summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-adapter.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-11-14 18:22:37 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-11-14 18:22:37 +0000
commit38a404ba5bfbf21d4607a5d048846288a2359c56 (patch)
treec2d2f7a9d8e5c5077e21ca2cd99d17129cd28201 /hcid/dbus-adapter.c
parentfc03565db71241cbc0a47ae7528273d3982fb606 (diff)
Add offmode config option for defining SetMode("off") behaviour
Diffstat (limited to 'hcid/dbus-adapter.c')
-rw-r--r--hcid/dbus-adapter.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 3edbabf2..c7bc7671 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -426,7 +426,10 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
if (dd < 0)
return error_no_such_adapter(conn, msg);
- if (!adapter->up) {
+ if (!adapter->up &&
+ (hcid.offmode == HCID_OFFMODE_NOSCAN ||
+ (hcid.offmode == HCID_OFFMODE_DEVDOWN &&
+ hci_mode != SCAN_DISABLED))) {
bdaddr_t local;
str2ba(adapter->address, &local);
@@ -434,7 +437,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
write_device_mode(&local, scan_mode);
/* Start HCI device */
- if (ioctl(dd, HCIDEVUP, adapter->dev_id) == 0)
+ if (ioctl(dd, HCIDEVUP, adapter->dev_id) == 0)
goto done; /* on success */
if (errno != EALREADY) {
@@ -447,6 +450,16 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
}
}
+ if (adapter->up && hci_mode == SCAN_DISABLED &&
+ hcid.offmode == HCID_OFFMODE_DEVDOWN) {
+ if (ioctl(dd, HCIDEVDOWN, adapter->dev_id) < 0) {
+ hci_close_dev(dd);
+ return error_failed(conn, msg, errno);
+ }
+
+ goto done;
+ }
+
/* Check if the new requested mode is different from the current */
if (current_mode != hci_mode) {
struct hci_request rq;