Compare commits

..

5 commits

Author SHA1 Message Date
brentru
e1a05c6301 bump lib name 2020-09-23 12:58:50 -04:00
Brent Rubell
cc5331c470
Merge branch 'master' into patch-1 2020-09-23 12:49:02 -04:00
Zach Auclair
ec80bf783a chore(build): version bump for release 2020-07-08 22:36:27 -04:00
Zach Auclair
c74c56769a fix(definitions): csv length incorrectly small
The max csv length should be 4 characters larger than the max feed name,
so update the definition accordingly.

fixes #127
2020-07-08 22:35:59 -04:00
Zach Auclair
14c311d301 fix(definitions): feed name incorrectly small
Grouped feeds can be a max of 258 characters long (128 for the group, a single dot,
and another 128 for the feed name).
2020-07-08 22:35:59 -04:00
89 changed files with 144 additions and 1114 deletions

View file

@ -8,17 +8,16 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
arduino-platform: ["esp8266", "esp32", arduino-platform: ["esp8266", "esp32",
"pyportal", "metro_m4_airliftlite", "pyportal", "metro_m4_airliftlite"]
"picow_rp2040_tinyusb"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-python@v4 - uses: actions/setup-python@v1
with: with:
python-version: '3.x' python-version: '3.x'
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/checkout@v3 - uses: actions/checkout@v2
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
path: ci path: ci
@ -27,12 +26,10 @@ jobs:
run: bash ci/actions_install.sh run: bash ci/actions_install.sh
# manually install WiFi and HTTPClient # manually install WiFi
- name: extra libraries - name: extra libraries
run: | run: |
git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA
rm -rf /home/runner/Arduino/libraries/ArduinoHttpClient
git clone --quiet https://github.com/arduino-libraries/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient
- name: test platforms - name: test platforms
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}

View file

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015-2021 Adafruit Industries Copyright (c) 2015-2016 Adafruit Industries
Authors: Tony DiCola, Todd Treece Authors: Tony DiCola, Todd Treece
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View file

@ -2,11 +2,11 @@
[![Build Status](https://github.com/adafruit/Adafruit_IO_Arduino/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html) [![Build Status](https://github.com/adafruit/Adafruit_IO_Arduino/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html)
[![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://adafru.it/discord) [![Discord](https://img.shields.io/discord/327254708534116352.svg)](https://discord.gg/nBQh6qu)
![AIOArduino](https://cdn-learn.adafruit.com/assets/assets/000/057/496/original/adafruit_io_AIOA.png?1531335660) ![AIOArduino](https://cdn-learn.adafruit.com/assets/assets/000/057/496/original/adafruit_io_AIOA.png?1531335660)
This library provides a simple device independent interface for interacting with [Adafruit IO](https://io.adafruit.com) using Arduino. It allows you to switch between WiFi (ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, RP2040, Airlift, WINC1500, & WICED), Cellular (32u4 FONA), and Ethernet (Ethernet FeatherWing). This library provides a simple device independent interface for interacting with [Adafruit IO](https://io.adafruit.com) using Arduino. It allows you to switch between WiFi (ESP8266, ESP32, AirLift, WINC1500, & WICED), Cellular (32u4 FONA), and Ethernet (Ethernet FeatherWing)
## Documentation ## Documentation
@ -22,4 +22,4 @@ for details).
Adafruit invests time and resources providing this open source code, please Adafruit invests time and resources providing this open source code, please
support Adafruit and open-source hardware by purchasing products from support Adafruit and open-source hardware by purchasing products from
[Adafruit](https://www.adafruit.com)! [Adafruit](https://www.adafruit.com)!

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -27,9 +27,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -30,14 +30,9 @@ void setup() {
// set up led pin as an analog output // set up led pin as an analog output
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) // ESP32 pinMode()
// New ESP32 LEDC API ledcAttachPin(LED_PIN, 1);
ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution ledcSetup(1, 1200, 8);
#else
// Legacy ESP32 LEDC API
ledcAttachPin(LED_PIN, 1);
ledcSetup(1, 1200, 8);
#endif
#else #else
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
#endif #endif
@ -92,6 +87,12 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- "); Serial.print("received <- ");
Serial.println(reading); Serial.println(reading);
// write the current 'reading' to the led // write the current 'reading' to the led
analogWrite(LED_PIN, reading); #if defined(ARDUINO_ARCH_ESP32)
ledcWrite(1, reading); // ESP32 analogWrite()
#else
analogWrite(LED_PIN, reading);
#endif
} }

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -39,20 +39,14 @@ void setup() {
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode #if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) // assign rgb pins to channels
// New ESP32 LEDC API ledcAttachPin(RED_PIN, 1);
ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution ledcAttachPin(GREEN_PIN, 2);
ledcAttach(GREEN_PIN, 12000, 8); ledcAttachPin(BLUE_PIN, 3);
ledcAttach(BLUE_PIN, 12000, 8); // init. channels
#else ledcSetup(1, 12000, 8);
// Legacy ESP32 LEDC API ledcSetup(2, 12000, 8);
ledcAttachPin(RED_PIN, 1); ledcSetup(3, 12000, 8);
ledcAttachPin(GREEN_PIN, 2);
ledcAttachPin(BLUE_PIN, 3);
ledcSetup(1, 12000, 8);
ledcSetup(2, 12000, 8);
ledcSetup(3, 12000, 8);
#endif
#else #else
pinMode(RED_PIN, OUTPUT); pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT);
@ -114,7 +108,14 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.println(data->value()); Serial.println(data->value());
// invert RGB values for common anode LEDs // invert RGB values for common anode LEDs
analogWrite(RED_PIN, 255 - data->toRed()); #if defined(ARDUINO_ARCH_ESP32) // ESP32 analogWrite
analogWrite(GREEN_PIN, 255 - data->toGreen()); ledcWrite(1, 255 - data->toRed());
analogWrite(BLUE_PIN, 255 - data->toBlue()); ledcWrite(2, 255 - data->toGreen());
ledcWrite(3, 255 - data->toBlue());
#else
analogWrite(RED_PIN, 255 - data->toRed());
analogWrite(GREEN_PIN, 255 - data->toGreen());
analogWrite(BLUE_PIN, 255 - data->toBlue());
#endif
} }

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -27,9 +27,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -1,95 +0,0 @@
// Adafruit IO Schedule Trigger Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-scheduled-triggers/
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Brent Rubell for Adafruit Industries
// Copyright (c) 2020 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.
/************************** Configuration ***********************************/
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"
/************************ Example Starts Here *******************************/
// Relay is connected to PyPortal's D3 connector
#define RELAY_POWER_PIN 3
// Set up the 'relay feed'
AdafruitIO_Feed *relay = io.feed("relay");
void setup() {
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
Serial.print("Connecting to Adafruit IO");
// connect to io.adafruit.com
io.connect();
// set up a message handler for the 'relay' feed.
// the handleMessage function (defined below)
// will be called whenever a message is
// received from adafruit io
relay->onMessage(handleMessage);
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
// Get the last known value from the feed
relay->get();
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
}
// this function is called whenever an 'relay' feed message
// is received from Adafruit IO. it was attached to
// the 'relay' feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {
Serial.print("feed received new data <- ");
Serial.println(data->toChar());
// Check to see if the morning scheduled trigger has executed
if (strcmp(data->toChar(), "1") == 0) {
Serial.println("Turning lights ON");
digitalWrite(RELAY_POWER_PIN, HIGH);
}
// Check to see if the evening scheduled trigger has executed
else if (strcmp(data->toChar(), "0") == 0) {
Serial.println("Turning lights OFF");
digitalWrite(RELAY_POWER_PIN, LOW);
}
else {
Serial.println("Unexpected data received from Adafruit IO");
}
}

View file

@ -1,67 +0,0 @@
/************************ Adafruit IO Config *******************************/
// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME "your_username"
#define IO_KEY "your_key"
/******************************* WIFI **************************************/
// the AdafruitIO_WiFi client will work with the following boards:
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010
// - Feather WICED -> https://www.adafruit.com/products/3056
// - Adafruit PyPortal -> https://www.adafruit.com/product/4116
// - Adafruit Metro M4 Express AirLift Lite ->
// https://www.adafruit.com/product/4000
// - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201
#define WIFI_SSID "your_ssid"
#define WIFI_PASS "your_pass"
// uncomment the following line if you are using airlift
// #define USE_AIRLIFT
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
#define ESP32_RESETN 6 // Reset pin
#define ESP32_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* FONA **************************************/
// the AdafruitIO_FONA client will work with the following boards:
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027
// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
/**************************** ETHERNET ************************************/
// the AdafruitIO_Ethernet client will work with the following boards:
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201
// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

View file

@ -1,116 +0,0 @@
// Adafruit IO Publish & Subscribe, Digital Input and Output Example
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Modified by Brent Rubell for Adafruit Industries
// Copyright (c) 2020 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.
/************************** Configuration ***********************************/
// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"
/************************ Example Starts Here *******************************/
// Button Pin
#define BUTTON_PIN 0
// LED Pin
#define LED_PIN LED_BUILTIN
// button state
bool btn_state = false;
bool prv_btn_state = false;
// set up the 'led' feed
AdafruitIO_Feed *led = io.feed("led");
// set up the 'button' feed
AdafruitIO_Feed *button = io.feed("button");
void setup() {
// set button pin as an input
pinMode(BUTTON_PIN, INPUT);
// set LED pin as an output
pinMode(LED_PIN, OUTPUT);
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
Serial.print("Connecting to Adafruit IO");
// connect to io.adafruit.com
io.connect();
// set up a message handler for the count feed.
// the handleMessage function (defined below)
// will be called whenever a message is
// received from adafruit io.
led->onMessage(handleMessage);
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
led->get();
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
// grab the btn_state state of the button.
if(digitalRead(BUTTON_PIN) == LOW)
btn_state = false;
else
btn_state = true;
// return if the btn state hasn't changed
if(btn_state == prv_btn_state)
return;
// save the btn_state state to the 'button' feed on adafruit io
Serial.print("sending button -> "); Serial.println(btn_state);
button->save(btn_state);
// store last button state
prv_btn_state = btn_state;
}
// this function is called whenever a 'led' message
// is received from Adafruit IO. it was attached to
// the counter feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- ");
if(data->toPinLevel() == HIGH)
Serial.println("HIGH");
else
Serial.println("LOW");
digitalWrite(LED_PIN, data->toPinLevel());
}

