Adafruit MQTT with Photon compiler error

Is anyone using the Adafruit-mqtt-spark library on their Particle Photon? I’ve been using this for a few months, but about a week ago, I tried making changes to my code and got a compiler error. When I went back to the original example code and tried to compile it, it failed as well. It appears to be related to some of the #include files, but I don’t know why it would have changed. Unfortunately, I don’t seem to be getting any support from the Adafruit forums about this, so I’m hoping someone here may be able to provide some help. A portion of the error code is shown below.

    In file included from lib/Adafruit_MQTT/src/Adafruit_MQTT_SPARK.h:28:0,
                     from /src/adafruit-mqtt-spark-test.cpp:1:
    lib/Adafruit_MQTT/src/Adafruit_MQTT.h:36:0: warning: "strncpy_P" redefined [enabled by default]
     #define strncpy_P(dest, src, len) strncpy((dest), (src), (len))
     ^
    In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                     from ./inc/application.h:92,
                     from /src/adafruit-mqtt-spark-test.cpp:1:
    ../wiring/inc/avr/pgmspace.h:70:0: note: this is the location of the previous definition
     #define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
     ^
    In file included from lib/Adafruit_MQTT/src/Adafruit_MQTT_SPARK.h:28:0,
                     from /src/adafruit-mqtt-spark-test.cpp:1:
    lib/Adafruit_MQTT/src/Adafruit_MQTT.h:37:0: warning: "strncasecmp_P" redefined [enabled by default]
     #define strncasecmp_P(f1, f2, len) strncasecmp((f1), (f2), (len))
     ^
    In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                     from ./inc/application.h:92,
                     from /src/adafruit-mqtt-spark-test.cpp:1:

In that part of the error log is no breaking error to be seen.
Please post the full log and for the time being try to target 0.6.0 instead of 0.6.1.
There are some issues with the new Arduino compatibility settings that are currently discussed and will be addressed shortly.

In file included from Adafruit_MQTT/Adafruit_MQTT_SPARK.h:28:0,
                 from chadmqtt_test.cpp:1:
Adafruit_MQTT/Adafruit_MQTT.h:36:0: warning: "strncpy_P" redefined [enabled by default]
 #define strncpy_P(dest, src, len) strncpy((dest), (src), (len))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                 from ./inc/application.h:92,
                 from chadmqtt_test.cpp:1:
../wiring/inc/avr/pgmspace.h:70:0: note: this is the location of the previous definition
 #define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
 ^
In file included from Adafruit_MQTT/Adafruit_MQTT_SPARK.h:28:0,
                 from chadmqtt_test.cpp:1:
Adafruit_MQTT/Adafruit_MQTT.h:37:0: warning: "strncasecmp_P" redefined [enabled by default]
 #define strncasecmp_P(f1, f2, len) strncasecmp((f1), (f2), (len))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                 from ./inc/application.h:92,
                 from chadmqtt_test.cpp:1:
../wiring/inc/avr/pgmspace.h:68:0: note: this is the location of the previous definition
 #define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
 ^
In file included from Adafruit_MQTT/Adafruit_MQTT.cpp:22:0:
Adafruit_MQTT/Adafruit_MQTT.h:36:0: warning: "strncpy_P" redefined [enabled by default]
 #define strncpy_P(dest, src, len) strncpy((dest), (src), (len))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                 from ./inc/application.h:92,
                 from Adafruit_MQTT/Adafruit_MQTT.h:26,
                 from Adafruit_MQTT/Adafruit_MQTT.cpp:22:
../wiring/inc/avr/pgmspace.h:70:0: note: this is the location of the previous definition
 #define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n))
 ^
In file included from Adafruit_MQTT/Adafruit_MQTT.cpp:22:0:
Adafruit_MQTT/Adafruit_MQTT.h:37:0: warning: "strncasecmp_P" redefined [enabled by default]
 #define strncasecmp_P(f1, f2, len) strncasecmp((f1), (f2), (len))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                 from ./inc/application.h:92,
                 from Adafruit_MQTT/Adafruit_MQTT.h:26,
                 from Adafruit_MQTT/Adafruit_MQTT.cpp:22:
../wiring/inc/avr/pgmspace.h:68:0: note: this is the location of the previous definition
 #define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n))
 ^
In file included from ./inc/application.h:92:0,
                 from Adafruit_MQTT/Adafruit_MQTT.h:26,
                 from Adafruit_MQTT/Adafruit_MQTT.cpp:22:
Adafruit_MQTT/Adafruit_MQTT.cpp: In member function 'const char* Adafruit_MQTT::connectErrorString(int8_t)':

../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
           
'''                                                   ^


Adafruit_MQTT/Adafruit_MQTT.cpp:272:22: note: in expansion of macro 'F'
       case 1: return F("The Server does not support the level of the MQTT protocol requested");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:273:22: note: in expansion of macro 'F'
       case 2: return F("The Client identifier is correct UTF-8 but not allowed by the Server");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:274:22: note: in expansion of macro 'F'
       case 3: return F("The MQTT service is unavailable");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:275:22: note: in expansion of macro 'F'
       case 4: return F("The data in the user name or password is malformed");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:276:22: note: in expansion of macro 'F'
       case 5: return F("Not authorized to connect");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:277:22: note: in expansion of macro 'F'
       case 6: return F("Exceeded reconnect rate limit. Please try again later.");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:278:22: note: in expansion of macro 'F'
       case 7: return F("You have been banned from connecting. Please contact the MQTT server administrator for more details.");
                      ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:279:23: note: in expansion of macro 'F'
       case -1: return F("Connection failed");
                       ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:280:23: note: in expansion of macro 'F'
       case -2: return F("Failed to subscribe");
                       ^
../wiring/inc/spark_wiring_arduino.h:40:62: error: cannot convert 'const __FlashStringHelper*' to 'const char*' in return
 #define F(X) (reinterpret_cast<const __FlashStringHelper*>(X))
                                                              ^
Adafruit_MQTT/Adafruit_MQTT.cpp:282:12: note: in expansion of macro 'F'
     return F("Unknown error");
            ^
Adafruit_MQTT/Adafruit_MQTT.cpp:283:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[1]: *** [../build/target/user/platform-6Adafruit_MQTT/Adafruit_MQTT.o] Error 1
make: *** [user] Error 2

Error: Could not compile. Please review your code.

This is ann issue recently introduced with the ARDUINO compatibility features of 0.6.1. Particle is aware of that and plans to implement a fix soon.
For the time being the easiest fix is to target 0.6.0 (system firmware can stay at 0.6.1).

I changed to 0.6.0 and tried compiling again. Success!! Thanks for your prompt response, much appreciated.

1 Like