Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues with Arduino IDE compilation #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TriDEntApollO
Copy link

Fixes issue #312

In Arduino IDE the ESP32 core library has a BleDevice.h library that the code includes and uses. The BleDevice.h file has a function definition that uses the String class

static void init(String deviceName);

but the code used std::string variables instead and passed that directly to the init() without typecasting, which raised an error during compilation, this commit fixes that issue.

This commits changes the code base to use the String class instead of std::string for better over all compatibility with Arduino.

In Arduino IDE the ESP32 core library has BleDevice.h library that is uses String but the code used std::string instead which raised an error during compilation, this commit fixes that issue
@TriDEntApollO
Copy link
Author

Exact error message by Arduino IDE during compilation:


"c:\\Users\\tride\\OneDrive\\Documents\\Arduino\\libraries\\ESP32_BLE_Keyboard\\BleKeyboard.cpp" -o "C:\\Users\\tride\\AppData\\Local\\Temp\\arduino\\sketches\\2F6DC235B9777E6112A59FD9BDC5F2AD\\libraries\\ESP32_BLE_Keyboard\\BleKeyboard.cpp.o"
c:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp: In member function 'void BleKeyboard::begin()':
c:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp:106:19: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'String'
  106 |   BLEDevice::init(deviceName);
      |                   ^~~~~~~~~~
      |                   |
      |                   std::string {aka std::__cxx11::basic_string<char>}
In file included from c:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp:9:
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp:117:32: error: no matching function for call to 'BLECharacteristic::setValue(std::string&)'
  117 |   hid->manufacturer()->setValue(deviceManufacturer);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLEHIDDevice.h:17,
                 from c:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.h:24,
                 from c:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp:1:
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:83:8: note: candidate: 'void BLECharacteristic::setValue(double&)'
   83 |   void setValue(double &data64);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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);
      |                 ~~~~~~~~^~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:82:8: note: candidate: 'void BLECharacteristic::setValue(float&)'
   82 |   void setValue(float &data32);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:81:8: note: candidate: 'void BLECharacteristic::setValue(int&)'
   81 |   void setValue(int &data32);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:80:8: note: candidate: 'void BLECharacteristic::setValue(uint32_t&)'
   80 |   void setValue(uint32_t &data32);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:79:8: note: candidate: 'void BLECharacteristic::setValue(uint16_t&)'
   79 |   void setValue(uint16_t &data16);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:77:8: note:   candidate expects 2 arguments, 1 provided
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE\src/BLECharacteristic.h:78:8: note: candidate: 'void BLECharacteristic::setValue(String)'
   78 |   void setValue(String value);
      |        ^~~~~~~~
C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.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);
      |                 ~~~~~~~^~~~~

Using library Wire at version 3.1.0 in folder: C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\Wire 
Using library ESP32 BLE Keyboard at version 0.3.2 in folder: C:\Users\tride\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard 
Using library BLE at version 3.1.0 in folder: C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\BLE 
Using library Adafruit GFX Library at version 1.11.11 in folder: C:\Users\tride\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit BusIO at version 1.16.2 in folder: C:\Users\tride\OneDrive\Documents\Arduino\libraries\Adafruit_BusIO 
Using library SPI at version 3.1.0 in folder: C:\Users\tride\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\SPI 
Using library Adafruit SH110X at version 2.1.11 in folder: C:\Users\tride\OneDrive\Documents\Arduino\libraries\Adafruit_SH110X 
exit status 1

Compilation error: exit status 1

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.

1 participant