diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index ac50ffa..b1f7b0d 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -22,7 +22,7 @@ #include "Adafruit_MQTT.h" #if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || \ - defined(ARDUINO_ARCH_SAMD) + defined(ARDUINO_SAMD_MKR1010) || defined(ARDUINO_ARCH_SAMD) static char *dtostrf(double val, signed char width, unsigned char prec, char *sout) { char fmt[20]; diff --git a/Adafruit_MQTT_Client.h b/Adafruit_MQTT_Client.h index 5d23e03..6ede1d6 100644 --- a/Adafruit_MQTT_Client.h +++ b/Adafruit_MQTT_Client.h @@ -41,11 +41,14 @@ public: const char *user = "", const char *pass = "") : Adafruit_MQTT(server, port, user, pass), client(client) {} - bool connectServer(); - bool disconnectServer(); - bool connected(); - uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, int16_t timeout); - bool sendPacket(uint8_t *buffer, uint16_t len); + bool connected() override; + +protected: + bool connectServer() override; + bool disconnectServer() override; + uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, + int16_t timeout) override; + bool sendPacket(uint8_t *buffer, uint16_t len) override; private: Client *client; diff --git a/Adafruit_MQTT_FONA.h b/Adafruit_MQTT_FONA.h index 422aa03..52e25ba 100644 --- a/Adafruit_MQTT_FONA.h +++ b/Adafruit_MQTT_FONA.h @@ -42,7 +42,13 @@ public: const char *user = "", const char *pass = "") : Adafruit_MQTT(server, port, user, pass), fona(f) {} - bool connectServer() { + bool connected() { + // Return true if connected, false if not connected. + return fona->TCPconnected(); + } + +protected: + bool connectServer() override { char server[40]; strncpy(server, servername, 40); #ifdef ADAFRUIT_SLEEPYDOG_H @@ -54,14 +60,10 @@ public: return fona->TCPconnect(server, portnum); } - bool disconnectServer() { return fona->TCPclose(); } + bool disconnectServer() override { return fona->TCPclose(); } - bool connected() { - // Return true if connected, false if not connected. - return fona->TCPconnected(); - } - - uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, int16_t timeout) { + uint16_t readPacket(uint8_t *buffer, uint16_t maxlen, + int16_t timeout) override { uint8_t *buffp = buffer; DEBUG_PRINTLN(F("Reading data..")); @@ -114,7 +116,7 @@ public: return len; } - bool sendPacket(uint8_t *buffer, uint16_t len) { + bool sendPacket(uint8_t *buffer, uint16_t len) override { DEBUG_PRINTLN(F("Writing packet")); if (fona->TCPconnected()) { boolean ret = fona->TCPsend((char *)buffer, len); diff --git a/examples/mqtt_esp8266/mqtt_esp8266.ino b/examples/mqtt_esp8266/mqtt_esp8266.ino index a8c3b0e..2310166 100644 --- a/examples/mqtt_esp8266/mqtt_esp8266.ino +++ b/examples/mqtt_esp8266/mqtt_esp8266.ino @@ -35,7 +35,7 @@ // Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client; -// or... use WiFiFlientSecure for SSL +// or... use WiFiClientSecure for SSL //WiFiClientSecure client; // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.