Should we check the BLE connection when we call esp_ble_gattc_read_char?
Posted: Mon Mar 12, 2018 9:24 am
by kxJiang
hi,
if the ble connection between ESP32 and a device is suddenly broken, when we are periodically calling
ESP32 will run crash. Is there any safe manner to call
something like that:
Code: Select all
if (ble_connection_is_ok())
{
esp_ble_gattc_read_char();
}
thanks!
Re: Should we check the BLE connection when we call esp_ble_gattc_read_char?
Posted: Mon Mar 12, 2018 7:04 pm
by kolban
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.
Re: Should we check the BLE connection when we call esp_ble_gattc_read_char?
Posted: Tue Mar 13, 2018 5:59 am
by kxJiang
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