summaryrefslogtreecommitdiffstats
path: root/hcid/main.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-11-21 13:03:48 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-11-21 13:03:48 +0000
commit8982d081ea2af0687e2eb7e3babff5d692f0577c (patch)
tree433f4d2a3706c91cc5d4fac8f14d9925757cbabb /hcid/main.c
parent253ba836f00b17a4da1436520f3735593ba9493d (diff)
Improve "off" mode behaviour when offmode=devdown
Diffstat (limited to 'hcid/main.c')
-rw-r--r--hcid/main.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/hcid/main.c b/hcid/main.c
index 8abd3d40..5f05543b 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -302,10 +302,12 @@ static void configure_device(int hdev)
}
}
- dr.dev_opt = device_opts->scan;
- if (ioctl(s, HCISETSCAN, (unsigned long) &dr) < 0) {
- error("Can't set scan mode on hci%d: %s (%d)",
- hdev, strerror(errno), errno);
+ if (!(hcid.offmode == HCID_OFFMODE_DEVDOWN && !strcmp(mode, MODE_OFF))) {
+ dr.dev_opt = device_opts->scan;
+ if (ioctl(s, HCISETSCAN, (unsigned long) &dr) < 0) {
+ error("Can't set scan mode on hci%d: %s (%d)",
+ hdev, strerror(errno), errno);
+ }
}
/* Set device name */
@@ -417,6 +419,16 @@ static void init_device(int hdev)
if (hci_test_bit(HCI_RAW, &di.flags))
exit(0);
+ if (hcid.offmode == HCID_OFFMODE_DEVDOWN) {
+ char mode[16];
+
+ if (read_device_mode(&di.bdaddr, mode, sizeof(mode)) == 0
+ && strcmp(mode, "off") == 0) {
+ ioctl(dd, HCIDEVDOWN, dev_id);
+ exit(0);
+ }
+ }
+
memset(&dr, 0, sizeof(dr));
dr.dev_id = dev_id;
device_opts = get_device_opts(dd, dev_id);