Skip to content

[pioarduino] Workaround BLE stability issues on reconnect to certain Android phones#10220

Merged
vidplace7 merged 2 commits intomeshtastic:pioarduino-nimblefrom
cpatulea:pioarduino-nimble-micfail
Apr 21, 2026
Merged

[pioarduino] Workaround BLE stability issues on reconnect to certain Android phones#10220
vidplace7 merged 2 commits intomeshtastic:pioarduino-nimblefrom
cpatulea:pioarduino-nimble-micfail

Conversation

@cpatulea
Copy link
Copy Markdown
Contributor

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

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)

…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.
@github-actions github-actions Bot added needs-review Needs human review bugfix Pull request that fixes bugs labels Apr 21, 2026
@vidplace7 vidplace7 requested review from mverch67 and vidplace7 April 21, 2026 11:50
@thebentern thebentern requested a review from Copilot April 21, 2026 12:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/nimble/NimbleBluetooth.cpp
Copy link
Copy Markdown
Member

@vidplace7 vidplace7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works here on Pixel 8 + Heltec v3 🚀
Thanks a million @cpatulea we're unblocked!

@vidplace7 vidplace7 merged commit d195677 into meshtastic:pioarduino-nimble Apr 21, 2026
8 of 10 checks passed
@cpatulea
Copy link
Copy Markdown
Contributor Author

Great to hear it!! Thanks for the quick merge!

@cpatulea
Copy link
Copy Markdown
Contributor Author

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.

@cpatulea cpatulea deleted the pioarduino-nimble-micfail branch April 22, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants