Can't get BLE extended connectable advertising timeout callback

Using SDK 2.1.2

Trying to set up connectable advertising for specific period of time and be notified when this period of time expired.
My setup sequence (simplified for demonstration purpose):

struct bt_le_ext_adv_cb ext_adv_cb = {
.sent = adv_timed_out,
};

static struct bt_conn_cb conn_callbacks = {
.connected = connected,
.disconnected = disconnected,
.security_changed = security_changed,
};
 

Init (one time at boot):
------
bt_conn_cb_register(&conn_callbacks);
bt_conn_auth_cb_register(&conn_auth_callbacks);
bt_conn_auth_info_cb_register(&auth_cb_info);
bt_enable(NULL);
settings_load();
bt_nus_init(&nus_cb);
struct bt_le_adv_param *adv_param = BT_LE_ADV_CONN;
bt_le_ext_adv_create(adv_param, &ext_adv_cb, out_adv);
bt_le_ext_adv_set_data(...);


Start advertising (every time I want to give opportunity to my central device to connect):
----------------------
#define BLE_CONN_ADV_TIMEOUT (4 * 100) // 4 sec in 10ms units
param = BT_LE_EXT_ADV_START_PARAM(BLE_CONN_ADV_TIMEOUT, 0); 
bt_le_ext_adv_stop(adv);  // JIC there is a previous advertisement in progress
bt_le_ext_adv_start(adv, param);


If connection happens, I receive both bt_conn_cb.connected and subsequent .disconnected callbacks 
If no connection happened within 4 seconds I would expect (perhaps mistakenly) to receive bt_le_ext_adv_cb.sent callback, but it doesn't happen.

Interestingly, if I change my advertising to non-connectable, and set param as
param = BT_LE_EXT_ADV_START_PARAM(0, 3);

then I do receive this .sent callback, and info->num_events is correctly set to 3.

Looking at zephyr/include/zephyr/bluetooth/bluetooth.h

struct bt_le_ext_adv_cb {
/**
* @brief The advertising set has finished sending adv data.
*
* This callback notifies the application that the advertising set has
* finished sending advertising data.
* The advertising set can either have been stopped by a timeout or
* because the specified number of advertising events has been reached.
*
* @param adv The advertising set object.
* @param info Information about the sent event.
*/
void (*sent)(struct bt_le_ext_adv *adv,  <-----------------------
struct bt_le_ext_adv_sent_info *info);

it appears that it should work on either timeout or number of events

What am I missing ?



Parents Reply Children
No Data
Related