summaryrefslogtreecommitdiffstats
path: root/hcid/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'hcid/main.c')
-rw-r--r--hcid/main.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/hcid/main.c b/hcid/main.c
index 2022f761..0a6b832f 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -315,31 +315,6 @@ static void configure_device(int dev_id)
}
}
- /* Set default discoverable timeout if not set */
- if (!(device_opts->flags & (1 << HCID_SET_DISCOVTO)))
- device_opts->discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
-
- /* Set scan mode */
- if (!read_device_mode(&di.bdaddr, mode, sizeof(mode))) {
- if (!strcmp(mode, MODE_OFF) && hcid.offmode == HCID_OFFMODE_NOSCAN)
- device_opts->scan = SCAN_DISABLED;
- else if (!strcmp(mode, MODE_CONNECTABLE))
- device_opts->scan = SCAN_PAGE;
- else if (!strcmp(mode, MODE_DISCOVERABLE)) {
- /* Set discoverable only if timeout is 0 */
- if (!get_discoverable_timeout(dev_id))
- device_opts->scan = SCAN_PAGE | SCAN_INQUIRY;
- else
- device_opts->scan = SCAN_PAGE;
- }
- }
-
- dr.dev_opt = device_opts->scan;
- if (ioctl(dd, HCISETSCAN, (unsigned long) &dr) < 0) {
- error("Can't set scan mode on hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
- }
-
/* Set device name */
if ((device_opts->flags & (1 << HCID_SET_NAME)) && device_opts->name) {
change_local_name_cp cp;
@@ -408,6 +383,28 @@ static void configure_device(int dev_id)
WRITE_PAGE_TIMEOUT_CP_SIZE, &cp);
}
+ /* Set default discoverable timeout if not set */
+ if (!(device_opts->flags & (1 << HCID_SET_DISCOVTO)))
+ device_opts->discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
+
+ /* Set scan mode */
+ if (!read_device_mode(&di.bdaddr, mode, sizeof(mode))) {
+ if (!strcmp(mode, MODE_OFF) && hcid.offmode == HCID_OFFMODE_NOSCAN)
+ device_opts->scan = SCAN_DISABLED;
+ else if (!strcmp(mode, MODE_CONNECTABLE))
+ device_opts->scan = SCAN_PAGE;
+ else if (!strcmp(mode, MODE_DISCOVERABLE)) {
+ /* Set discoverable only if timeout is 0 */
+ if (!get_discoverable_timeout(dev_id))
+ device_opts->scan = SCAN_PAGE | SCAN_INQUIRY;
+ else
+ device_opts->scan = SCAN_PAGE;
+ }
+ }
+
+ hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE, 1,
+ &device_opts->scan);
+
exit(0);
}