BLE Combo failing to compile

Hey!

For the past few weeks I have been making a BLE Mouse glove using an ESP32, flex sensors and an MPU6050. The project is based off this library (GitHub - Georgegipa/ESP32-BLE-Combo: Bluetooth LE Keyboard & Mouse compatible with Arduino Keyboard and Mouse) and has been working well. However, this week I have started getting these errors when compiling (below). I havent made any changes to the library and I am not sure why this has started happening. Any help would be really appreciated.

Errors:

/Users/dionysus/Documents/Arduino/libraries/ESP32_BLE_Abs_Mouse/BleAbsMouse.cpp: In static member function 'static void BleAbsMouse::taskServer(void*)':
/Users/dionysus/Documents/Arduino/libraries/ESP32_BLE_Abs_Mouse/BleAbsMouse.cpp:141:37: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'String'
  141 |   BLEDevice::init(bleMouseInstance->deviceName);
      |                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                     |
      |                                     std::string {aka std::__cxx11::basic_string<char>}
In file included from /Users/dionysus/Documents/Arduino/libraries/ESP32_BLE_Abs_Mouse/BleAbsMouse.cpp:1:
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLEDevice.h:41:27: note:   initializing argument 1 of 'static void BLEDevice::init(String)'
   41 |   static void init(String deviceName);                                                            // Initialize the local BLE environment.
      |                    ~~~~~~~^~~~~~~~~~
/Users/dionysus/Documents/Arduino/libraries/ESP32_BLE_Abs_Mouse/BleAbsMouse.cpp:149:50: error: no matching function for call to 'BLECharacteristic::setValue(std::string&)'
  149 |   bleMouseInstance->hid->manufacturer()->setValue(bleMouseInstance->deviceManufacturer);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLEServer.h:23,
                 from /Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLEDevice.h:21:
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:77:8: note: candidate: 'void BLECharacteristic::setValue(uint8_t*, size_t)'
   77 |   void setValue(uint8_t *data, size_t size);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:77:8: note:   candidate expects 2 arguments, 1 provided
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:78:8: note: candidate: 'void BLECharacteristic::setValue(String)'
   78 |   void setValue(String value);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:78:24: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'String'
   78 |   void setValue(String value);
      |                 ~~~~~~~^~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:79:8: note: candidate: 'void BLECharacteristic::setValue(uint16_t&)'
   79 |   void setValue(uint16_t &data16);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:79:27: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'uint16_t&' {aka 'short unsigned int&'}
   79 |   void setValue(uint16_t &data16);
      |                 ~~~~~~~~~~^~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:80:8: note: candidate: 'void BLECharacteristic::setValue(uint32_t&)'
   80 |   void setValue(uint32_t &data32);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:80:27: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'uint32_t&' {aka 'long unsigned int&'}
   80 |   void setValue(uint32_t &data32);
      |                 ~~~~~~~~~~^~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:81:8: note: candidate: 'void BLECharacteristic::setValue(int&)'
   81 |   void setValue(int &data32);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:81:22: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int&'
   81 |   void setValue(int &data32);
      |                 ~~~~~^~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:82:8: note: candidate: 'void BLECharacteristic::setValue(float&)'
   82 |   void setValue(float &data32);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:82:24: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'float&'
   82 |   void setValue(float &data32);
      |                 ~~~~~~~^~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:83:8: note: candidate: 'void BLECharacteristic::setValue(double&)'
   83 |   void setValue(double &data64);
      |        ^~~~~~~~
/Users/dionysus/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/BLE/src/BLECharacteristic.h:83:25: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'double&'
   83 |   void setValue(double &data64);
      |                 ~~~~~~~~^~~~~~

exit status 1

Compilation error: exit status 1

Hi @timgoode5555.

Explanation

There are significant breaking changes in the recently released version 3.0.0 of the "esp32" boards platform.

Some of these breaking changes caused a loss of compatibility with the "ESP32 BLE Abs Mouse" library you are using in your sketch:

https://github.com/espressif/arduino-esp32/blob/master/docs/en/migration_guides/2.x_to_3.0.rst#ble

BLE

Changes in APIs

  • Changed APIs return and parameter type from std::string to Arduino style String.

Resolution

The easiest solution will be to use a version of the "esp32" boards platform that is compatible with the "ESP32 BLE Abs Mouse" library.

The breaking changes in the "esp32" boards platform were introduced in the 3.0.0 release, so you won't have these problems compiling the library if you install an older version of the "esp32" platform.

  1. Select Tools > Board > Boards Manager... from the Arduino IDE menus.
    The "Boards Manager" dialog will open.
  2. Wait for the updates to finish, as shown by the messages printed at the bottom of the "Boards Manager" dialog.
  3. Scroll down through the list of boards platforms until you find the "esp32" entry. Click on it.
    A "Select version" dropdown will appear in the entry.
  4. Click on the "Select version" dropdown.
    It will expand.
  5. Select "2.0.17" from the menu.
  6. Click the "Install" button in the "esp32" entry.
  7. Wait for the installation to finish.
  8. Click the "Close" button on the "Boards Manager" dialog.
    The "Boards Manager" dialog will close.

Now compile your sketch again. Hopefully this time the error will not occur and the library will work as expected.


Arduino IDE will occasionally notify you that a new version of the boards platform is available, you'll need to refrain from accepting the offer that will cause an update back to the problematic version of the platform. If you find these notifications annoying, you can disable them via the IDE preferences.

I'll provide instructions you can follow to do that:

  1. Select File > Preferences... (or Arduino > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to "Check for updates on startup" in the "Preferences" dialog.
  3. Click the "OK" button.
    The "Preferences" dialog will close.

If you disable the automatic update check, make sure to periodically do a manual check for newer versions of the installed boards platforms and libraries that you want to keep updated. You can check for new versions of Arduino IDE by selecting Help > Check for Arduino IDE Updates from the Arduino IDE menus. You can check for new versions of boards platforms and libraries by selecting "Updatable" from the "Type" menu in the Boards Manager and Library Manager views.

I guess you saw the notification in Arduino IDE offering the available update of the "esp32" boards platform, accepted the update, and then didn't associate that action with the errors that occurred the next time you compiled your project.

Thats awesome! Thank you

You are welcome. I'm glad if I was able to be of assistance.

You nailed it! All working now :slight_smile:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.