I am currently using release/v3.3 of the esp-idf and am running the ESP32 WROOM-32D as a GATT Server. When a client connects to the server I see all the expected events. Now when the client disconnects, I see the disconnect event but the server does not start advertising again. My code was essentially built upon the GATTS_DEMO from the idf.
I have added code to the GATTS_DISCONNECT_EVT that issues the gap_start_advertising() command, even though I don't feel it should be necessary. The command returns an ESP_OK however advertising does not seem to be restarting as the device is not visible in any BT scanning app I run.
I have seen issues like this reported in past versions of the idf, however, there was no real solution provided. I am using release/V3.3 as this is mentioned to be the latest stable version and I am targeting the ESP32 for a commercial product.
Any help would be greatly appreciated.
BLE Not starting advertising after disconnect
Re: BLE Not starting advertising after disconnect
I think there is something wrong with the code. Check mine. It should be look like that.
If you still facing the error, Please paste the whole code here. thanks!
- case ESP_GATTS_DISCONNECT_EVT:{
- ESP_LOGI(bleTag,"ESP_GATTS_DISCONNECT_EVT event called");
- esp_err_t ret = esp_ble_gap_set_device_name(btName);
- ESP_LOGI(bleTag, "name set is done %s\n", esp_err_to_name(ret));
- if (ret){
- ESP_LOGE(bleTag, "set device name failed, error code = %s", esp_err_to_name(ret));
- }
- ret = esp_ble_gap_config_adv_data(&adv_data);
- if (ret){
- ESP_LOGE(bleTag, "config adv data failed, error code = %x", ret);
- }
- adv_config_done |= adv_config_flag;
- ret = esp_ble_gap_config_adv_data(&scan_rsp_data);
- ESP_LOGI(bleTag, "response of scan data = %s", esp_err_to_name(ret));
- adv_config_done |= scan_rsp_config_flag;
- heart_rate.conn_id = 0xffff;
- }break;
If you still facing the error, Please paste the whole code here. thanks!
Re: BLE Not starting advertising after disconnect
It is up to you, designer, to decide when you want to start advertising. It can be right after disconnecting, or after connecting so you could have connected multiple central or one hour after disconnect, on push button, timer, or never.jjwsei wrote: ↑Tue Apr 21, 2020 1:43 pmI have added code to the GATTS_DISCONNECT_EVT that issues the gap_start_advertising() command, even though I don't feel it should be necessary. The command returns an ESP_OK however advertising does not seem to be restarting as the device is not visible in any BT scanning app I run.
There is so many possibilities so it would be not wise to force users to stop advertising, only because your use case is to advertise after disconnect.
Re: BLE Not starting advertising after disconnect
I use latest Arduino IDE and latest ESP32 add-on to debug a very simple BLE project. I have the same problem: ESP32 stop advertising after a client disconnect to it. The C++ code posted can not be added into my Arduino code for ESP32. Is there any way to solve this problem?
Re: BLE Not starting advertising after disconnect
Please send out the code I can look into it. Above code is for the esp -idf only. Thanks!color99 wrote: ↑Sun Oct 24, 2021 1:29 amI use latest Arduino IDE and latest ESP32 add-on to debug a very simple BLE project. I have the same problem: ESP32 stop advertising after a client disconnect to it. The C++ code posted can not be added into my Arduino code for ESP32. Is there any way to solve this problem?
Who is online
Users browsing this forum: No registered users and 123 guests