Compilation error for BLE Mouse Library

Hello everyone,

I am trying to compile the BLE Mouse code from the below repo-
BLE MOuse repo

The basic code example is -

/**
 * This example turns the ESP32 into a Bluetooth LE mouse that scrolls down every 2 seconds.
 */
#include <BleMouse.h>

BleMouse bleMouse;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleMouse.begin();
}

void loop() {
  if(bleMouse.isConnected()) {
    Serial.println("Scroll Down");
    bleMouse.move(0,0,-1);
  }
  delay(2000);
}

The selected board is
XIAO_ESP32C3

I am getting a compilation error-

C:\Users\usr\OneDrive\Documents\Arduino\libraries\ESP32-BLE-Mouse\BleMouse.cpp: In static member function 'static void BleMouse::taskServer(void*)':
C:\Users\usr\OneDrive\Documents\Arduino\libraries\ESP32-BLE-Mouse\BleMouse.cpp:143:37: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'String'
  143 |   BLEDevice::init(bleMouseInstance->deviceName);
      |                   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                     |
      |                                     std::string {aka std::__cxx11::basic_string<char>}
In file included from C:\Users\usr\OneDrive\Documents\Arduino\libraries\ESP32-BLE-Mouse\BleMouse.cpp:1:
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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.
      |                    ~~~~~~~^~~~~~~~~~
C:\Users\usr\OneDrive\Documents\Arduino\libraries\ESP32-BLE-Mouse\BleMouse.cpp:151:50: error: no matching function for call to 'BLECharacteristic::setValue(std::string&)'
  151 |   bleMouseInstance->hid->manufacturer()->setValue(bleMouseInstance->deviceManufacturer);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLEServer.h:23,
                 from C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLEDevice.h:21:
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:77:8: note:   candidate expects 2 arguments, 1 provided
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:78:8: note: candidate: 'void BLECharacteristic::setValue(String)'
   78 |   void setValue(String value);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~~~^~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:79:8: note: candidate: 'void BLECharacteristic::setValue(uint16_t&)'
   79 |   void setValue(uint16_t &data16);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~~~~~~^~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:80:8: note: candidate: 'void BLECharacteristic::setValue(uint32_t&)'
   80 |   void setValue(uint32_t &data32);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~~~~~~^~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:81:8: note: candidate: 'void BLECharacteristic::setValue(int&)'
   81 |   void setValue(int &data32);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~^~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:82:8: note: candidate: 'void BLECharacteristic::setValue(float&)'
   82 |   void setValue(float &data32);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~~~^~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE\src/BLECharacteristic.h:83:8: note: candidate: 'void BLECharacteristic::setValue(double&)'
   83 |   void setValue(double &data64);
      |        ^~~~~~~~
C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\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);
      |                 ~~~~~~~~^~~~~~
Using library ESP32-BLE-Mouse at version 0.3.1 in folder: C:\Users\usr\OneDrive\Documents\Arduino\libraries\ESP32-BLE-Mouse 
Using library BLE at version 2.0.0 in folder: C:\Users\usr\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\3.0.0\libraries\BLE 
exit status 1
Error compiling for board XIAO_ESP32C3.

I’d appreciate your help resolving this.
Thanks in advance.

Hi there,
Works Great, Actually better than the ** :wink:** Newer Stuff
Serial output once you connect to it, I used Nrf_connect for Desktop and the $9 dollar dongle. :+1:

Starting BLE work!
Scroll Down
Scroll Down
Scroll Down
Scroll Down
Scroll Down

compiler output :stuck_out_tongue_winking_eye: :+1:

