Hi
I am working with a central_and_peripheral_hr sample (nRF Connect SDK v1.8.0) and I want to get unconnectable directed advertising with scan request callback and high duty cycle.
These are the main steps I have followed so far:
1. If I want to get a scanned callback after a scan request it is required to use extended advertising (CONFIG_BT_EXT_ADV=y added to prj.conf). The following code is added to get scanned responses.
static void scanned(struct bt_le_ext_adv *adv,
struct bt_le_ext_adv_scanned_info *info){
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(info->addr, addr, sizeof(addr));
//if (info->addr->a.val[5] == 193)
printk("Scanned addr:%s\n", addr);
}
static struct bt_le_ext_adv_cb adv_callbacks = {
.sent = NULL,
.connected = NULL,
.scanned = scanned
};
err = bt_le_ext_adv_create(¶m, &adv_callbacks, &adv);
if (err) {
printk("Failed to create advertiser set (%d)\n", err);
return;
}
printk("Created adv: %p\n", adv);
err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad),
sd, ARRAY_SIZE(sd));
if (err) {
printk("Failed to set advertising data (%d)\n", err);
return;
}
printk("Adv data set: %p\n", adv);
err = bt_le_ext_adv_start(adv, NULL);
if (err) {
printk("Failed to start advertising set (%d)\n", err);
return;
}
printk("Advertiser %p set started\n", adv);
2. Then, the adv params are modified to include a peer target device:
static bt_addr_le_t beacon_peer;
const static struct bt_le_adv_param param =
BT_LE_ADV_PARAM_INIT( BT_LE_ADV_OPT_EXT_ADV |
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY |
BT_LE_ADV_OPT_FILTER_SCAN_REQ |
BT_LE_ADV_OPT_NOTIFY_SCAN_REQ |
BT_LE_ADV_OPT_SCANNABLE,
BT_GAP_ADV_INT_MIN, \
BT_GAP_ADV_INT_MAX, &beacon_peer);
3. My problem now is that it is required to include BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY as an option or an error will be triggered when starting to advertise. Please check adv.c valid_adv_ext_param function in line 237.
if (param->peer &&
!(param->options & BT_LE_ADV_OPT_EXT_ADV) &&
!(param->options & BT_LE_ADV_OPT_CONNECTABLE)) {
/* Cannot do directed non-connectable advertising
* without extended advertising.
*/
return false;
}
if (param->peer &&
(param->options & BT_LE_ADV_OPT_EXT_ADV) &&
!(param->options & BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY)) {
/* High duty cycle directed connectable advertising
* shall not be used with Extended Advertising.
*/
return false;
}
Thus my questions
1. What are the implications of enabling BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option?
2. Is there a way to perform an unconnectable directed advertising without enabling BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option?
Many thanks