Bluetooth: Add convenience macros for defined GAP timers
Change-Id: I6315c7791249d07fa2df0682decc0049718b5a06 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
6891b94357
commit
70669756ff
3 changed files with 18 additions and 8 deletions
|
@ -99,13 +99,17 @@ typedef void bt_le_scan_cb_t(const bt_addr_le_t *addr, int8_t rssi,
|
|||
uint8_t adv_type, const uint8_t *adv_data,
|
||||
uint8_t len);
|
||||
|
||||
/** Helper macro to enable active scanning to discover new devices */
|
||||
/** Helper macro to enable active scanning to discover new devices.
|
||||
*
|
||||
* The interval and window are intentionally set to the same value to
|
||||
* perform continuous scanning.
|
||||
*/
|
||||
#define BT_LE_SCAN_ACTIVE \
|
||||
(&(struct bt_le_scan_param) { \
|
||||
.type = BT_HCI_LE_SCAN_ACTIVE, \
|
||||
.filter_dup = BT_HCI_LE_SCAN_FILTER_DUP_ENABLE, \
|
||||
.interval = 0x0030, \
|
||||
.window = 0x0030, \
|
||||
.interval = BT_GAP_SCAN_FAST_INTERVAL, \
|
||||
.window = BT_GAP_SCAN_FAST_INTERVAL, \
|
||||
})
|
||||
|
||||
/** LE scan parameters */
|
||||
|
|
|
@ -100,6 +100,12 @@ struct bt_hci_cmd_hdr {
|
|||
#define BT_HCI_LE_CONN_PARAM_REQ_PROC 0x02
|
||||
#define BT_HCI_LE_SLAVE_FEATURES 0x08
|
||||
|
||||
/* Defined GAP timers */
|
||||
#define BT_GAP_SCAN_FAST_INTERVAL 0x0060
|
||||
#define BT_GAP_SCAN_FAST_WINDOW 0x0030
|
||||
#define BT_GAP_SCAN_SLOW_INTERVAL 0x0800
|
||||
#define BT_GAP_SCAN_SLOW_WINDOW 0x0012
|
||||
|
||||
/* OpCode Group Fields */
|
||||
#define BT_OGF_LINK_CTRL 0x01
|
||||
#define BT_OGF_BASEBAND 0x03
|
||||
|
|
|
@ -406,7 +406,7 @@ static int hci_le_create_conn(const bt_addr_le_t *addr)
|
|||
memset(cp, 0, sizeof(*cp));
|
||||
|
||||
/* Interval == window for continuous scanning */
|
||||
cp->scan_interval = sys_cpu_to_le16(0x0060);
|
||||
cp->scan_interval = sys_cpu_to_le16(BT_GAP_SCAN_FAST_INTERVAL);
|
||||
cp->scan_window = cp->scan_interval;
|
||||
|
||||
bt_addr_le_copy(&cp->peer_addr, addr);
|
||||
|
@ -1204,11 +1204,11 @@ int bt_le_scan_update(bool fast_scan)
|
|||
bt_conn_unref(conn);
|
||||
|
||||
if (fast_scan) {
|
||||
interval = 0x0060;
|
||||
window = 0x0030;
|
||||
interval = BT_GAP_SCAN_FAST_INTERVAL;
|
||||
window = BT_GAP_SCAN_FAST_WINDOW;
|
||||
} else {
|
||||
interval = 0x0800;
|
||||
window = 0x0012;
|
||||
interval = BT_GAP_SCAN_SLOW_INTERVAL;
|
||||
window = BT_GAP_SCAN_SLOW_WINDOW;
|
||||
}
|
||||
|
||||
return start_le_scan(BT_HCI_LE_SCAN_PASSIVE, interval, window, 0x01);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue