Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
*.swo
*.swp
.DS_Store
.sync
.syntastic_cpp_config

# platformio (testing)
.pioenvs
.piolibdeps
.travis.yml
platformio.ini

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ This library requires the latest version of the [Arduino IDE](https://www.arduin
* Latest version of the [Adafruit MQTT Library](https://github.com/adafruit/Adafruit_MQTT_Library)
* Latest version of the [Arduino HTTP Client Library](https://github.com/arduino-libraries/ArduinoHttpClient)

### Adafruit Feather HUZZAH32 (ESP32)

* Latest version of the [ESP32 Arduino Core](https://github.com/espressif/arduino-esp32#using-through-arduino-ide)
* Latest version of the [Adafruit MQTT Library](https://github.com/adafruit/Adafruit_MQTT_Library)
* Latest version of the [Arduino HTTP Client Library](https://github.com/arduino-libraries/ArduinoHttpClient)

### Adafruit Feather M0 WiFi with ATWINC1500

* Latest version of the [Arduino SAMD Arduino Core](https://github.com/arduino/ArduinoCore-samd)
Expand Down
17 changes: 14 additions & 3 deletions examples/adafruitio_01_subscribe/adafruitio_01_subscribe.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ void setup() {

Serial.print("Connecting to Adafruit IO");

// connect to io.adafruit.com
// because Adafruit IO doesn't support the MQTT
// retain flag right now, we need to load the
// last value for the "counter" feed manually and
// send it our handleMessage function
if (counter->exists()) {
handleMessage(counter->lastValue());
}

// start MQTT connection to io.adafruit.com
io.connect();

// set up a message handler for the count feed.
Expand All @@ -41,8 +49,11 @@ void setup() {
// received from adafruit io.
counter->onMessage(handleMessage);

// wait for a connection
while(io.status() < AIO_CONNECTED) {
// wait for an MQTT connection
// NOTE: when blending the HTTP and MQTT API, always use the mqttStatus
// method to check on MQTT connection status specifically

while(io.mqttStatus() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit IO Arduino
version=2.7.0
version=2.7.1
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Arduino library to access Adafruit IO.
Expand Down
14 changes: 10 additions & 4 deletions src/AdafruitIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ AdafruitIO::AdafruitIO(const char *user, const char *key)

void errorCallback(char *err, uint16_t len)
{
AIO_ERR_PRINTLN();
AIO_ERR_PRINT("ERROR: ");
AIO_ERR_PRINTLN(err);
AIO_ERR_PRINTLN();
AIO_ERROR_PRINTLN();
AIO_ERROR_PRINT("ERROR: ");
AIO_ERROR_PRINTLN(err);
AIO_ERROR_PRINTLN();
}

void AdafruitIO::connect()
{

AIO_DEBUG_PRINTLN("AdafruitIO::connect()");

if(_err_sub) {
// setup error sub
_err_sub = new Adafruit_MQTT_Subscribe(_mqtt, _err_topic);
Expand Down Expand Up @@ -221,7 +223,11 @@ aio_status_t AdafruitIO::mqttStatus()
// if the connection failed,
// return so we don't hammer IO
if(_status == AIO_CONNECT_FAILED)
{
AIO_ERROR_PRINT("mqttStatus() failed to connect");
AIO_ERROR_PRINTLN(_mqtt->connectErrorString(_status));
return _status;
}

if(_mqtt->connected())
return AIO_CONNECTED;
Expand Down
1 change: 1 addition & 0 deletions src/AdafruitIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#error "This sketch requires Adafruit MQTT Library v0.17.0 or higher. Please install or upgrade using the Library Manager."
#endif


class AdafruitIO {

friend class AdafruitIO_Feed;
Expand Down
Loading