Skip to content

Commit dd72b39

Browse files
committed
fix return type for esp bsp 2.0.8
1 parent 6f82f66 commit dd72b39

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

Adafruit_MQTT.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,47 @@ uint16_t Adafruit_MQTT::readFullPacket(uint8_t *buffer, uint16_t maxsize,
327327
return ((pbuff - buffer) + rlen);
328328
}
329329

330+
#ifdef ARDUINO_ARCH_ESP32
331+
const char *Adafruit_MQTT::connectErrorString(int8_t code) {
332+
const char *statusMsg;
333+
switch (code) {
334+
case 1:
335+
statusMsg =
336+
"The Server does not support the level of the MQTT protocol requested";
337+
break;
338+
case 2:
339+
statusMsg =
340+
"The Client identifier is correct UTF-8 but not allowed by the Server";
341+
break;
342+
case 3:
343+
statusMsg = "The MQTT service is unavailable";
344+
break;
345+
case 4:
346+
statusMsg = "The data in the user name or password is malformed";
347+
break;
348+
case 5:
349+
statusMsg = "Not authorized to connect";
350+
break;
351+
case 6:
352+
statusMsg = "Exceeded reconnect rate limit. Please try again later.";
353+
break;
354+
case 7:
355+
statusMsg = "You have been banned from connecting. Please contact the MQTT "
356+
"server administrator for more details.";
357+
break;
358+
case -1:
359+
statusMsg = "Connection failed";
360+
break;
361+
case -2:
362+
statusMsg = "Failed to subscribe";
363+
break;
364+
default:
365+
statusMsg = "Unknown error";
366+
break;
367+
}
368+
return statusMsg;
369+
}
370+
#else
330371
const __FlashStringHelper *Adafruit_MQTT::connectErrorString(int8_t code) {
331372
switch (code) {
332373
case 1:
@@ -354,6 +395,7 @@ const __FlashStringHelper *Adafruit_MQTT::connectErrorString(int8_t code) {
354395
return F("Unknown error");
355396
}
356397
}
398+
#endif
357399

358400
bool Adafruit_MQTT::disconnect() {
359401

Adafruit_MQTT.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,19 @@ class Adafruit_MQTT {
166166
int8_t connect();
167167
int8_t connect(const char *user, const char *pass);
168168

169-
// Return a printable string version of the error code returned by
169+
#ifdef ARDUINO_ARCH_ESP32
170+
// Returns a printable string version of the error code returned by
171+
// connect(). Preprocessor due to breaking change within
172+
// Arduino ESP32 BSP v2.0.8
173+
// see: https://github.com/espressif/arduino-esp32/pull/7941
174+
const char *connectErrorString(int8_t code);
175+
#else
176+
// Returns a printable string version of the error code returned by
170177
// connect(). This returns a __FlashStringHelper*, which points to a
171178
// string stored in flash, but can be directly passed to e.g.
172179
// Serial.println without any further processing.
173180
const __FlashStringHelper *connectErrorString(int8_t code);
181+
#endif;
174182

175183
// Sends MQTT disconnect packet and calls disconnectServer()
176184
bool disconnect();

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit MQTT Library
2-
version=2.5.2
2+
version=2.5.3
33
author=Adafruit
44
maintainer=Adafruit <info@adafruit.com>
55
sentence=MQTT library that supports the FONA, ESP8266, ESP32, Yun, and generic Arduino Client hardware.

0 commit comments

Comments
 (0)