diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/adapter.c | 8 | ||||
-rw-r--r-- | src/hcid.h | 1 | ||||
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/main.conf | 3 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/adapter.c b/src/adapter.c index 360f76d2..5eaf729a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2530,8 +2530,12 @@ static int adapter_up(struct btd_adapter *adapter, int dd) if (read_device_pairable(&adapter->bdaddr, &adapter->pairable) < 0) adapter->pairable = TRUE; - /* Set scan mode */ - if (read_device_mode(srcaddr, mode, sizeof(mode)) < 0) { + if (!adapter->initialized && !main_opts.remember_powered) { + if (main_opts.mode == MODE_OFF) + strcpy(mode, "off"); + else + strcpy(mode, "connectable"); + } else if (read_device_mode(srcaddr, mode, sizeof(mode)) < 0) { if (!adapter->initialized && main_opts.mode == MODE_OFF) strcpy(mode, "off"); else @@ -55,6 +55,7 @@ struct main_opts { uint32_t pairto; uint16_t link_mode; uint16_t link_policy; + gboolean remember_powered; uint8_t scan; uint8_t mode; @@ -175,6 +175,14 @@ static void parse_config(GKeyFile *config) } else if (boolean == FALSE) main_opts.mode = MODE_OFF; + boolean = g_key_file_get_boolean(config, "General", + "RememberPowered", &err); + if (err) { + debug("%s", err->message); + g_clear_error(&err); + } else if (boolean == FALSE) + main_opts.remember_powered = boolean; + str = g_key_file_get_string(config, "General", "DeviceID", &err); if (err) { debug("%s", err->message); @@ -532,6 +540,7 @@ static void init_defaults(void) main_opts.mode = MODE_CONNECTABLE; main_opts.name = g_strdup("BlueZ"); main_opts.discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT; + main_opts.remember_powered = TRUE; if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 1) < 0) strcpy(main_opts.host_name, "noname"); diff --git a/src/main.conf b/src/main.conf index a7bb0e40..5d49c7b3 100644 --- a/src/main.conf +++ b/src/main.conf @@ -34,6 +34,9 @@ DiscoverSchedulerInterval = 0 # SetProperty(Powered, ...) hasn't been called yet. Defaults to true InitiallyPowered = true +# Remember the previously stored Powered state when initializing adapters +RememberPowered = true + # Use vendor, product and version information for DID profile support. # The values are separated by ":" and VID, PID and version. #DeviceID = 1234:5678:abcd |