ESP-IDF BLE No Disconnect Event

Shofixti
Posts: 1
Joined: Wed Feb 07, 2018 10:02 pm

ESP-IDF BLE No Disconnect Event

Postby Shofixti » Wed Feb 07, 2018 10:09 pm

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.

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: ESP-IDF BLE No Disconnect Event

Postby vonnieda » Mon Mar 05, 2018 11:24 pm

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.
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.

flodis
Posts: 12
Joined: Mon Feb 26, 2018 5:09 am

Re: ESP-IDF BLE No Disconnect Event

Postby flodis » Mon Mar 19, 2018 1:49 pm

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.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF BLE No Disconnect Event

Postby chegewara » Mon Mar 19, 2018 5:19 pm

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.

flodis
Posts: 12
Joined: Mon Feb 26, 2018 5:09 am

Re: ESP-IDF BLE No Disconnect Event

Postby flodis » Tue Mar 20, 2018 2:43 pm

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.
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.

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.

sparta
Posts: 3
Joined: Mon Nov 28, 2022 10:54 am

Re: ESP-IDF BLE No Disconnect Event

Postby sparta » Tue Nov 29, 2022 6:55 am

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.

Who is online

Users browsing this forum: No registered users and 105 guests