I'm using an ESP32 DEV Module and the Arduino IDE.
I'm trying to get the SendKeyStrokes.ino example code from the ESP32_BLE_Keyboard library to compile.
I receive many errors, the first of which is:
c:\Users\richa\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp: In member function 'void BleKeyboard::begin()':
c:\Users\richa\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Keyboard\BleKeyboard.cpp:105:19: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'String'
105 | BLEDevice::init(deviceName);
"Cannot convert std::string to string"
I have found a note " In order to get a C-style string from an std::string, use the c_str() member function." but I don't know how to apply it in this situation.
Any help gratefully accepted.
If your board level is current i.e. >3 then this may be a ver error. Drop back to the last 2.x ver and see what happens. As far as c_string, off the top of my head it's myString.c_string
The Arduino.cc web site has the language reference docs, here is the relevant page for your c_string query. c_string
Here is info re Ver 3 changes. Ver 3
Thanks for pointing that out. I am using the latest version and see that there is an issue with std:string.
Ruis at Random Nerd Tutorials has a migration guide and has replaced std:string with String.
I will try that and see how I get on.
Thanks for your response.
Tried to replace std::string with String but that caused more errors.
Tried reverting to ESP32 version 2.0.17 but again that caused issues.
I guess I'm back to solving the original issue with c_str().
Um, what do you mean? All you do is add '.c_str()' to the offending variable on line 105. Do you not know that the language reference manual is online at arduino.cc? Attached is a screen grab to show you what I meant above.