View file

@ -1,67 +0,0 @@
/************************ Adafruit IO Config *******************************/
// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME "your_username"
#define IO_KEY "your_key"
/******************************* WIFI **************************************/
// the AdafruitIO_WiFi client will work with the following boards:
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010
// - Feather WICED -> https://www.adafruit.com/products/3056
// - Adafruit PyPortal -> https://www.adafruit.com/product/4116
// - Adafruit Metro M4 Express AirLift Lite ->
// https://www.adafruit.com/product/4000
// - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201
#define WIFI_SSID "your_ssid"
#define WIFI_PASS "your_pass"
// uncomment the following line if you are using airlift
// #define USE_AIRLIFT
// uncomment the following line if you are using winc1500
// #define USE_WINC1500
// comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define SPIWIFI_ACK 9 // a.k.a BUSY or READY pin
#define ESP32_RESETN 6 // Reset pin
#define ESP32_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* FONA **************************************/
// the AdafruitIO_FONA client will work with the following boards:
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027
// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
/**************************** ETHERNET ************************************/
// the AdafruitIO_Ethernet client will work with the following boards:
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201
// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

View file

@ -1,80 +0,0 @@
/* Adafruit IO Example Using WiFiManager
*
* This is a simple Adafruit feed subscribe example that uses
* WiFiManager to handle setup of WiFi credentials and connecting
* to the network instead of defining the WiFI SSID and password
* explicitly in the code.
*
* To use this example, add your Adafruit IO Username and Key
* and setup a feed called "myfeed". When you manually add data
* to the feed on io.adafruit.com, you'll see that data written to
* the serial output.
*
* Brad Black - 2022
*
*/
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"
char IO_USERNAME[64] = "my username";
char IO_KEY[64] = "my key";
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, "", "");
AdafruitIO_Feed *myfeed = io.feed("myfeed");
WiFiManager wifiManager;
void handleMessage(AdafruitIO_Data *data)
{
Serial.print("received <- ");
Serial.println(data->toString());
} // handleMessage
void setup()
{
Serial.begin(115200); // Initialize serial port for debugging.
delay(500);
// wifiManager.resetSettings(); //uncomment to reset the WiFi settings
wifiManager.setClass("invert"); // enable "dark mode" for the config portal
wifiManager.setConfigPortalTimeout(120); // auto close configportal after n seconds
wifiManager.setAPClientCheck(true); // avoid timeout if client connected to softap
if (!wifiManager.autoConnect("WiFi Setup")) // connect to wifi with existing setting or start config
{
Serial.println("failed to connect and hit timeout");
}
else
{
// if you get here you have connected to the WiFi
Serial.println("Connected to WiFi.");
Serial.printf("Connecting to Adafruit IO with User: %s Key: %s.\n", IO_USERNAME, IO_KEY);
io.connect();
myfeed->onMessage(handleMessage);
myfeed->get();
// wait for a connection
while ((io.status() < AIO_CONNECTED))
{
Serial.print(".");
delay(500);
}
Serial.println("Connected to Adafruit IO.");
}
} // setup()
void loop()
{
io.run();
} // loop()

