devWaves / SwitchBot-MQTT-BLE-ESP32

Allows for multiple SwitchBot bots and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Temperature, Motion, Contact sensors
MIT License
549 stars 68 forks source link

Error compiling #24

Closed arankwende closed 3 years ago

arankwende commented 3 years ago

Hi devwaves, I've been trying to implement your awesome project for the last couple of days and I seem to have hit a wall. You see, whenever I try to compile it on my Arduino IDE, I end up with the following message:

exit status 1

comparison with string literal results in unspecified behaviour [-Werror=address]

and the bolded line below marked in red: _} else { int value = docIn["sec"]; String secString = String(value); if (secString.c_str() != "") { bool isNum = is_number(secString.cstr()); if (isNum) {

I also get errors sucha as the following:

_C:\Users\cdiaz\Documents\GitHub\SwitchBot-MQTT-BLE-ESP32\SwitchBot-BLE2MQTT-ESP32\SwitchBot-BLE2MQTT-ESP32.ino: In function 'void rescanMQTT(std::__cxx11::string)':

SwitchBot-BLE2MQTT-ESP32:2432:30: error: comparison with string literal results in unspecified behaviour [-Werror=address]

 if (secString.c_str() != "") {_

I have checked that I have the libraries installed, and the ESP332 board, and don't know what other options could be causing this, I have tried compiling with my settings but also I tried compiling the example ino without any setting filled, and I get the same error.

I am attaching the full log .

Thanks for any help

arduino error log.txt

devWaves commented 3 years ago

Have you been able to compile and upload any other example esp32 project? you can google to find examples or this one https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/

without changing the code, it should at least compile and upload. so it sounds like an arduino ide setup issue, not easy to tell based on error from what I can see

You are using a d1 mini esp32 correct?

if you are not using a fresh install of arduino IDE it can result in conflicting libraries sometimes. You can try uninstalling reinstalling, but I assume this is your first arduino project?

arankwende commented 3 years ago

It's not my first project, I'll try uninstalling and reinstalling the IDE to rule out libraries.
As for other ESP32 projects, I just tried the example from the link you suggested, compiled without problem. Thanks

arankwende commented 3 years ago

So, just wanted to close this. First and foremost: thank you for having taken the time to answer!! I think it had something to do with other libraries I had installed but after uninstalling the ide and reinstalling everything from scratch, it worked.