Skip to content

Fix compilation and runtime crashes on ESP32 core 3.x#389

Open
kevinagomez wants to merge 1 commit into
T-vK:masterfrom
kevinagomez:fix/esp32-core3x-compatibility
Open

Fix compilation and runtime crashes on ESP32 core 3.x#389
kevinagomez wants to merge 1 commit into
T-vK:masterfrom
kevinagomez:fix/esp32-core3x-compatibility

Conversation

@kevinagomez

Copy link
Copy Markdown

Problem

ESP32-BLE-Keyboard fails to compile and crashes at runtime on
ESP32 Arduino core 3.x (tested on XIAO ESP32-C6 with Seeed core 3.3.7).

Symptoms

  • Compilation error: cannot convert std::string to String
  • Runtime: Guru Meditation Load access fault (MCAUSE 0x05, MTVAL 0x0000002c)

Root Causes Fixed

  1. std::string → Arduino String throughout constructor, members, signatures
  2. substr() → substring() for Arduino String API
  3. BLEDevice::init() and setValue() — pass String directly
  4. onConnect/onDisconnect — null-check BLE2902 descriptors before use
    (core 3.x returns nullptr from getDescriptorByUUID — this was the
    primary crash cause)
  5. onWrite() — fix dangling pointer from temporary String destruction

Tested On

  • Hardware: Seeed XIAO ESP32-C6
  • Core: Seeed esp32 3.3.7
  • Sketch: BLE HID keyboard sending keystrokes successfully

- Replace std::string with Arduino String throughout
- Fix dangling pointer in onWrite()
- Add null checks for BLE2902 descriptors (primary crash cause on core 3.x)
- Tested on XIAO ESP32-C6 with Seeed core 3.3.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant