ESP32-BLE-Mouse icon indicating copy to clipboard operation
ESP32-BLE-Mouse copied to clipboard

Fix Compatibility with std::string in ESP32_BLE_Mouse Library

Open robosphere99 opened this issue 1 year ago • 2 comments

This pull request resolves compatibility issues in the ESP32_BLE_Mouse library, ensuring smoother integration and functionality with Arduino functions that require the String type. The following fixes were implemented:

Key Changes: BLEDevice::init():

Fixed a type mismatch by converting std::string to String using .c_str(). Updated line 143 in BleMouse.cpp: cpp Copy code BLEDevice::init(String(bleMouseInstance->deviceName.c_str())); BLECharacteristic::setValue():

Resolved a similar issue by converting std::string to String. Updated line 151 in BleMouse.cpp:

bleMouseInstance->hid->manufacturer()->setValue(String(bleMouseInstance->deviceManufacturer.c_str()));

Reason for Changes:

The library was originally passing std::string (C++ Standard Library) to functions that require String (Arduino-specific type). This caused compilation errors on Arduino platforms. These changes ensure type compatibility and make the library fully functional without modifying the user's project code.

Testing:

Verified the fixes on an ESP32-based project. Ensured smooth initialization of BLE and successful updates to the characteristic values. Tested with multiple BLE devices and ensured backward compatibility.

Impact:

Fixes critical compilation issues caused by type mismatches. Ensures seamless use of the library on the latest ESP32 Arduino Core. No breaking changes introduced.

Recommendation to Maintainers:

Consider adding explicit support for std::string in future versions for broader compatibility.

robosphere99 avatar Dec 11 '24 13:12 robosphere99

I made changes to the ESP32_BLE_Mouse library to fix compatibility issues with std::string and Arduino's String type. After resolving the type mismatches in BleMouse.cpp, the project is now working perfectly. The BLE mouse functionality is smooth, and all features are performing as expected without any errors. 😊

robosphere99 avatar Dec 11 '24 13:12 robosphere99

This fairly trivial PR is required to build the code with recent releases of Arduino IDE. Please consider merging it.

mtrojnar avatar Jun 26 '25 16:06 mtrojnar