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
This commit is contained in:
brentrubell 2018-08-17 18:01:52 -04:00 committed by brentru
parent a4e1ee0133
commit 61f75246f4
18 changed files with 38 additions and 15 deletions

View File

@ -3,9 +3,11 @@ sudo: false
before_install: before_install:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
install: install:
- arduino --install-library "Adafruit SleepyDog Library,Adafruit FONA Library,Adafruit CC3000 Library,Adafruit_WINC1500" - arduino --install-library "Adafruit SleepyDog Library","Adafruit FONA Library"
script: script:
- build_main_platforms - build_platform esp8266
- arduino --install-library "WiFi101"
- build_platform zero
notifications: notifications:
email: email:
on_success: change on_success: change

View File

@ -189,7 +189,6 @@ int8_t Adafruit_MQTT::connect() {
success = true; success = true;
break; break;
} }
//Serial.println("\t**failed, retrying!");
} }
if (! success) return -2; // failed to sub for some reason if (! success) return -2; // failed to sub for some reason
} }
@ -206,15 +205,20 @@ int8_t Adafruit_MQTT::connect(const char *user, const char *pass)
uint16_t Adafruit_MQTT::processPacketsUntil(uint8_t *buffer, uint8_t waitforpackettype, uint16_t timeout) { uint16_t Adafruit_MQTT::processPacketsUntil(uint8_t *buffer, uint8_t waitforpackettype, uint16_t timeout) {
uint16_t len; uint16_t len;
while (len = readFullPacket(buffer, MAXBUFFERSIZE, timeout)) {
//DEBUG_PRINT("Packet read size: "); DEBUG_PRINTLN(len); while(true) {
// TODO: add subscription reading & call back processing here len = readFullPacket(buffer, MAXBUFFERSIZE, timeout);
if ((buffer[0] >> 4) == waitforpackettype) { if(len == 0){
//DEBUG_PRINTLN(F("Found right packet")); break;
}
if ((buffer[0] >> 4) == waitforpackettype)
{
return len; return len;
} else { }
else
{
ERROR_PRINTLN(F("Dropped a packet")); ERROR_PRINTLN(F("Dropped a packet"));
} }
} }
@ -407,7 +411,6 @@ bool Adafruit_MQTT::unsubscribe(Adafruit_MQTT_Subscribe *sub) {
} }
void Adafruit_MQTT::processPackets(int16_t timeout) { void Adafruit_MQTT::processPackets(int16_t timeout) {
uint16_t len;
uint32_t elapsed = 0, endtime, starttime = millis(); uint32_t elapsed = 0, endtime, starttime = millis();
@ -482,7 +485,7 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ??? if (i==MAXSUBSCRIPTIONS) return NULL; // matching sub not found ???
uint8_t packet_id_len = 0; uint8_t packet_id_len = 0;
uint16_t packetid; uint16_t packetid = 0;
// Check if it is QoS 1, TODO: we dont support QoS 2 // Check if it is QoS 1, TODO: we dont support QoS 2
if ((buffer[0] & 0x6) == 0x2) { if ((buffer[0] & 0x6) == 0x2) {
packet_id_len = 2; packet_id_len = 2;

View File

@ -53,6 +53,7 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
uint16_t len = 0; uint16_t len = 0;
int16_t t = timeout; int16_t t = timeout;
while (client->connected() && (timeout >= 0)) { while (client->connected() && (timeout >= 0)) {
//DEBUG_PRINT('.'); //DEBUG_PRINT('.');
while (client->available()) { while (client->available()) {
@ -62,6 +63,11 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
buffer[len] = c; buffer[len] = c;
//DEBUG_PRINTLN((uint8_t)c, HEX); //DEBUG_PRINTLN((uint8_t)c, HEX);
len++; len++;
if (maxlen == 0) { // handle zero-length packets
return 0;
}
if (len == maxlen) { // we read all we want, bail if (len == maxlen) { // we read all we want, bail
DEBUG_PRINT(F("Read data:\t")); DEBUG_PRINT(F("Read data:\t"));
DEBUG_PRINTBUFFER(buffer, len); DEBUG_PRINTBUFFER(buffer, len);

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -40,9 +40,8 @@ WiFiClientSecure client;
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
// io.adafruit.com SHA1 fingerprint. Current fingerprint can be verified via: // io.adafruit.com SHA1 fingerprint
// echo | openssl s_client -connect io.adafruit.com:443 |& openssl x509 -fingerprint -noout const char* fingerprint = "AD 4B 64 B3 67 40 B5 FC 0E 51 9B BD 25 E9 7F 88 B6 2A A3 5B";
#define AIO_SSL_FINGERPRINT "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18"
/****************************** Feeds ***************************************/ /****************************** Feeds ***************************************/

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -1,5 +1,5 @@
name=Adafruit MQTT Library name=Adafruit MQTT Library
version=0.20.1 version=0.20.2
author=Adafruit author=Adafruit
maintainer=Adafruit <info@adafruit.com> maintainer=Adafruit <info@adafruit.com>
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware. sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.