Should we check the BLE connection when we call esp_ble_gattc_read_char?

kxJiang
Posts: 6
Joined: Fri Jun 16, 2017 8:41 am

Should we check the BLE connection when we call esp_ble_gattc_read_char?

Postby kxJiang » Mon Mar 12, 2018 9:24 am

hi,
if the ble connection between ESP32 and a device is suddenly broken, when we are periodically calling

Code: Select all

esp_ble_gattc_read_char
ESP32 will run crash. Is there any safe manner to call

Code: Select all

esp_ble_gattc_read_char
something like that:

Code: Select all

if (ble_connection_is_ok())
{
	esp_ble_gattc_read_char();
}
thanks!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Should we check the BLE connection when we call esp_ble_gattc_read_char?

Postby kolban » Mon Mar 12, 2018 7:04 pm

Howdy,
The call to esp_ble_gattc_read_char() should not crash the ESP32. I think that's the symptom we should be looking at. When this call is made, we should eventually receive an ESP_GATTC_READ_CHAR_EVT event. This contains a field called "status" that should inform us of the success (or otherwise) of the call. What I would suggest is to investigate the nature of the crash itself. If as you say, the ESP32 crashes, then we are going to want to create a Github issue for tracking and resolution.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

kxJiang
Posts: 6
Joined: Fri Jun 16, 2017 8:41 am

Re: Should we check the BLE connection when we call esp_ble_gattc_read_char?

Postby kxJiang » Tue Mar 13, 2018 5:59 am

Hi,kolban. Thanks for your reply! Your are right. When we call esp_ble_gattc_read_char() in such situations that is when the BLE connection is broken, I got the ESP_GATT_ERROR from the "status" field under ESP_GATTC_READ_CHAR_EVT event. I haven't process this error, that caused ESP32 failed since I still tried to do something with the BLE things. Thanks again! I also very appreciate your excellent workings on ESP. I have read your book long before, it's very informative. Sometimes I wonder how can you be such productive and always being enthusiastic. Any personal experiences shared on embedded system would be nice :D

Who is online

Users browsing this forum: No registered users and 86 guests