Hello all,
Writing some BLE code today, mostly following from the excellent example here: https://github.com/espressif/esp-idf/tr ... att_server. However I've hit a bit of a snag while trying to deal with disconnect events.
Simply, I don't seem to get them.
Right now I can connect to my ESP32, Read, Write, etc... But I can't ever reconnect to it as it never begins advertising again following a disconnect. Tracing the issue, I find that my "ESP_GATTS_DISCONNECT_EVT" case never gets called. Odd... So I dig some more, I find out that oftentimes the ESP_GATTS_CLOSE_EVT event is a better candidate for this, so I make sure I work with that as well... Still no luck.
Finally, I put a debug statement in my event handler before my switch statement going over the event, and I start logging out every event that comes my way. It turns out that following a disconnect... Simply nothing happens.
I've tried connecting with my computer as well as my phone using different test apps, and it all seems to be the same. No disconnect or close events get sent my way.
Anybody have any ideas as to where to start diagnosing this issue? I can provide my [very messy] code if needed.
ESP-IDF BLE No Disconnect Event
Re: ESP-IDF BLE No Disconnect Event
Hi @Shofixti, have you found out anything else about this issue? I seem to be experiencing the same problem. It's not in every case - sometimes I get disconnect events, but it's pretty often. I find that in this case advertising seems to restart completely on it's own without me having called esp_ble_gap_start_advertising as I get a ESP_GAP_BLE_ADV_START_COMPLETE_EVT.Shofixti wrote:Hello all,
Writing some BLE code today, mostly following from the excellent example here: https://github.com/espressif/esp-idf/tr ... att_server. However I've hit a bit of a snag while trying to deal with disconnect events.
Simply, I don't seem to get them.
Right now I can connect to my ESP32, Read, Write, etc... But I can't ever reconnect to it as it never begins advertising again following a disconnect. Tracing the issue, I find that my "ESP_GATTS_DISCONNECT_EVT" case never gets called. Odd... So I dig some more, I find out that oftentimes the ESP_GATTS_CLOSE_EVT event is a better candidate for this, so I make sure I work with that as well... Still no luck.
Finally, I put a debug statement in my event handler before my switch statement going over the event, and I start logging out every event that comes my way. It turns out that following a disconnect... Simply nothing happens.
I've tried connecting with my computer as well as my phone using different test apps, and it all seems to be the same. No disconnect or close events get sent my way.
Anybody have any ideas as to where to start diagnosing this issue? I can provide my [very messy] code if needed.
Re: ESP-IDF BLE No Disconnect Event
I have identical issue when connecting using the BLE extension in app inventor. It normally works for the BLE devices I have tested from Nordic Semiconductor (nordicsemi) like the nRF52840.
Interestingly the nRF Connect for Mobile from nordicsemi is able to connect and disconnect from the ESP32 gatt server demo generating 'ESP_GATTS_DISCONNECT_EVT' events.
Interestingly the nRF Connect for Mobile from nordicsemi is able to connect and disconnect from the ESP32 gatt server demo generating 'ESP_GATTS_DISCONNECT_EVT' events.
Re: ESP-IDF BLE No Disconnect Event
This is strange, because i dont have any issues with disconnecting client from esp32 and reconnecting it using nRF connect or even app written with app inventor 2.
Re: ESP-IDF BLE No Disconnect Event
Yes I also found it strange and had to peer review myself and found out my app inventor log was wiped on each BLE "devicefound" event. I did not notice I connected multiple times to the same device. It was great to find out you can accidentally burst connect multiple times to the same device and app inventor will not complain. If connect is called multiple times calling BLE disconnect there are still an active connection. I have not tried to close multiple times on same uuid. I was happy finding the error.chegewara wrote:This is strange, because i dont have any issues with disconnecting client from esp32 and reconnecting it using nRF connect or even app written with app inventor 2.
Lesson learned is to connect only once by disabling scanning as device found or if continuous scanning is needed store the uuid to indicate connection pending.
Re: ESP-IDF BLE No Disconnect Event
I have the same problem with esp_ble_spp_server_demo.c example.Would anybody kindly guide me to how to check if I am connecting to the same device multiple times?
Any help,idea will be highly appreciated.
Thanks.
Any help,idea will be highly appreciated.
Thanks.
Who is online
Users browsing this forum: No registered users and 208 guests