Help with ESP8266 compilation warning

I am getting the following warning about a deprecated conversion.
Is it a problem or just a warning?

In file included from /Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP-master/src/CayenneMQTTWiFiClient.h:21:0,
from /Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP-master/src/CayenneMQTTESP8266.h:23,
from /Users/John/Documents/Arduino/Hydroponics/Cayenne-MQTT-ESP/ESP8266/ESP8266.ino:6:
/Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP-master/src/CayenneArduinoMQTTClient.h: In member function ‘void CayenneArduinoMQTTClient::connect()’:
/Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP-master/src/CayenneArduinoMQTTClient.h:58:63: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
if (!NetworkConnect(&_network, CAYENNE_DOMAIN, CAYENNE_PORT)) {

Can you post your code?

the code was posted in the secoond issue that I raised about not being able to connect from a slider device:

I am not sure that will help.
The compiler is clearly complaining about a deprecated conversion:
master/src/CayenneArduinoMQTTClient.h:58:63: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
and this complaint refers to an item in CayenneArduinoMQTTClient.h.
Not really my code but I think this is what it is referring to:
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
which reference:
char username = “93…”;
char password = “75…”;
char clientID = “ae…”;
and …
char ssid = “HA…”;
char wifiPassword = “HA…”;

So is it complaining about “&” vs “char*” ???

The code is fine. Which version of the Arduino IDE and the Cayenne library are you using? I compiled your code and did not receive any warnings.

Arduino V1.8.5
Cayenne V1.0.1

Arduino V1.8.5
Cayenne V1.0.2

Cayenne-MQTT-ESP V1.0.1
CayenneLPP V1.0.0

MacOS 10.13.3

see if you have followed all this steps Adding a New Device using MQTT

Isn’t the point that everything including the slider works for MacOS/(whatever browser you choose)?
And that the On/Off button, timer data and history data work on the Android systems.
I assume you have a topic per device/function, so I cannot see how MQTT could be the culprit.
I think you need to look at the host slider code as there are a lot of other issues with that as well. Including not working after you set the units!

The compile issue could be a Mac problem. I don’t have one to test, but I think @bestes has one, if not should be able to get someone to test.

I had the same problem and I updated the board definitions.
Set the download path in Arduino Preferences (Add new boards): http://arduino.esp8266.com/stable/package_esp8266com_index.json

Then go in Boards Manager and update the boards based on ESP8266.
Then should compile fine!

Regards, Adrian

Hi Adrian,

Thanks for that clue.

But I already had the board definitions correct.

The issue relates to this error message:

In file included from /Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTWiFiClient.h:21:0,

  •             from /Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneMQTTESP32.h:23,*
    
  •             from /Users/John/Documents/workspace/SmartNutrientPump/SmartNutrientPump.ino:13:*
    

/Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneArduinoMQTTClient.h: In member function ‘void CayenneArduinoMQTTClient::connect()’:

/Users/John/Documents/Arduino/libraries/Cayenne-MQTT-ESP/src/CayenneArduinoMQTTClient.h:58:63: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

  • if (!NetworkConnect(&_network, CAYENNE_DOMAIN, CAYENNE_PORT)) {*

I think it is caused by this definition in “CayenneUtils/CayenneDefines.h” :

#define CAYENNE_DOMAIN “mqtt.mydevices.com

#define CAYENNE_PORT 1883

As you can see CAYENNE_DOMAIN is a string constant whereas in MQTTArduino.h NetworkConnect requires a char*.

int NetworkConnect(Network* network, char* addr, int port);

As the warning says:

warning: ISO C++ forbids converting a string constant to ‘char*’

Seems pretty clear ???

I am not sure why Cayenne don’t want to fix or investigate this.

But the code works, and it is a warning not an error, and I am not confident enough to change it.

Best regards,

John