diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-23 08:51:34 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-23 08:51:34 +0000 |
commit | d7362993329a76de9fc0eda2ae8d3449bbefcf58 (patch) | |
tree | 9b0ba89947425a3f42bef162ab3bbc7d8f7dac65 | |
parent | 2fe5d87c4a952ed92a3ea5fb608179ce8fbc7ffa (diff) |
Use HCI command to set scan mode and not the kernel option
-rw-r--r-- | hcid/hcid.h | 2 | ||||
-rw-r--r-- | hcid/main.c | 47 |
2 files changed, 23 insertions, 26 deletions
diff --git a/hcid/hcid.h b/hcid/hcid.h index 91b311f8..0c77c225 100644 --- a/hcid/hcid.h +++ b/hcid/hcid.h @@ -70,7 +70,7 @@ struct device_opts { uint16_t pkt_type; uint16_t link_mode; uint16_t link_policy; - uint16_t scan; + uint8_t scan; int discovto; }; 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); } |