summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-12-16 15:30:34 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-12-16 15:30:34 +0200
commitbf64c9b32825beba09cd0e96fc93ce9a4cf4f352 (patch)
tree079acc89476aea0b8a6f84ca7ef51832dd57f08a
parent567d6494208ceae0d2101df36e7c285ad998242d (diff)
Implement InitiallyPowered config option
-rw-r--r--src/adapter.c8
-rw-r--r--src/main.c11
-rw-r--r--src/main.conf4
3 files changed, 21 insertions, 2 deletions
diff --git a/src/adapter.c b/src/adapter.c
index c85ca360..853592bb 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2531,8 +2531,12 @@ static int adapter_up(struct btd_adapter *adapter, int dd)
adapter->pairable = TRUE;
/* Set scan mode */
- if (read_device_mode(srcaddr, mode, sizeof(mode)) < 0)
- goto proceed;
+ if (read_device_mode(srcaddr, mode, sizeof(mode)) < 0) {
+ if (!adapter->initialized && main_opts.mode == MODE_OFF)
+ strcpy(mode, "off");
+ else
+ goto proceed;
+ }
if (g_str_equal(mode, "off")) {
powered = FALSE;
diff --git a/src/main.c b/src/main.c
index af3368e9..c53454e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,6 +96,7 @@ static void parse_config(GKeyFile *config)
GError *err = NULL;
char *str;
int val;
+ gboolean boolean;
if (!config)
return;
@@ -173,6 +174,16 @@ static void parse_config(GKeyFile *config)
main_opts.inqmode = val;
}
+ boolean = g_key_file_get_boolean(config, "General",
+ "InitiallyPowered",
+ &err);
+ if (err) {
+ debug("%s", err->message);
+ g_clear_error(&err);
+ } else if (boolean == FALSE)
+ main_opts.mode = MODE_OFF;
+
+
main_opts.link_mode = HCI_LM_ACCEPT;
main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
diff --git a/src/main.conf b/src/main.conf
index 0ddd9498..2479df39 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -29,3 +29,7 @@ PageTimeout = 8192
# Discover scheduler interval used in Adapter.DiscoverDevices
# The value is in seconds. Defaults is 0 to use controller scheduler
DiscoverSchedulerInterval = 0
+
+# Whether adapters should assume Powered=off when SetProperty(Powered, ...)
+# hasn't been called yet. Defaults to true
+InitiallyPowered = true