Skip to content

Commit 61f7524

Browse files
brentrubrentru
authored andcommitted
Library Fixes (#127)
* Removing warnings * handle reading zero-length packets * updating travis to exclude archived libraries, addin Arduino WiFi101 lib instead * adding esp lib to travis * restrict builds to current hardware platforms * travis, esp8266: skip esp target for non-esp-based examples * adding test skips for zero, fixing fingerprint error bump library version
1 parent a4e1ee0 commit 61f7524

File tree

18 files changed

+38
-15
lines changed

18 files changed

+38
-15
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ sudo: false
33
before_install:
44
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
55
install:
6-
- arduino --install-library "Adafruit SleepyDog Library,Adafruit FONA Library,Adafruit CC3000 Library,Adafruit_WINC1500"
6+
- arduino --install-library "Adafruit SleepyDog Library","Adafruit FONA Library"
77
script:
8-
- build_main_platforms
8+
- build_platform esp8266
9+
- arduino --install-library "WiFi101"
10+
- build_platform zero
911
notifications:
1012
email:
1113
on_success: change

Adafruit_MQTT.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ int8_t Adafruit_MQTT::connect() {
189189
success = true;
190190
break;
191191
}
192-
//Serial.println("\t**failed, retrying!");
193192
}
194193
if (! success) return -2; // failed to sub for some reason
195194
}
@@ -206,15 +205,20 @@ int8_t Adafruit_MQTT::connect(const char *user, const char *pass)
206205

207206
uint16_t Adafruit_MQTT::processPacketsUntil(uint8_t *buffer, uint8_t waitforpackettype, uint16_t timeout) {
208207
uint16_t len;
209-
while (len = readFullPacket(buffer, MAXBUFFERSIZE, timeout)) {
210208

211-
//DEBUG_PRINT("Packet read size: "); DEBUG_PRINTLN(len);
212-
// TODO: add subscription reading & call back processing here
209+
while(true) {
210+
len = readFullPacket(buffer, MAXBUFFERSIZE, timeout);
213211

214-
if ((buffer[0] >> 4) == waitforpackettype) {
215-
//DEBUG_PRINTLN(F("Found right packet"));
212+
if(len == 0){
213+
break;
214+
}
215+
216+
if ((buffer[0] >> 4) == waitforpackettype)
217+
{
216218
return len;
217-
} else {
219+
}
220+
else
221+
{
218222
ERROR_PRINTLN(F("Dropped a packet"));
219223
}
220224
}
@@ -407,7 +411,6 @@ bool Adafruit_MQTT::unsubscribe(Adafruit_MQTT_Subscribe *sub) {
407411
}
408412

409413
void Adafruit_MQTT::processPackets(int16_t timeout) {
410-
uint16_t len;
411414

412415
uint32_t elapsed = 0, endtime, starttime = millis();
413416

@@ -482,7 +485,7 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
482485
if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ???
483486

484487
uint8_t packet_id_len = 0;
485-
uint16_t packetid;
488+
uint16_t packetid = 0;
486489
// Check if it is QoS 1, TODO: we dont support QoS 2
487490
if ((buffer[0] & 0x6) == 0x2) {
488491
packet_id_len = 2;

Adafruit_MQTT_Client.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
5353
uint16_t len = 0;
5454
int16_t t = timeout;
5555

56+
5657
while (client->connected() && (timeout >= 0)) {
5758
//DEBUG_PRINT('.');
5859
while (client->available()) {
@@ -62,6 +63,11 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
6263
buffer[len] = c;
6364
//DEBUG_PRINTLN((uint8_t)c, HEX);
6465
len++;
66+
67+
if (maxlen == 0) { // handle zero-length packets
68+
return 0;
69+
}
70+
6571
if (len == maxlen) { // we read all we want, bail
6672
DEBUG_PRINT(F("Read data:\t"));
6773
DEBUG_PRINTBUFFER(buffer, len);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

examples/adafruitio_secure_esp8266/adafruitio_secure_esp8266.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ WiFiClientSecure client;
4040
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
4141
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
4242

43-
// io.adafruit.com SHA1 fingerprint. Current fingerprint can be verified via:
44-
// echo | openssl s_client -connect io.adafruit.com:443 |& openssl x509 -fingerprint -noout
45-
#define AIO_SSL_FINGERPRINT "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18"
43+
// io.adafruit.com SHA1 fingerprint
44+
const char* fingerprint = "AD 4B 64 B3 67 40 B5 FC 0E 51 9B BD 25 E9 7F 88 B6 2A A3 5B";
4645

4746
/****************************** Feeds ***************************************/
4847

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

examples/mqtt_esp8266/.zero.test.skip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)