FQBN: esp32:esp32:XIAO_ESP32C3
Using board 'XIAO_ESP32C3' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11
Using core 'esp32' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11
---Edit for brevity...
Successfully created esp32c3 image.
"C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.11/tools/gen_esp32part.exe" -q "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\64AC377E73975BFA08F3D4FAD80B2A90/partitions.csv" "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\64AC377E73975BFA08F3D4FAD80B2A90/sketch_may29a.ino.partitions.bin"
cmd /c if exist "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\64AC377E73975BFA08F3D4FAD80B2A90\\libraries\\Insights" "C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.11/tools/gen_insights_package.exe" "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\64AC377E73975BFA08F3D4FAD80B2A90" sketch_may29a.ino "C:\\Users\\Dude\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2024429-16796-1rvnykm.l9lj\\sketch_may29a"
cmd /c IF 0==1 COPY /y "C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\openocd-esp32\\v0.11.0-esp32-20221026\\share\\openocd\\scripts\\board\\esp32c3-builtin.cfg" "C:\\Users\\Dude\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2024429-16796-1rvnykm.l9lj\\sketch_may29a\\debug.cfg"
cmd /c IF 0==1 COPY /y "C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.11\\tools\\ide-debug\\esp32c3.json" "C:\\Users\\Dude\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2024429-16796-1rvnykm.l9lj\\sketch_may29a\\debug_custom.json"
cmd /c IF 0==1 COPY /y "C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.11\\tools\\ide-debug\\svd\\esp32c3.svd" "C:\\Users\\Dude\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2024429-16796-1rvnykm.l9lj\\sketch_may29a\\debug.svd"

Using library ESP32 BLE Mouse at version 0.3.1 in folder: D:\Arduino_projects\libraries\ESP32_BLE_Mouse 
Using library ESP32 BLE Arduino at version 2.0.0 in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\BLE 
"C:\\Users\\Dude\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\riscv32-esp-elf-gcc\\esp-2021r2-patch5-8.4.0/bin/riscv32-esp-elf-size" -A "C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\64AC377E73975BFA08F3D4FAD80B2A90/sketch_may29a.ino.elf"
Sketch uses 938478 bytes (71%) of program storage space. Maximum is 1310720 bytes.
Global variables use 36900 bytes (11%) of dynamic memory, leaving 290780 bytes for local variables. Maximum is 327680 bytes.
"C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe" --chip esp32c3 --port "COM5" --baud 921600  --before default_reset --after hard_reset write_flash  -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 "C:\Users\Dude\AppData\Local\Temp\arduino\sketches\64AC377E73975BFA08F3D4FAD80B2A90/sketch_may29a.ino.bootloader.bin" 0x8000 "C:\Users\Dude\AppData\Local\Temp\arduino\sketches\64AC377E73975BFA08F3D4FAD80B2A90/sketch_may29a.ino.partitions.bin" 0xe000 "C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\Dude\AppData\Local\Temp\arduino\sketches\64AC377E73975BFA08F3D4FAD80B2A90/sketch_may29a.ino.bin" 
esptool.py v4.5.1
Serial port COM5
Connecting...
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: a0:76:4e:40:08:ec
Uploading stub...
Running stub...

If you can’t figure it out , :cricket: I’ll tell (point it out) you but let’s see what you do Next… :stuck_out_tongue_winking_eye:
:man_teacher: :fishing_pole_and_fish:
I’m from Teach_man_to_fish…

HTH
GL :slight_smile: PJ
:v:

The answer you seek is in the second line of the compiler output screen, You see I built it with the original BSP, You should too. Ver 2.0.11

HTH
GL :slight_smile: PJ :v:

1 Like

Thank you.
It worked like a charm :slight_smile:

1 Like

Hi there,
Great!! God job. It does work better than a lot of the current examples(good find) for sure.
Can you mark it as the solution so others can find the answer too!
GL :slight_smile: PJ
:v:

1 Like

This is basic but I can’t find the button to mark it as a solution :upside_down_face:.

P.S. I am new to this forum.

hi there,
Yea, go to the post that was the answer at the bottom should be a solution with a check mark in it.
Highlight it and click it should mark that post as the solution.
HTH
GL :slight_smile: PJ
:v: