In my application, I'm using the Scan Response Packet to transmit some device related information, rather than requiring Clients to connect to get this. I'm using NCS v2.0.0 and testing on an nRF52-DK.
I'm using the following to store the scan response information, and I update the information in there whenever it changes.
static struct bt_data sd[] = {
BT_DATA(BT_DATA_MANUFACTURER_DATA, NULL, BT_GAP_ADV_MAX_ADV_DATA_LEN-2),
};
On first boot up, when I start BLE, I make a call to:
err = bt_le_adv_start(BT_LE_ADV_CONN_LSR_AD, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
That successfully updates the scan response packet. But if I subsequently attempt to update the scan response packet whilst I'm still advertising, via a call to:
err = bt_le_adv_update_data(ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
Then the scan response packet doesn't change. I'm checking the result of err after this function call, and its returning 0, which indicates that its been successful.
The only way I seem able to get the scan response packet to update correctly is if I:
- Stop advertising
- Update scan response packet
- Restart advertising
Is there a way to dynamically update the scan response packet whilst advertising? Or do I need to follow the process of stop, update, restart?
Cheers,
Mike