diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-24 12:31:56 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-24 17:55:16 -0700 |
commit | 1f100851bef2e19df94620b967b77c2502d474b7 (patch) | |
tree | c672a710f836e59627ef6d3714ecfe53736925db /src/adapter.c | |
parent | 5f3961abfd5e2ac3c614925dbf63b86c38899a0b (diff) |
Restore 'on' mode on the first time adapter comes up and is on OffMode = DevDown
Diffstat (limited to 'src/adapter.c')
-rw-r--r-- | src/adapter.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/adapter.c b/src/adapter.c index 0f21f2a1..9a52c6c7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2329,8 +2329,20 @@ 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) { - ioctl(dd, HCIDEVDOWN, adapter->dev_id); - return; + static gboolean restore_on_mode = FALSE; + + if (!restore_on_mode) { + ioctl(dd, HCIDEVDOWN, adapter->dev_id); + restore_on_mode = TRUE; + return; + } + + if (read_on_mode(srcaddr, mode, sizeof(mode)) < 0) + write_device_mode(&adapter->bdaddr, mode); + else + write_device_mode(&adapter->bdaddr, "connectable"); + + adapter_up(adapter, dd); } } else if (!strcmp(mode, "connectable")) { adapter->mode = MODE_CONNECTABLE; @@ -2393,7 +2405,7 @@ static void adapter_up(struct btd_adapter *adapter, int dd) ADAPTER_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN, &powered); - discoverable = adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY) ? TRUE + discoverable = adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY) ? TRUE : FALSE; dbus_connection_emit_property_changed(connection, adapter->path, |