Skip to content

Fix std::string to const char* compilation error on arduino-esp32 v3.x - #86

Open
Tejakshaya wants to merge 1 commit into
T-vK:masterfrom
Tejakshaya:fix/c_str-compilation-error
Open

Tejakshaya wants to merge 1 commit into
T-vK:masterfrom
Tejakshaya:fix/c_str-compilation-error

Conversation

@Tejakshaya

Copy link
Copy Markdown

This fixes the compilation failure on arduino-esp32 v3.x (ESP32 Arduino Core 3.0+) where BLEDevice::init() and BLECharacteristic::setValue() now expect const char* instead of std::string.

Changes:

  • Added .c_str() to BLEDevice::init() call at line 143
  • Added .c_str() to hid->manufacturer()->setValue() call at line 151

Why
Starting with arduino-esp32 v3.0, the BLE API changed its function signatures from accepting std::string to const char* and this causes the library to fail to compile with errors like:
error: cannot convert 'std::string' to 'const char*'
The fix is backward-compatible — .c_str() works on all versions.

Closes #73
Closes #84

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.

error: cannot convert 'std::string' to 'String' needed to add the .c_str() in the BleMouse.cpp

1 participant