Bluetooth: Add ability to specify dedicated LE scan parameters

We'll need to have a much more flexible LE scanning API. This is a
first step towards it. The existing BT_LE_SCAN_FILTER_DUP_* enum
values are converted to macros to avoid having to update application
code at this point.

Change-Id: I0c8d29dc156bad67cddc9401c0d72aee8ec6d8de
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-12-03 15:17:10 +02:00 committed by Anas Nashif
commit 6f470dcbce
2 changed files with 12 additions and 9 deletions

View file

@ -93,24 +93,27 @@ 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);
/** Filter out duplicate scanning results. **/
typedef enum {
BT_LE_SCAN_FILTER_DUP_DISABLE,
BT_LE_SCAN_FILTER_DUP_ENABLE,
} bt_le_scan_filter_dup_t;
#define BT_LE_SCAN_FILTER_DUP_DISABLE \
(&(struct bt_le_scan_param) { .filter_dup = 0x00 })
#define BT_LE_SCAN_FILTER_DUP_ENABLE \
(&(struct bt_le_scan_param) { .filter_dup = 0x01 })
struct bt_le_scan_param {
uint8_t filter_dup;
};
/** @brief Start (LE) scanning
*
* Start LE scanning with and provide results through the specified
* callback.
*
* @param filter_dups Enable duplicate filtering (or not).
* @param param Scan parameters.
* @param cb Callback to notify scan results.
*
* @return Zero on success or error code otherwise, positive in case
* of protocol error or negative (POSIX) in case of stack internal error
*/
int bt_le_scan_start(bt_le_scan_filter_dup_t filter, bt_le_scan_cb_t cb);
int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb);
/** @brief Stop (LE) scanning.
*

View file

@ -2068,7 +2068,7 @@ int bt_le_adv_stop(void)
return 0;
}
int bt_le_scan_start(bt_le_scan_filter_dup_t filter, bt_le_scan_cb_t cb)
int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)
{
/* Return if active scan is already enabled */
if (scan_dev_found_cb) {
@ -2076,7 +2076,7 @@ int bt_le_scan_start(bt_le_scan_filter_dup_t filter, bt_le_scan_cb_t cb)
}
scan_dev_found_cb = cb;
if (filter == BT_LE_SCAN_FILTER_DUP_DISABLE) {
if (!param->filter_dup) {
atomic_clear_bit(bt_dev.flags, BT_DEV_SCAN_FILTER_DUP);
}