When creating a BLE peripheral which will be advertising its existence, I understand that I must call:
esp_ble_gap_config_adv_data()
to set the content of the advertisement and then call
esp_ble_gap_start_advertising()
to begin the actual advertising procedure.
However, my question is about timing. When we call:
esp_ble_gap_config_adv_data()
at some time later we will receive an ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT that indicates that the advertising data has been set. My core question is as follows:
Do I have to wait for the ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT event before calling esp_ble_gap_start_advertising() or can I call esp_ble_gap_start_advertising() immediately following a call to esp_ble_gap_config_adv_data()?
I could see either being valid and am hoping to hear the sequence rules in effect.
Sequence flow for BLE advertising ... must I wait for an ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT?
Sequence flow for BLE advertising ... must I wait for an ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 36
- Joined: Thu Jun 29, 2017 7:20 am
Re: Sequence flow for BLE advertising ... must I wait for an ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT?
It is allowed to call “set adv data”, “set scan rsp data” and “start adv” together under the condition that adv data and scan rsp data are all correctly set. Calling “Start adv” before adv data being set correctly will cause that peripheral advertises NULL packets, which may cause unexpected result.
So it is better to wait for “adv data set completed event” and “scan response set completed event” (if you have scan response) before start advertising.
So it is better to wait for “adv data set completed event” and “scan response set completed event” (if you have scan response) before start advertising.
Who is online
Users browsing this forum: No registered users and 156 guests