compile fix & #ifdef the MQTT version

This commit is contained in:
ladyada 2015-10-21 00:05:46 -04:00
parent 9a11d83cf5
commit 286245ab62
2 changed files with 8 additions and 3 deletions

View File

@ -84,6 +84,7 @@ Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port,
subscriptions[i] = 0; subscriptions[i] = 0;
} }
packet_id_counter = 0;
} }
Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server, Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
@ -103,6 +104,7 @@ Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server,
subscriptions[i] = 0; subscriptions[i] = 0;
} }
packet_id_counter = 0;
} }
int8_t Adafruit_MQTT::connect() { int8_t Adafruit_MQTT::connect() {
@ -355,10 +357,13 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
p+=2; p+=2;
// fill in packet[1] last // fill in packet[1] last
if(MQTT_PROTOCOL_LEVEL == 3) #if MQTT_PROTOCOL_LEVEL == 3
p = stringprint_P(p, PSTR("MQIsdp")); p = stringprint_P(p, PSTR("MQIsdp"));
else #elif MQTT_PROTOCOL_LEVEL == 4
p = stringprint_P(p, PSTR("MQTT")); p = stringprint_P(p, PSTR("MQTT"));
#else
#error "MQTT level not supported"
#endif
p[0] = MQTT_PROTOCOL_LEVEL; p[0] = MQTT_PROTOCOL_LEVEL;
p++; p++;

View File

@ -201,7 +201,7 @@ class Adafruit_MQTT {
uint8_t will_qos; uint8_t will_qos;
uint8_t will_retain; uint8_t will_retain;
uint8_t buffer[MAXBUFFERSIZE]; // one buffer, used for all incoming/outgoing uint8_t buffer[MAXBUFFERSIZE]; // one buffer, used for all incoming/outgoing
uint16_t packet_id_counter = 0; uint16_t packet_id_counter;
private: private:
Adafruit_MQTT_Subscribe *subscriptions[MAXSUBSCRIPTIONS]; Adafruit_MQTT_Subscribe *subscriptions[MAXSUBSCRIPTIONS];