View file

@ -1,192 +0,0 @@
/* Adafruit IO Example Using WiFiManager with Custom Adafruit IO parameters
*
* This is a simple Adafruit feed subscribe example that uses
* WiFiManager to handle setup of WiFi credentials and connecting
* to the network instead of defining the WiFI SSID and password
* explicitly in the code.
*
* In addition, this example allows you to enter your Adafruit IO username and key
* as customer parameters in WiFiManager so that they do not need to be coded into
* the sketch.
*
* This is useful if you want to create projects and share them with others that
* may use them on a different WiFi network and use a different Adafruit IO account
* for IOT integrations such as collecting sensor data or voice command integration via
* IFFT.
*
* To use this example, setup a feed called "myfeed". When the ESP8266 or ESP32
* microcontroller starts, join the "WiFi Setup" SSID and you should be presented
* with the config portal. If the config portal does not automatically start you
* can browse to http://192.168.4.1 to access it
*
* Select the SSID and enter the password for WiFi Access in the config portal.
* Enter your Adafruit IO username and key in the config portal and select "Save".
*
* When you manually add data to the feed on io.adafruit.com, you'll see
* that data written to the serial output.
*
* Brad Black - 2022
*
*/
#include <WiFiManager.h>
#include "AdafruitIO_WiFi.h"
#include <ArduinoJson.h>
#include <LittleFS.h>
char IO_USERNAME[64] = "";
char IO_KEY[64] = "";
static uint8_t objStorage[sizeof(AdafruitIO_WiFi)]; // RAM for the object
AdafruitIO_WiFi *io; // a pointer to the object, once it's constructed
// create WiFiManager object and define our custom parameters
WiFiManager wifiManager;
WiFiManagerParameter custom_IO_USERNAME("iouser", "Adafruit IO Username", IO_USERNAME, 60);
WiFiManagerParameter custom_IO_KEY("iokey", "Adafruit IO Key", IO_KEY, 60);
void handleMessage(AdafruitIO_Data *data)
{
Serial.print("received <- ");
Serial.println(data->toString());
} // handleMessage
// callback notifying us of the need to save config
void saveConfigCallback()
{
Serial.println("Saving new config");
strcpy(IO_USERNAME, custom_IO_USERNAME.getValue());
strcpy(IO_KEY, custom_IO_KEY.getValue());
DynamicJsonDocument json(256);
json["IO_KEY"] = IO_KEY;
json["IO_USERNAME"] = IO_USERNAME;
File configFile = LittleFS.open("/config.json", "w");
if (!configFile)
{
Serial.println("Failed to open config file for writing");
}
serializeJson(json, Serial);
serializeJson(json, configFile);
configFile.close();
} // end save
void readParamsFromFS()
{
if (LittleFS.begin())
{
if (LittleFS.exists("/config.json"))
{
// file exists, reading and loading
Serial.println("Reading config file");
File configFile = LittleFS.open("/config.json", "r");
if (configFile)
{
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonDocument json(256);
auto deserializeError = deserializeJson(json, buf.get());
serializeJson(json, Serial);
Serial.println();
if (!deserializeError)
{
if (json.containsKey("IO_USERNAME"))
strcpy(IO_USERNAME, json["IO_USERNAME"]);
if (json.containsKey("IO_KEY"))
strcpy(IO_KEY, json["IO_KEY"]);
}
else
{
Serial.println("Failed to load json config");
}
configFile.close();
}
}
else
{
Serial.println("Failed to mount FS");
}
}
}
void setup()
{
Serial.begin(115200); // Initialize serial port for debugging.
delay(500);
WiFi.begin();
readParamsFromFS(); // get parameters from file system
//wifiManager.resetSettings(); //uncomment to reset the WiFi settings
wifiManager.setClass("invert"); // enable "dark mode" for the config portal
wifiManager.setConfigPortalTimeout(120); // auto close configportal after n seconds
wifiManager.setAPClientCheck(true); // avoid timeout if client connected to softap
wifiManager.addParameter(&custom_IO_USERNAME); // set custom paraeter for IO username
wifiManager.addParameter(&custom_IO_KEY); // set custom parameter for IO key
custom_IO_KEY.setValue(IO_KEY, 64); // set custom parameter value
custom_IO_USERNAME.setValue(IO_USERNAME, 64); // set custom parameter value
wifiManager.setSaveConfigCallback(saveConfigCallback); // set config save notify callback
if (!wifiManager.autoConnect("WiFi Setup")) // connect to wifi with existing setting or start config
{
Serial.println("Failed to connect and hit timeout");
}
else
{
// if you get here you have connected to the WiFi
Serial.println("Connected to WiFi.");
// connect to Adafruit IO
io = new (objStorage) AdafruitIO_WiFi(IO_USERNAME, IO_KEY, "", "");
Serial.printf("Connecting to Adafruit IO with User: %s Key: %s.\n", IO_USERNAME, IO_KEY);
io->connect();
AdafruitIO_Feed *myfeed = io->feed("myfeed");
myfeed->onMessage(handleMessage);
myfeed->get();
// wait for a connection
while ((io->status() < AIO_CONNECTED))
{
Serial.print(".");
delay(500);
}
Serial.println("Connected to Adafruit IO.");
}
} // setup()
void loop()
{
io->run();
} // loop()

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -29,9 +29,6 @@
// uncomment the following line if you are using winc1500 // uncomment the following line if you are using winc1500
// #define USE_WINC1500 // #define USE_WINC1500
// uncomment the following line if you are using mrk1010 or nano 33 iot
// #define ARDUINO_SAMD_MKR1010
// comment out the following lines if you are using fona or ethernet // comment out the following lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h" #include "AdafruitIO_WiFi.h"

View file

