[pioarduino] Workaround BLE stability issues on reconnect to certain Android phones#10220
Conversation
…arent ESP-IDF Bluetooth bug when re-connecting to Pixel 8 Android devices. Initial pairing works, but after ESP32 is rebooted, phone fails to reconnect. Meshtastic app shows it as disconnecting immediately. LightBlue shows a more detailed error "Peripheral Connection - Warning: onConnectionStatusChange: status 61" (0x3D - MIC Failure). Bug report to Espresssif: espressif/esp-idf#18126 (comment)
…ndroid reconnect. Crash looks like this: [ 11966][E][BLEAdvertising.cpp:341] setScanResponseData(): ble_gap_adv_rsp_set_data: 22 [ 11975][E][BLEAdvertising.cpp:1554] start(): Host reset, wait for sync. ERROR | ??:??:?? 11 BLE failed to start advertising Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. Core 0 register dump: PC : 0x420e6190 PS : 0x00060730 A0 : 0x820e158b A1 : 0x3fce50c0 A2 : 0x00000000 A3 : 0x3fcb8600 A4 : 0x3fcb85cc A5 : 0x00000000 A6 : 0x00000000 A7 : 0x00000c03 A8 : 0x00000000 A9 : 0x3fce50b0 A10 : 0x0000000e A11 : 0x00000000 A12 : 0x00000010 A13 : 0x3fce50e0 A14 : 0x00000c03 A15 : 0x00000001 SAR : 0x0000001e EXCCAUSE: 0x0000001c EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000 Backtrace: 0x420e618d:0x3fce50c0 0x420e1588:0x3fce5110 0x420dfe87:0x3fce5200 0x420dfefb:0x3fce5220 0x420dff3f:0x3fce5240 0x4219602b:0x3fce5260 0x4037b0e5:0x3fce5280 0x4201edf3:0x3fce52a0 Connection seems fast enough even without this. We'll investigate the reason for the crash and re-enable once it's safe.
There was a problem hiding this comment.
Pull request overview
Workarounds BLE reconnect instability on ESP32 (pioarduino / Arduino-ESP32 v3.x path), specifically targeting crashes seen when reconnecting from certain Android devices (e.g., Pixel 8), to unblock ongoing NimBLE migration work.
Changes:
- Lower Arduino core log level from DEBUG to INFO in the shared ESP32 PlatformIO config (with an inline warning and upstream issue link).
- Disable the NimBLE
ble_gap_set_data_len()request on connect (suspected crash trigger on reconnect for affected phones).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| variants/esp32/esp32-common.ini | Drops CORE_DEBUG_LEVEL to INFO and documents the ESP-IDF BT crash risk when using DEBUG. |
| src/nimble/NimbleBluetooth.cpp | Disables ble_gap_set_data_len() on connect to avoid reconnect crashes. |
d195677
into
meshtastic:pioarduino-nimble
|
Great to hear it!! Thanks for the quick merge! |
|
Disclaimer: totally speculation. No evidence of the theory below. Maybe NimBLE host task is hitting stack overflow? I researched FreeRTOS stack control, for example https://www.freertos.org/Documentation/02-Kernel/02-Kernel-features/09-Memory-management/02-Stack-usage-and-stack-overflow-checking https://www.freertos.org/Documentation/02-Kernel/04-API-references/03-Task-utilities/04-uxTaskGetStackHighWaterMark This is like a personal note to try to explore this area if/when I pick up the investigation again. |
This is addressing the lengthy debugging of pioarduino NimBLE problems with re-connect to Android devices, worked on by @vidplace7 @mverch67 and myself on Discord from February 2026 to April 2026, and currently the main blocker to migrating to pioarduino (#10164, #9122).
The workarounds aren't pretty, but since I had something that works, I thought I would post it for discussion at least.
Tested with Google Pixel 8 Android 16, which previously failed to reconnect to the Meshtastic node (Heltec v3), and now successfully reconnects to the node.
I think it is worth considering that, even if the workarounds are ugly, it will unblock us from moving forward with the pioarduino / NimBLE migration (#10164) which is itself increasingly painful as folks have to maintain effectively a fork (constantly backporting and forward porting changes between develop and pioarduino and pioarduino-nimble).
🤝 Attestations