diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 0b0318c..ad147f9 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -188,18 +188,6 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) { DEBUG_PRINT(F("Found sub #")); DEBUG_PRINTLN(i); break; } - // bool flag = true; - // // TODO: REPLACE WITH MEMCMP? - // for (uint8_t k=0; ktopic+k) ) - // flag = false; - // } - // bool flag = strcmp_P() - // if (flag) { - // DEBUG_PRINTLN_VERBOSE((char *)buffer+4); - // DEBUG_PRINT_VERBOSE(F("Found sub #")); DEBUG_PRINTLN_VERBOSE(i); - // break; - // } } } if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ??? diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 22ad32d..a2bf4e8 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -37,29 +37,31 @@ #define MQTT_QOS_1 0x1 #define MQTT_QOS_0 0x0 -#define SERVERNAME_SIZE 25 - -#define PASSWORD_SIZE 50 // Need to be able to store an AIO key which is 41 chars. -#define USERNAME_SIZE 41 -#define CLIENTID_SIZE 23 - -#define FEEDNAME_SIZE 40 - #define CONNECT_TIMEOUT_MS 3000 #define PUBLISH_TIMEOUT_MS 500 #define PING_TIMEOUT_MS 500 +// Adjust as necessary, in seconds +#define MQTT_CONN_KEEPALIVE 15 + +// Largest full packet we're able to send. +// Need to be able to store at least ~90 chars for a connect packet with full +// 23 char client ID. +#define MAXBUFFERSIZE (105) + #define MQTT_CONN_USERNAMEFLAG 0x80 #define MQTT_CONN_PASSWORDFLAG 0x40 #define MQTT_CONN_WILLRETAIN 0x20 #define MQTT_CONN_WILLQOS 0x08 #define MQTT_CONN_WILLFLAG 0x04 #define MQTT_CONN_CLEANSESSION 0x02 -#define MQTT_CONN_KEEPALIVE 15 // in seconds -#define MAXBUFFERSIZE (105) // Need to be able to store at least ~90 chars - // for a connect packet with full 23 char client ID. +// how many subscriptions we want to be able to +// track #define MAXSUBSCRIPTIONS 5 + +// how much data we save in a subscription object +// eg max-subscription-payload-size #define SUBSCRIPTIONDATALEN 20 @@ -128,7 +130,7 @@ class Adafruit_MQTT { const char *clientid; const char *username; const char *password; - uint8_t buffer[MAXBUFFERSIZE]; + uint8_t buffer[MAXBUFFERSIZE]; // one buffer, used for all incoming/outgoing private: Adafruit_MQTT_Subscribe *subscriptions[MAXSUBSCRIPTIONS]; diff --git a/README.md b/README.md index 4408295..6cc012e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # Adafruit_MQTT_Library Arduino library for MQTT support + +ToDo: + * QoS > 0 for publication + * Subscription callbacks + * example with way more timeout/reconnection protection + * Wills + * remove watchdog \ No newline at end of file