Fix Compatibility with std::string in ESP32_BLE_Mouse Library #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.