@ -1,10 +1,10 @@
name=Adafruit IO Arduino name=Adafruit IO Arduino
version=4.3.2 version=3.9.1
author=Adafruit author=Adafruit
maintainer=Adafruit <adafruitio@adafruit.com> maintainer=Adafruit <adafruitio@adafruit.com>
sentence=Arduino library to access Adafruit IO. sentence=Arduino library to access Adafruit IO.
paragraph=Arduino library to access Adafruit IO using WiFi, ethernet, or cellular. paragraph=Arduino library to access Adafruit IO using the Adafruit AirLift, ESP8266, ESP32, M0 WINC1500, WICED, MKR1000, Ethernet, or FONA hardware.
category=Communication category=Communication
url=https://github.com/adafruit/Adafruit_IO_Arduino url=https://github.com/adafruit/Adafruit_IO_Arduino
architectures=* architectures=*
depends=Adafruit MQTT Library, ArduinoHttpClient, Adafruit Unified Sensor, Adafruit NeoPixel, DHT sensor library, Ethernet, Adafruit Si7021 Library, Adafruit SGP30 Sensor, Adafruit BME280 Library, Adafruit LIS3DH, Adafruit VEML6070 Library, ESP32Servo, WiFiManager, ArduinoJson depends=Adafruit MQTT Library, ArduinoHttpClient, Adafruit Unified Sensor, Adafruit NeoPixel, DHT sensor library, Ethernet, Adafruit Si7021 Library, Adafruit SGP30 Sensor, Adafruit BME280 Library, Adafruit LIS3DH, Adafruit VEML6070 Library, ESP32Servo

View file

@ -30,7 +30,7 @@
* *
* @section license License * @section license License
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO.h" #include "AdafruitIO.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DASHBOARD_H #ifndef ADAFRUITIO_DASHBOARD_H

View file

