1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-06-11 22:48:09 +03:00

Add Adfruit_MQTT::connectErrorString() method

This easily allows printing error messages without having to hard-code
return values in the sketch and makes the example sketches a bit more
concise.
This commit is contained in:
Matthijs Kooijman
2015-07-02 13:01:05 +02:00
parent 73f5be4e5c
commit 6879df86f6
5 changed files with 25 additions and 34 deletions

View File

@ -140,6 +140,19 @@ int8_t Adafruit_MQTT::connect() {
return 0;
}
const __FlashStringHelper* Adafruit_MQTT::connectErrorString(int8_t code) {
switch (code) {
case 1: return F("Wrong protocol");
case 2: return F("ID rejected");
case 3: return F("Server unavail");
case 4: return F("Bad user/pass");
case 5: return F("Not authed");
case 6: return F("Failed to subscribe");
case -1: return F("Connection failed");
default: return F("Unknown error");
}
}
bool Adafruit_MQTT::publish(const char *topic, const char *data, uint8_t qos) {
// Construct and send publish packet.
uint8_t len = publishPacket(buffer, topic, data, qos);