Merge cleanup changes and update README todo.

This commit is contained in:
Tony DiCola 2015-06-05 13:10:22 -07:00
commit 2fa9804b48
3 changed files with 21 additions and 24 deletions

View File

@ -188,18 +188,6 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
DEBUG_PRINT(F("Found sub #")); DEBUG_PRINTLN(i); DEBUG_PRINT(F("Found sub #")); DEBUG_PRINTLN(i);
break; break;
} }
// bool flag = true;
// // TODO: REPLACE WITH MEMCMP?
// for (uint8_t k=0; k<topiclen; k++) {
// if ( buffer[4+k] != pgm_read_byte(subscriptions[i]->topic+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 ??? if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ???

View File

@ -37,29 +37,31 @@
#define MQTT_QOS_1 0x1 #define MQTT_QOS_1 0x1
#define MQTT_QOS_0 0x0 #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 CONNECT_TIMEOUT_MS 3000
#define PUBLISH_TIMEOUT_MS 500 #define PUBLISH_TIMEOUT_MS 500
#define PING_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_USERNAMEFLAG 0x80
#define MQTT_CONN_PASSWORDFLAG 0x40 #define MQTT_CONN_PASSWORDFLAG 0x40
#define MQTT_CONN_WILLRETAIN 0x20 #define MQTT_CONN_WILLRETAIN 0x20
#define MQTT_CONN_WILLQOS 0x08 #define MQTT_CONN_WILLQOS 0x08
#define MQTT_CONN_WILLFLAG 0x04 #define MQTT_CONN_WILLFLAG 0x04
#define MQTT_CONN_CLEANSESSION 0x02 #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 // how many subscriptions we want to be able to
// for a connect packet with full 23 char client ID. // track
#define MAXSUBSCRIPTIONS 5 #define MAXSUBSCRIPTIONS 5
// how much data we save in a subscription object
// eg max-subscription-payload-size
#define SUBSCRIPTIONDATALEN 20 #define SUBSCRIPTIONDATALEN 20
@ -128,7 +130,7 @@ class Adafruit_MQTT {
const char *clientid; const char *clientid;
const char *username; const char *username;
const char *password; const char *password;
uint8_t buffer[MAXBUFFERSIZE]; uint8_t buffer[MAXBUFFERSIZE]; // one buffer, used for all incoming/outgoing
private: private:
Adafruit_MQTT_Subscribe *subscriptions[MAXSUBSCRIPTIONS]; Adafruit_MQTT_Subscribe *subscriptions[MAXSUBSCRIPTIONS];

View File

@ -1,2 +1,9 @@
# Adafruit_MQTT_Library # Adafruit_MQTT_Library
Arduino library for MQTT support Arduino library for MQTT support
ToDo:
* QoS > 0 for publication
* Subscription callbacks
* example with way more timeout/reconnection protection
* Wills
* remove watchdog