@ -419,7 +419,12 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,
@return Feed's name if feed exists. @return Feed's name if feed exists.
*/ */
/**************************************************************************/ /**************************************************************************/
char *AdafruitIO_Data::feedName() { return _feed; } char *AdafruitIO_Data::feedName() {
if (!_feed)
return (char *)"";
return _feed;
}
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -443,7 +448,12 @@ char *AdafruitIO_Data::toChar() { return _value; }
@return String of value. @return String of value.
*/ */
/**************************************************************************/ /**************************************************************************/
String AdafruitIO_Data::toString() { return String(_value); } String AdafruitIO_Data::toString() {
if (!_value)
return String();
return String(_value);
}
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -452,9 +462,13 @@ String AdafruitIO_Data::toString() { return String(_value); }
*/ */
/**************************************************************************/ /**************************************************************************/
bool AdafruitIO_Data::toBool() { bool AdafruitIO_Data::toBool() {
if (!_value)
return false;
if (strcmp(_value, "1") == 0 || _value[0] == 't' || _value[0] == 'T') if (strcmp(_value, "1") == 0 || _value[0] == 't' || _value[0] == 'T')
return true; return true;
return false; else
return false;
} }
/**************************************************************************/ /**************************************************************************/
@ -480,6 +494,9 @@ bool AdafruitIO_Data::isFalse() { return !toBool(); }
*/ */
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toInt() { int AdafruitIO_Data::toInt() {
if (!_value)
return 0;
char *endptr; char *endptr;
return (int)strtol(_value, &endptr, 10); return (int)strtol(_value, &endptr, 10);
} }
@ -505,6 +522,9 @@ int AdafruitIO_Data::toPinLevel() {
*/ */
/**************************************************************************/ /**************************************************************************/
unsigned int AdafruitIO_Data::toUnsignedInt() { unsigned int AdafruitIO_Data::toUnsignedInt() {
if (!_value)
return 0;
char *endptr; char *endptr;
#ifdef ESP8266 #ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now. // For some reason strtoul is not defined on the ESP8266 platform right now.
@ -522,6 +542,9 @@ unsigned int AdafruitIO_Data::toUnsignedInt() {
*/ */
/**************************************************************************/ /**************************************************************************/
float AdafruitIO_Data::toFloat() { float AdafruitIO_Data::toFloat() {
if (!_value)
return 0;
char *endptr; char *endptr;
return (float)strtod(_value, &endptr); return (float)strtod(_value, &endptr);
} }
@ -533,6 +556,9 @@ float AdafruitIO_Data::toFloat() {
*/ */
/**************************************************************************/ /**************************************************************************/
double AdafruitIO_Data::toDouble() { double AdafruitIO_Data::toDouble() {
if (!_value)
return 0;
char *endptr; char *endptr;
return strtod(_value, &endptr); return strtod(_value, &endptr);
} }
@ -544,6 +570,9 @@ double AdafruitIO_Data::toDouble() {
*/ */
/**************************************************************************/ /**************************************************************************/
long AdafruitIO_Data::toLong() { long AdafruitIO_Data::toLong() {
if (!_value)
return 0;
char *endptr; char *endptr;
return strtol(_value, &endptr, 10); return strtol(_value, &endptr, 10);
} }
@ -555,6 +584,9 @@ long AdafruitIO_Data::toLong() {
*/ */
/**************************************************************************/ /**************************************************************************/
unsigned long AdafruitIO_Data::toUnsignedLong() { unsigned long AdafruitIO_Data::toUnsignedLong() {
if (!_value)
return 0;
char *endptr; char *endptr;
#ifdef ESP8266 #ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now. // For some reason strtoul is not defined on the ESP8266 platform right now.
@ -573,6 +605,9 @@ unsigned long AdafruitIO_Data::toUnsignedLong() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toRed() { int AdafruitIO_Data::toRed() {
// Convert 0xRRGGBB to red. // Convert 0xRRGGBB to red.
if (!_value) {
return 0;
}
char r[5]; char r[5];
strcpy(r, "0x"); strcpy(r, "0x");
strncpy(&r[2], toChar() + 1, 2); strncpy(&r[2], toChar() + 1, 2);
@ -588,6 +623,9 @@ int AdafruitIO_Data::toRed() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toGreen() { int AdafruitIO_Data::toGreen() {
// Convert 0xRRGGBB to green. // Convert 0xRRGGBB to green.
if (!_value) {
return 0;
}
char g[5]; char g[5];
strcpy(g, "0x"); strcpy(g, "0x");
strncpy(&g[2], toChar() + 3, 2); strncpy(&g[2], toChar() + 3, 2);
@ -603,6 +641,9 @@ int AdafruitIO_Data::toGreen() {
/**************************************************************************/ /**************************************************************************/
int AdafruitIO_Data::toBlue() { int AdafruitIO_Data::toBlue() {
// Convert 0xRRGGBB to blue. // Convert 0xRRGGBB to blue.
if (!_value) {
return 0;
}
char b[5]; char b[5];
strcpy(b, "0x"); strcpy(b, "0x");
strncpy(&b[2], toChar() + 5, 2); strncpy(&b[2], toChar() + 5, 2);
@ -618,6 +659,9 @@ int AdafruitIO_Data::toBlue() {
*/ */
/**************************************************************************/ /**************************************************************************/
long AdafruitIO_Data::toNeoPixel() { long AdafruitIO_Data::toNeoPixel() {
if (!_value) {
return 0;
}
char rgb[9]; char rgb[9];
strcpy(rgb, "0x"); strcpy(rgb, "0x");
strncpy(&rgb[2], toChar() + 1, 6); strncpy(&rgb[2], toChar() + 1, 6);
@ -632,7 +676,11 @@ long AdafruitIO_Data::toNeoPixel() {
*/ */
/**************************************************************************/ /**************************************************************************/
char *AdafruitIO_Data::toCSV() { char *AdafruitIO_Data::toCSV() {
if (!_value)
return _csv;
memset(_csv, 0, AIO_CSV_LENGTH); memset(_csv, 0, AIO_CSV_LENGTH);
strcpy(_csv, "\""); strcpy(_csv, "\"");
strcat(_csv, _value); strcat(_csv, _value);
strcat(_csv, "\","); strcat(_csv, "\",");
@ -641,6 +689,7 @@ char *AdafruitIO_Data::toCSV() {
strcat(_csv, charFromDouble(_lon)); strcat(_csv, charFromDouble(_lon));
strcat(_csv, ","); strcat(_csv, ",");
strcat(_csv, charFromDouble(_ele, 2)); strcat(_csv, charFromDouble(_ele, 2));
return _csv; return _csv;
} }
@ -824,7 +873,6 @@ char **parse_csv(const char *line) {
continue; continue;
case '\0': case '\0':
fEnd = 1; fEnd = 1;
break;
case ',': case ',':
*tptr = '\0'; *tptr = '\0';
*bptr = strdup(tmp); *bptr = strdup(tmp);

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DATA_H #ifndef ADAFRUITIO_DATA_H

View file

@ -9,16 +9,16 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_DEFINITIONS_H_ #ifndef ADAFRUITIO_DEFINITIONS_H_
#define ADAFRUITIO_DEFINITIONS_H_ #define ADAFRUITIO_DEFINITIONS_H_
#define ADAFRUITIO_VERSION_MAJOR 4 ///< Adafruit IO Arduino Major Semvar #define ADAFRUITIO_VERSION_MAJOR 3 ///< Adafruit IO Arduino Major Semvar
#define ADAFRUITIO_VERSION_MINOR 2 ///< Adafruit IO Arduino Minor Semvar #define ADAFRUITIO_VERSION_MINOR 5 ///< Adafruit IO Arduino Minor Semvar
#define ADAFRUITIO_VERSION_PATCH 1 ///< Adafruit IO Arduino Patch Semvar #define ADAFRUITIO_VERSION_PATCH 0 ///< Adafruit IO Arduino Patch Semvar
// forward declaration // forward declaration
class AdafruitIO_Data; class AdafruitIO_Data;
@ -119,20 +119,20 @@ public:
// echo | openssl s_client -connect io.adafruit.com:443 | openssl x509 // echo | openssl s_client -connect io.adafruit.com:443 | openssl x509
// -fingerprint -noout // -fingerprint -noout
#define AIO_SSL_FINGERPRINT \ #define AIO_SSL_FINGERPRINT \
"47 D2 CB 14 DF 38 97 59 C6 65 1A 1F 3E 00 1E 53 CC A5 17 E0" ///< Latest "59 3C 48 0A B1 8B 39 4E 0D 58 50 47 9A 13 55 60 CC A0 1D AF" ///< Latest
///< Adafruit IO ///< Adafruit IO
///< SSL ///< SSL
///< Fingerprint ///< Fingerprint
#define AIO_FEED_NAME_LENGTH \ #define AIO_FEED_NAME_LENGTH \
258 ///< Maximum length of an Adafruit IO Feed: Name; 128 + 1 + 128 for the 258 ///< Maximum length of an Adafruit IO Feed \
///< group, a dot, and actual feed name. ///< Name; 128 + 1 + 128 for the group, a dot \
///< , and actual feed name.
#define AIO_DATA_LENGTH \ #define AIO_DATA_LENGTH \
45 ///< Maximum length of data sent/recieved from Adafruit IO 45 ///< Maximum length of data sent/recieved from Adafruit IO
#define AIO_CSV_LENGTH \ #define AIO_CSV_LENGTH \
AIO_FEED_NAME_LENGTH + \ AIO_FEED_NAME_LENGTH + 4 ///< Maximum comma-separated-value length from \
4 ///< Maximum comma-separated-value length from Adafruit IO ///< Adafruit IO
/** aio_status_t offers 13 status states */ /** aio_status_t offers 13 status states */
typedef enum { typedef enum {

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_ETHERNET_H #ifndef ADAFRUITIO_ETHERNET_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_FEED_H #ifndef ADAFRUITIO_FEED_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MQTT_H #ifndef ADAFRUITIO_MQTT_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TIME_H #ifndef ADAFRUITIO_TIME_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_WIFI_H #ifndef ADAFRUITIO_WIFI_H
@ -20,11 +20,6 @@
#include "wifi/AdafruitIO_MKR1000.h" #include "wifi/AdafruitIO_MKR1000.h"
typedef AdafruitIO_MKR1000 AdafruitIO_WiFi; typedef AdafruitIO_MKR1000 AdafruitIO_WiFi;
#elif defined(ARDUINO_SAMD_MKR1010)
#include "wifi/AdafruitIO_MKR1010.h"
typedef AdafruitIO_MKR1010 AdafruitIO_WiFi;
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \ #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
defined(USE_AIRLIFT) defined(USE_AIRLIFT)
@ -51,11 +46,6 @@ typedef AdafruitIO_ESP8266 AdafruitIO_WiFi;
#include "wifi/AdafruitIO_WICED.h" #include "wifi/AdafruitIO_WICED.h"
typedef AdafruitIO_WICED AdafruitIO_WiFi; typedef AdafruitIO_WICED AdafruitIO_WiFi;
#elif defined(ARDUINO_ARCH_RP2040)
#include "wifi/AdafruitIO_RP2040.h"
typedef AdafruitIO_RP2040 AdafruitIO_WiFi;
#else #else
#warning "Must define USE_AIRLIFT or USE_WINC1500 before including this file." #warning "Must define USE_AIRLIFT or USE_WINC1500 before including this file."

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO_Block.h" #include "AdafruitIO_Block.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_BLOCK_H #ifndef ADAFRUITIO_BLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "ChartBlock.h" #include "ChartBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_CHARTBLOCK_H #ifndef ADAFRUITIO_CHARTBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_COLORBLOCK_H #ifndef ADAFRUITIO_COLORBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "GaugeBlock.h" #include "GaugeBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_GAUGEBLOCK_H #ifndef ADAFRUITIO_GAUGEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_IMAGEBLOCK_H #ifndef ADAFRUITIO_IMAGEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "MapBlock.h" #include "MapBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MAPBLOCK_H #ifndef ADAFRUITIO_MAPBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "MomentaryBlock.h" #include "MomentaryBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_MOMENTARYBLOCK_H #ifndef ADAFRUITIO_MOMENTARYBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "SliderBlock.h" #include "SliderBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_SLIDERBLOCK_H #ifndef ADAFRUITIO_SLIDERBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "StreamBlock.h" #include "StreamBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_STREAMBLOCK_H #ifndef ADAFRUITIO_STREAMBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "TextBlock.h" #include "TextBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TEXTBLOCK_H #ifndef ADAFRUITIO_TEXTBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "ToggleBlock.h" #include "ToggleBlock.h"

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_TOGGLEBLOCK_H #ifndef ADAFRUITIO_TOGGLEBLOCK_H

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#include "AdafruitIO_Board.h" #include "AdafruitIO_Board.h"
@ -29,8 +29,6 @@ const char AdafruitIO_Board::_type[] = "feather_wiced";
const char AdafruitIO_Board::_type[] = "esp32"; const char AdafruitIO_Board::_type[] = "esp32";
#elif defined(ESP8266) #elif defined(ESP8266)
const char AdafruitIO_Board::_type[] = "esp8266"; const char AdafruitIO_Board::_type[] = "esp8266";
#elif defined(ARDUINO_ARCH_RP2040)
const char AdafruitIO_Board::_type[] = "rp2040";
#else #else
const char AdafruitIO_Board::_type[] = "unknown"; const char AdafruitIO_Board::_type[] = "unknown";
#endif #endif

View file

@ -9,7 +9,7 @@
* *
* Written by Tony DiCola, Todd Treece for Adafruit Industries * Written by Tony DiCola, Todd Treece for Adafruit Industries
* *
* MIT license, all text here must be included in any redistribution. * BSD license, all text here must be included in any redistribution.
* *
*/ */
#ifndef ADAFRUITIO_BOARD_H #ifndef ADAFRUITIO_BOARD_H

View file

@ -5,8 +5,8 @@
* Please support Adafruit and open source hardware by purchasing * Please support Adafruit and open source hardware by purchasing
* products from Adafruit! * products from Adafruit!
* *
* Copyright (c) 2015-2021 Adafruit Industries * Copyright (c) 2015-2016 Adafruit Industries
* Authors: Tony DiCola, Todd Treece, Brent Rubell * Authors: Tony DiCola, Todd Treece
* Licensed under the MIT license. * Licensed under the MIT license.
* *
* All text above must be included in any redistribution. * All text above must be included in any redistribution.
@ -42,7 +42,6 @@ void AdafruitIO_ESP32::_connect() {
delay(100); delay(100);
_status = AIO_NET_DISCONNECTED; _status = AIO_NET_DISCONNECTED;
} }
_client->setCACert(_aio_root_ca);
} }
/**************************************************************************/ /**************************************************************************/
@ -56,6 +55,7 @@ void AdafruitIO_ESP32::_disconnect() {
} }
aio_status_t AdafruitIO_ESP32::networkStatus() { aio_status_t AdafruitIO_ESP32::networkStatus() {
switch (WiFi.status()) { switch (WiFi.status()) {
case WL_CONNECTED: case WL_CONNECTED:
return AIO_NET_CONNECTED; return AIO_NET_CONNECTED;

View file

@ -5,8 +5,8 @@
* Please support Adafruit and open source hardware by purchasing * Please support Adafruit and open source hardware by purchasing
* products from Adafruit! * products from Adafruit!
* *
* Copyright (c) 2015-2021 Adafruit Industries * Copyright (c) 2015-2016 Adafruit Industries
* Authors: Tony DiCola, Todd Treece, Brent Rubell * Authors: Tony DiCola, Todd Treece
* Licensed under the MIT license. * Licensed under the MIT license.
* *
* All text above must be included in any redistribution. * All text above must be included in any redistribution.
@ -42,36 +42,6 @@ protected:
const char *_pass; const char *_pass;
WiFiClientSecure *_client; WiFiClientSecure *_client;
// io.adafruit.com root CA
const char *_aio_root_ca =
"-----BEGIN CERTIFICATE-----\n"
"MIIEjTCCA3WgAwIBAgIQDQd4KhM/xvmlcpbhMf/ReTANBgkqhkiG9w0BAQsFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n"
"MjAeFw0xNzExMDIxMjIzMzdaFw0yNzExMDIxMjIzMzdaMGAxCzAJBgNVBAYTAlVT\n"
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n"
"b20xHzAdBgNVBAMTFkdlb1RydXN0IFRMUyBSU0EgQ0EgRzEwggEiMA0GCSqGSIb3\n"
"DQEBAQUAA4IBDwAwggEKAoIBAQC+F+jsvikKy/65LWEx/TMkCDIuWegh1Ngwvm4Q\n"
"yISgP7oU5d79eoySG3vOhC3w/3jEMuipoH1fBtp7m0tTpsYbAhch4XA7rfuD6whU\n"
"gajeErLVxoiWMPkC/DnUvbgi74BJmdBiuGHQSd7LwsuXpTEGG9fYXcbTVN5SATYq\n"
"DfbexbYxTMwVJWoVb6lrBEgM3gBBqiiAiy800xu1Nq07JdCIQkBsNpFtZbIZhsDS\n"
"fzlGWP4wEmBQ3O67c+ZXkFr2DcrXBEtHam80Gp2SNhou2U5U7UesDL/xgLK6/0d7\n"
"6TnEVMSUVJkZ8VeZr+IUIlvoLrtjLbqugb0T3OYXW+CQU0kBAgMBAAGjggFAMIIB\n"
"PDAdBgNVHQ4EFgQUlE/UXYvkpOKmgP792PkA76O+AlcwHwYDVR0jBBgwFoAUTiJU\n"
"IBiV5uNu5g/6+rkS7QYXjzkwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsG\n"
"AQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDQGCCsGAQUFBwEB\n"
"BCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMEIGA1Ud\n"
"HwQ7MDkwN6A1oDOGMWh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEds\n"
"b2JhbFJvb3RHMi5jcmwwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEW\n"
"HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwDQYJKoZIhvcNAQELBQADggEB\n"
"AIIcBDqC6cWpyGUSXAjjAcYwsK4iiGF7KweG97i1RJz1kwZhRoo6orU1JtBYnjzB\n"
"c4+/sXmnHJk3mlPyL1xuIAt9sMeC7+vreRIF5wFBC0MCN5sbHwhNN1JzKbifNeP5\n"
"ozpZdQFmkCo+neBiKR6HqIA+LMTMCMMuv2khGGuPHmtDze4GmEGZtYLyF8EQpa5Y\n"
"jPuV6k2Cr/N3XxFpT3hRpt/3usU/Zb9wfKPtWpoznZ4/44c1p9rzFcZYrWkj3A+7\n"
"TNBJE0GmP2fhXhP1D/XVfIW/h0yCJGEiV9Glm/uGOa3DXHlmbAcxSyCRraG+ZBkA\n"
"7h4SeM6Y8l/7MBRpPCz6l8Y=\n"
"-----END CERTIFICATE-----\n";
}; };
#endif // ESP32 #endif // ESP32

View file

@ -21,13 +21,9 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char *user, const char *key,
: AdafruitIO(user, key) { : AdafruitIO(user, key) {
_ssid = ssid; _ssid = ssid;
_pass = pass; _pass = pass;
// Uncomment the following lines and remove the existing WiFiClient and MQTT _client = new WiFiClientSecure;
// client constructors to use Secure MQTT with ESP8266. _client->setFingerprint(AIO_SSL_FINGERPRINT);
// _client = new WiFiClientSecure; _mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
// _client->setFingerprint(AIO_SSL_FINGERPRINT);
// _mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
_client = new WiFiClient;
_mqtt = new Adafruit_MQTT_Client(_client, _host, 1883);
_http = new HttpClient(*_client, _host, _http_port); _http = new HttpClient(*_client, _host, _http_port);
} }

View file

@ -22,17 +22,7 @@
#include "Adafruit_MQTT_Client.h" #include "Adafruit_MQTT_Client.h"
#include "Arduino.h" #include "Arduino.h"
#include "ESP8266WiFi.h" #include "ESP8266WiFi.h"
/* NOTE - Projects that require "Secure MQTT" (TLS/SSL) also require a new #include "WiFiClientSecure.h"
* SSL certificate every year. If adding Secure MQTT to your ESP8266 project is
* important - please switch to using the modern ESP32 (and related models)
* instead of the ESP8266 to avoid updating the SSL fingerprint every year.
*
* If you've read through this and still want to use "Secure MQTT" with your
* ESP8266 project, we've left the "WiFiClientSecure" lines commented out. To
* use them, uncomment the commented out lines within `AdafruitIO_ESP8266.h` and
* `AdafruitIO_ESP8266.cpp` and recompile the library.
*/
// #include "WiFiClientSecure.h"
class AdafruitIO_ESP8266 : public AdafruitIO { class AdafruitIO_ESP8266 : public AdafruitIO {
@ -50,10 +40,7 @@ protected:
const char *_ssid; const char *_ssid;
const char *_pass; const char *_pass;
WiFiClient *_client; WiFiClientSecure *_client;
// Uncomment the following line, and remove the line above, to use
// secure MQTT with ESP8266.
// WiFiClientSecure *_client;
}; };
#endif // ESP8266 #endif // ESP8266

View file

@ -1,83 +0,0 @@
/*!
* @file AdafruitIO_MKR1010.h
*
* Adafruit invests time and resources providing this open source code.
* Please support Adafruit and open source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) 2015-2016 Adafruit Industries
* Authors: David Goldstein, Morgan Winters
* Licensed under the MIT license.
*
* All text above must be included in any redistribution.
*/
#ifndef ADAFRUITIO_MKR1010_H
#define ADAFRUITIO_MKR1010_H
#include "AdafruitIO.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Arduino.h"
#include "SPI.h"
#include "WiFiNINA.h"
#include "WiFiSSLClient.h"
class AdafruitIO_MKR1010 : public AdafruitIO {
public:
AdafruitIO_MKR1010(const char *user, const char *key, const char *ssid,
const char *pass)
: AdafruitIO(user, key) {
_ssid = ssid;
_pass = pass;
_client = new WiFiSSLClient;
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
_http = new HttpClient(*_client, _host, _http_port);
}
~AdafruitIO_MKR1010() {
if (_client)
delete _client;
if (_mqtt)
delete _mqtt;
}
aio_status_t networkStatus() {
switch (WiFi.status()) {
case WL_CONNECTED:
return AIO_NET_CONNECTED;
case WL_CONNECT_FAILED:
return AIO_NET_CONNECT_FAILED;
case WL_IDLE_STATUS:
return AIO_IDLE;
default:
return AIO_NET_DISCONNECTED;
}
}
const char *connectionType() { return "wifi"; }
protected:
void _connect() {
if (strlen(_ssid) == 0) {
_status = AIO_SSID_INVALID;
} else {
_disconnect();
WiFi.begin(_ssid, _pass);
_status = networkStatus();
}
}
void _disconnect() {
WiFi.disconnect();
delay(AIO_NET_DISCONNECT_WAIT);
}
const char *_ssid;
const char *_pass;
WiFiSSLClient *_client;
};
#endif ADAFRUITIO_MKR1010_H

View file

@ -1,167 +0,0 @@
/*!
* @file AdafruitIO_RP2040.h
*
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright 2024 Brent Rubell for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef ADAFRUITIO_RP2040_H
#define ADAFRUITIO_RP2040_H
#ifdef ARDUINO_ARCH_RP2040
#include "AdafruitIO.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Arduino.h"
#include <WiFiClientSecure.h>
/****************************************************************************/
/*!
@brief Class that stores functions for interacting with the RP2040
WiFi Client
*/
/****************************************************************************/
class AdafruitIO_RP2040 : public AdafruitIO {
public:
/**************************************************************************/
/*!
@brief Initializes the Adafruit IO class for RP2040 boards.
@param user
A reference to the Adafruit IO user, shared by AdafruitIO.
@param key
A reference to the Adafruit IO Key, shared by AdafruitIO.
@param ssid
A reference to the WiFi network SSID.
@param pass
A reference to the WiFi network password.
*/
/**************************************************************************/
AdafruitIO_RP2040(const char *user, const char *key, const char *ssid,
const char *pass)
: AdafruitIO(user, key) {
_ssid = ssid;
_pass = pass;
_mqtt_client = new WiFiClientSecure;
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
_http_client = new WiFiClientSecure;
_http = new HttpClient(*_http_client, _host, _http_port);
}
/*******************************/
/*!
@brief Class dtor
*/
/*******************************/
~AdafruitIO_RP2040() {
if (_mqtt_client)
delete _http_client;
if (_http_client)
delete _mqtt_client;
}
/********************************************************/
/*!
@brief Returns the network status of the RP2040.
@return aio_status_t
*/
/********************************************************/
aio_status_t networkStatus() {
switch (WiFi.status()) {
case WL_CONNECTED:
return AIO_NET_CONNECTED;
case WL_CONNECT_FAILED:
return AIO_NET_CONNECT_FAILED;
case WL_IDLE_STATUS:
return AIO_IDLE;
default:
return AIO_NET_DISCONNECTED;
}
}
/******************************************************************/
/*!
@brief Returns the type of network connection used by AdafruitIO.
@return RP2040
*/
/******************************************************************/
const char *connectionType() { return "RP2040"; }
protected:
const char *_ssid; ///< WiFi network SSID
const char *_pass; ///< WiFi network password
WiFiClientSecure *_http_client; ///< HTTP client
WiFiClientSecure *_mqtt_client; ///< MQTT client
const char *_aio_root_ca_prod =
"-----BEGIN CERTIFICATE-----\n"
"MIIEjTCCA3WgAwIBAgIQDQd4KhM/xvmlcpbhMf/ReTANBgkqhkiG9w0BAQsFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\n"
"MjAeFw0xNzExMDIxMjIzMzdaFw0yNzExMDIxMjIzMzdaMGAxCzAJBgNVBAYTAlVT\n"
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n"
"b20xHzAdBgNVBAMTFkdlb1RydXN0IFRMUyBSU0EgQ0EgRzEwggEiMA0GCSqGSIb3\n"
"DQEBAQUAA4IBDwAwggEKAoIBAQC+F+jsvikKy/65LWEx/TMkCDIuWegh1Ngwvm4Q\n"
"yISgP7oU5d79eoySG3vOhC3w/3jEMuipoH1fBtp7m0tTpsYbAhch4XA7rfuD6whU\n"
"gajeErLVxoiWMPkC/DnUvbgi74BJmdBiuGHQSd7LwsuXpTEGG9fYXcbTVN5SATYq\n"
"DfbexbYxTMwVJWoVb6lrBEgM3gBBqiiAiy800xu1Nq07JdCIQkBsNpFtZbIZhsDS\n"
"fzlGWP4wEmBQ3O67c+ZXkFr2DcrXBEtHam80Gp2SNhou2U5U7UesDL/xgLK6/0d7\n"
"6TnEVMSUVJkZ8VeZr+IUIlvoLrtjLbqugb0T3OYXW+CQU0kBAgMBAAGjggFAMIIB\n"
"PDAdBgNVHQ4EFgQUlE/UXYvkpOKmgP792PkA76O+AlcwHwYDVR0jBBgwFoAUTiJU\n"
"IBiV5uNu5g/6+rkS7QYXjzkwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsG\n"
"AQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDQGCCsGAQUFBwEB\n"
"BCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMEIGA1Ud\n"
"HwQ7MDkwN6A1oDOGMWh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEds\n"
"b2JhbFJvb3RHMi5jcmwwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEW\n"
"HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwDQYJKoZIhvcNAQELBQADggEB\n"
"AIIcBDqC6cWpyGUSXAjjAcYwsK4iiGF7KweG97i1RJz1kwZhRoo6orU1JtBYnjzB\n"
"c4+/sXmnHJk3mlPyL1xuIAt9sMeC7+vreRIF5wFBC0MCN5sbHwhNN1JzKbifNeP5\n"
"ozpZdQFmkCo+neBiKR6HqIA+LMTMCMMuv2khGGuPHmtDze4GmEGZtYLyF8EQpa5Y\n"
"jPuV6k2Cr/N3XxFpT3hRpt/3usU/Zb9wfKPtWpoznZ4/44c1p9rzFcZYrWkj3A+7\n"
"TNBJE0GmP2fhXhP1D/XVfIW/h0yCJGEiV9Glm/uGOa3DXHlmbAcxSyCRraG+ZBkA\n"
"7h4SeM6Y8l/7MBRpPCz6l8Y=\n"
"-----END CERTIFICATE-----\n"; ///< Root certificate for io.adafruit.com
/**************************************************************************/
/*!
@brief Attempts to establish a WiFi connection with the wireless network,
given _ssid and _pass from the AdafruitIO_RP2040 constructor.
*/
/**************************************************************************/
void _connect() {
if (strlen(_ssid) == 0) {
Serial.println("Invalid SSID!");
_status = AIO_SSID_INVALID;
} else {
_disconnect();
delay(10000);
WiFi.mode(WIFI_STA);
WiFi.setTimeout(20000);
WiFi.begin(_ssid, _pass);
Serial.println("\nConnecting");
_status = AIO_NET_DISCONNECTED;
}
_mqtt_client->setCACert(_aio_root_ca_prod);
}
/**************************************************************************/
/*!
@brief Disconnects from the wifi network.
*/
/**************************************************************************/
void _disconnect() {
WiFi.disconnect();
delay(AIO_NET_DISCONNECT_WAIT);
}
};
#endif // ADAFRUITIO_RP2040_H
#endif // ARDUINO_ARCH_RP2040

View file

@ -129,7 +129,7 @@ protected:
_status = AIO_SSID_INVALID; _status = AIO_SSID_INVALID;
} else { } else {
_disconnect(); _disconnect();
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en); // WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en);
// no shield? bail // no shield? bail
if (WiFi.status() == WL_NO_SHIELD) { if (WiFi.status() == WL_NO_SHIELD) {