Closed
Description
Board
heltec_wifi_kit_32
Device Description
nothing else connected
Hardware Configuration
nothing else connected
Version
v2.0.5
IDE Name
PlatformIO 6.1.4
Operating System
win10
Flash frequency
default
PSRAM enabled
no
Upload speed
default
Description
General
- ESP32 connects to target BLE device
- ESP32 hangs after some time
What happens
- Target BLE device has bad radio and often losses connection
- ESP32 stuck if BLE characteristics are read and connection is lost
Found issue
- BLE client uses semaphores to manage state
- Semaphore is not cleaned up if BLE device disconnects
- Seems similar to [BLE Client] Deadlock when calling writeValue after registerForNotify #4952
Sketch
use ble client example
Debug Message
[ 31021][V][BLEClient.cpp:412] getService(): >> getService: uuid: XXXXX
[ 31024][V][BLEClient.cpp:425] getService(): << getService: found the service with uuid: XXXXX
- Found our service
- Found our characteristic
[ 31246][V][BLERemoteCharacteristic.cpp:423] readValue(): >> readValue(): uuid: XXXXX, handle: 11 0x0b
[ 31249][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: ReadCharEvt (0x3ffdefa0), owner: <N/A> for readValue
[ 31259][V][FreeRTOS.cpp:198] take(): Semaphore taken: name: ReadCharEvt (0x3ffdefa0), owner: readValue
[ 31268][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: ReadCharEvt (0x3ffdefa0), owner: readValue for readValue
[ 32426][D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_DISCONNECT_EVT
[ 32427][V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: ESP_GATTC_DISCONNECT_EVT
[ 32434][V][BLEUtils.cpp:1326] dumpGattClientEvent(): [reason: ESP_GATT_CONN_TERMINATE_PEER_USER, conn_id: 0, remote_bda: XXXXX]
[ 32447][D][BLEClient.cpp:178] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_DISCONNECT_EVT
[ 32458][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: OpenEvt (0x3ffdc248), owner: <N/A>
[ 32466][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: RssiCmplEvt (0x3ffdc310), owner: <N/A>
[ 32475][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: SearchCmplEvt (0x3ffdc2ac), owner: <N/A>
[ 32484][I][BLEDevice.cpp:633] removePeerDevice(): remove: 1, GATT role client
[ 32491][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffdf390), owner: <N/A>
[ 32500][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffdf868), owner: <N/A>
[ 32509][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffdfd40), owner: <N/A>
[ 32518][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe1160), owner: <N/A>
[ 32527][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe1670), owner: <N/A>
[ 32536][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe1b80), owner: <N/A>
[ 32545][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe2090), owner: <N/A>
[ 32554][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe25a0), owner: <N/A>
[ 32563][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe2ab0), owner: <N/A>
[ 32572][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe2fc0), owner: <N/A>
[ 32580][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe34d0), owner: <N/A>
[ 32589][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe39e0), owner: <N/A>
[ 32598][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe4bc4), owner: <N/A>
[ 32607][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: WriteCharEvt (0x3ffe509c), owner: <N/A>
[ 32616][D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_CLOSE_EVT
[ 32627][V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: ESP_GATTC_CLOSE_EVT
[ 32634][V][BLEUtils.cpp:1297] dumpGattClientEvent(): [status: ESP_GATT_OK, reason:ESP_GATT_CONN_TERMINATE_PEER_USER, conn_id: 0]
[ 32646][D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_UNREG_EVT
[ 32656][V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: ESP_GATTC_UNREG_EVT
ESP32 stuck, no new output.
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.