summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-11-29 16:23:47 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-11-29 16:23:47 +0200
commit0d97d1961ece9c6fb7bf76f60562e9cbb19ee64c (patch)
tree09b163255cb840de8aa931048327a73f401e93c9 /src
parentc1f2c30ff5461cf5b3fca3d96c8425df2769e565 (diff)
Mode restoring for offmode=devdown should be per-adapter
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/adapter.c b/src/adapter.c
index c6ab4e65..fb577d89 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -117,6 +117,8 @@ struct btd_adapter {
struct hci_dev dev; /* hci info */
gboolean pairable; /* pairable state */
+
+ gboolean first_init; /* Needed for offmode=devdown */
};
static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
@@ -2505,11 +2507,15 @@ static void adapter_up(struct btd_adapter *adapter, int dd)
const char *pmode;
char mode[14], srcaddr[18];
int i;
- gboolean powered;
- gboolean discoverable;
+ gboolean powered, discoverable, first_init;
ba2str(&adapter->bdaddr, srcaddr);
+ first_init = adapter->first_init;
+
+ if (adapter->first_init)
+ adapter->first_init = FALSE;
+
adapter->up = 1;
adapter->discov_timeout = get_discoverable_timeout(srcaddr);
adapter->pairable_timeout = get_pairable_timeout(srcaddr);
@@ -2531,11 +2537,8 @@ static void adapter_up(struct btd_adapter *adapter, int dd)
adapter->mode = MODE_OFF;
adapter->scan_mode= SCAN_DISABLED;
} else if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
- static gboolean restore_on_mode = FALSE;
-
- if (!restore_on_mode) {
+ if (first_init) {
ioctl(dd, HCIDEVDOWN, adapter->dev_id);
- restore_on_mode = TRUE;
return;
}
@@ -2926,6 +2929,7 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id)
}
adapter->dev_id = id;
+ adapter->first_init = TRUE;
adapter->state |= RESOLVE_NAME;
adapter->path = g_strdup(path);