Compare commits
105 commits
blaskovicz
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f87e56290 | ||
|
|
e67e9229c6 | ||
|
|
36b88bb9da | ||
|
|
93251aaae4 | ||
|
|
ef46ac5a67 | ||
|
|
6e2de69a8e | ||
|
|
527328e376 | ||
|
|
04e52a3f2d | ||
|
|
a9a9c19531 | ||
|
|
7c3049e55b | ||
|
|
b21d7637da | ||
|
|
7f04b63811 | ||
|
|
e9867fb1d6 | ||
|
|
a76e50bc69 | ||
|
|
140f13febc | ||
|
|
0f94088d28 | ||
|
|
e1ace0ac6f | ||
|
|
2e73006040 | ||
|
|
db939d7405 | ||
|
|
4d87df2528 | ||
|
|
a2bb62a930 | ||
|
|
d06616eadf | ||
|
|
3eebc74f01 | ||
|
|
5e70cdb719 | ||
|
|
a2d84decef | ||
|
|
28fc13d597 | ||
|
|
f75cb9d14d | ||
|
|
e3c27cd196 | ||
|
|
88e85694a2 | ||
|
|
0e2cdf61f8 | ||
|
|
a770ba9357 | ||
|
|
a21c9a3999 | ||
|
|
5b33739f12 | ||
|
|
4240f3c2d9 | ||
|
|
36f3437eb8 | ||
|
|
534cbbcb54 | ||
|
|
4ac3fde145 | ||
|
|
963c452ade | ||
|
|
a47e7b9f24 | ||
|
|
ccf9875bf2 | ||
|
|
98e4941945 | ||
|
|
3cfe5b96c1 | ||
|
|
790534521b | ||
|
|
fe5050c6db | ||
|
|
fbe050e179 | ||
|
|
a00c8b20a4 | ||
|
|
f3ff8ea03a | ||
|
|
eb3379d6c5 | ||
|
|
97d093dc29 | ||
|
|
d98ea30a2c | ||
|
|
af5f7cc170 | ||
|
|
848e3eafd3 | ||
|
|
f2a63dfb72 | ||
|
|
a2b63fcca9 | ||
|
|
3aa5e6859d | ||
|
|
6fa5db5774 | ||
|
|
3750ae3c47 | ||
|
|
71b59edae8 | ||
|
|
20eaa0e49c | ||
|
|
a9bdeb34d5 | ||
|
|
126f8d0a3f | ||
|
|
d336c04b00 | ||
|
|
5ce7d66b89 | ||
|
|
bf9c3392a3 | ||
|
|
46ae1185d9 | ||
|
|
f6d762f01b | ||
|
|
d7f4bd28fb | ||
|
|
06474339c9 | ||
|
|
fe6d93d435 | ||
|
|
3e3f93f530 | ||
|
|
007e1357e3 | ||
|
|
55efac3adc | ||
|
|
28fd173425 | ||
|
|
c7d73db162 | ||
|
|
5bca6a5551 | ||
|
|
57420735ce | ||
|
|
dd3b67a7bd | ||
|
|
f36b913698 | ||
|
|
49e4453a58 | ||
|
|
6fe42e3978 | ||
|
|
3c1ab07109 | ||
|
|
59e489411a | ||
|
|
13aef07bbb | ||
|
|
15047f09b3 | ||
|
|
abe4320a12 | ||
|
|
533e82c523 | ||
|
|
605a700f69 | ||
|
|
acbaf4b454 | ||
|
|
13e24c5ef7 | ||
|
|
4031a80b3e | ||
|
|
feceacd4f6 | ||
|
|
1ee8c766da | ||
|
|
0ef372ce34 | ||
|
|
6c1cc5e81d | ||
|
|
c2d12ebf69 | ||
|
|
e9ac466f97 | ||
|
|
8570f62287 | ||
|
|
91224bc95a | ||
|
|
f7c62e9356 | ||
|
|
1df91354b2 | ||
|
|
a862fd9f73 | ||
|
|
2fb6f02742 | ||
|
|
cf8597c87d | ||
|
|
b3633cf852 | ||
|
|
2837f73511 |
89 changed files with 1115 additions and 141 deletions
13
.github/workflows/githubci.yml
vendored
13
.github/workflows/githubci.yml
vendored
|
|
@ -8,16 +8,17 @@ 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@v1
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: adafruit/ci-arduino
|
repository: adafruit/ci-arduino
|
||||||
path: ci
|
path: ci
|
||||||
|
|
@ -26,10 +27,12 @@ jobs:
|
||||||
run: bash ci/actions_install.sh
|
run: bash ci/actions_install.sh
|
||||||
|
|
||||||
|
|
||||||
# manually install WiFi
|
# manually install WiFi and HTTPClient
|
||||||
- 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 }}
|
||||||
|
|
|
||||||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015-2016 Adafruit Industries
|
Copyright (c) 2015-2021 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
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
[](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html)
|
[](https://github.com/adafruit/Adafruit_IO_Arduino/actions)[](http://adafruit.github.io/Adafruit_IO_Arduino/html/index.html)
|
||||||
|
|
||||||
[](https://discord.gg/nBQh6qu)
|
[](https://adafru.it/discord)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
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)
|
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).
|
||||||
|
|
||||||
## 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)!
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,14 @@ 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)
|
||||||
// ESP32 pinMode()
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1)
|
||||||
ledcAttachPin(LED_PIN, 1);
|
// New ESP32 LEDC API
|
||||||
ledcSetup(1, 1200, 8);
|
ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
|
||||||
|
#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
|
||||||
|
|
@ -87,12 +92,6 @@ 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
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
analogWrite(LED_PIN, reading);
|
||||||
ledcWrite(1, reading); // ESP32 analogWrite()
|
|
||||||
#else
|
|
||||||
analogWrite(LED_PIN, reading);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,20 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
|
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
|
||||||
// assign rgb pins to channels
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1)
|
||||||
ledcAttachPin(RED_PIN, 1);
|
// New ESP32 LEDC API
|
||||||
ledcAttachPin(GREEN_PIN, 2);
|
ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
|
||||||
ledcAttachPin(BLUE_PIN, 3);
|
ledcAttach(GREEN_PIN, 12000, 8);
|
||||||
// init. channels
|
ledcAttach(BLUE_PIN, 12000, 8);
|
||||||
ledcSetup(1, 12000, 8);
|
#else
|
||||||
ledcSetup(2, 12000, 8);
|
// Legacy ESP32 LEDC API
|
||||||
ledcSetup(3, 12000, 8);
|
ledcAttachPin(RED_PIN, 1);
|
||||||
|
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);
|
||||||
|
|
@ -108,14 +114,7 @@ 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
|
||||||
#if defined(ARDUINO_ARCH_ESP32) // ESP32 analogWrite
|
analogWrite(RED_PIN, 255 - data->toRed());
|
||||||
ledcWrite(1, 255 - data->toRed());
|
analogWrite(GREEN_PIN, 255 - data->toGreen());
|
||||||
ledcWrite(2, 255 - data->toGreen());
|
analogWrite(BLUE_PIN, 255 - data->toBlue());
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
1
examples/adafruitio_16_servo/.esp32.test.skip
Normal file
1
examples/adafruitio_16_servo/.esp32.test.skip
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
1
examples/adafruitio_23_ifttt/.esp32.test.skip
Normal file
1
examples/adafruitio_23_ifttt/.esp32.test.skip
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -27,6 +27,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
67
examples/adafruitio_25_schedule_trigger/config.h
Normal file
67
examples/adafruitio_25_schedule_trigger/config.h
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/************************ 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);
|
||||||
116
examples/adafruitio_26_led_btn/adafruitio_26_led_btn.ino
Normal file
116
examples/adafruitio_26_led_btn/adafruitio_26_led_btn.ino
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
67
examples/adafruitio_26_led_btn/config.h
Normal file
67
examples/adafruitio_26_led_btn/config.h
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/************************ 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);
|
||||||
1
examples/adafruitio_27_wifimanager/.esp32.test.skip
Normal file
1
examples/adafruitio_27_wifimanager/.esp32.test.skip
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
1
examples/adafruitio_27_wifimanager/.pyportal.test.skip
Normal file
1
examples/adafruitio_27_wifimanager/.pyportal.test.skip
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* 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()
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
/* 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()
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@
|
||||||
// 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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
name=Adafruit IO Arduino
|
name=Adafruit IO Arduino
|
||||||
version=3.8.0
|
version=4.3.2
|
||||||
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 the Adafruit AirLift, ESP8266, ESP32, M0 WINC1500, WICED, MKR1000, Ethernet, or FONA hardware.
|
paragraph=Arduino library to access Adafruit IO using WiFi, ethernet, or cellular.
|
||||||
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
|
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
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* @section license License
|
* @section license License
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "AdafruitIO.h"
|
#include "AdafruitIO.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_DASHBOARD_H
|
#ifndef ADAFRUITIO_DASHBOARD_H
|
||||||
|
|
|
||||||
|
|
@ -419,12 +419,7 @@ 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() {
|
char *AdafruitIO_Data::feedName() { return _feed; }
|
||||||
if (!_feed)
|
|
||||||
return (char *)"";
|
|
||||||
|
|
||||||
return _feed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -448,12 +443,7 @@ char *AdafruitIO_Data::toChar() { return _value; }
|
||||||
@return String of value.
|
@return String of value.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
String AdafruitIO_Data::toString() {
|
String AdafruitIO_Data::toString() { return String(_value); }
|
||||||
if (!_value)
|
|
||||||
return String();
|
|
||||||
|
|
||||||
return String(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -462,13 +452,9 @@ String AdafruitIO_Data::toString() {
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
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;
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
@ -494,9 +480,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -522,9 +505,6 @@ 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.
|
||||||
|
|
@ -542,9 +522,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -556,9 +533,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -570,9 +544,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -584,9 +555,6 @@ 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.
|
||||||
|
|
@ -605,9 +573,6 @@ 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);
|
||||||
|
|
@ -623,9 +588,6 @@ 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);
|
||||||
|
|
@ -641,9 +603,6 @@ 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);
|
||||||
|
|
@ -659,9 +618,6 @@ 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);
|
||||||
|
|
@ -676,11 +632,7 @@ 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, "\",");
|
||||||
|
|
@ -689,7 +641,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -873,6 +824,7 @@ 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);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_DATA_H
|
#ifndef ADAFRUITIO_DATA_H
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,16 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT 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 3 ///< Adafruit IO Arduino Major Semvar
|
#define ADAFRUITIO_VERSION_MAJOR 4 ///< Adafruit IO Arduino Major Semvar
|
||||||
#define ADAFRUITIO_VERSION_MINOR 5 ///< Adafruit IO Arduino Minor Semvar
|
#define ADAFRUITIO_VERSION_MINOR 2 ///< Adafruit IO Arduino Minor Semvar
|
||||||
#define ADAFRUITIO_VERSION_PATCH 0 ///< Adafruit IO Arduino Patch Semvar
|
#define ADAFRUITIO_VERSION_PATCH 1 ///< Adafruit IO Arduino Patch Semvar
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class AdafruitIO_Data;
|
class AdafruitIO_Data;
|
||||||
|
|
@ -119,16 +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 \
|
||||||
"59 3C 48 0A B1 8B 39 4E 0D 58 50 47 9A 13 55 60 CC A0 1D AF" ///< Latest
|
"47 D2 CB 14 DF 38 97 59 C6 65 1A 1F 3E 00 1E 53 CC A5 17 E0" ///< Latest
|
||||||
///< Adafruit IO
|
///< Adafruit IO
|
||||||
///< SSL
|
///< SSL
|
||||||
///< Fingerprint
|
///< Fingerprint
|
||||||
|
|
||||||
#define AIO_FEED_NAME_LENGTH 20 ///< Maximum length of an Adafruit IO Feed name
|
#define AIO_FEED_NAME_LENGTH \
|
||||||
|
258 ///< Maximum length of an Adafruit IO Feed: 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 \
|
||||||
150 ///< Maximum comma-separated-value length from Adafruit IO
|
AIO_FEED_NAME_LENGTH + \
|
||||||
|
4 ///< Maximum comma-separated-value length from Adafruit IO
|
||||||
|
|
||||||
/** aio_status_t offers 13 status states */
|
/** aio_status_t offers 13 status states */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_ETHERNET_H
|
#ifndef ADAFRUITIO_ETHERNET_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_FEED_H
|
#ifndef ADAFRUITIO_FEED_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_MQTT_H
|
#ifndef ADAFRUITIO_MQTT_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_TIME_H
|
#ifndef ADAFRUITIO_TIME_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_WIFI_H
|
#ifndef ADAFRUITIO_WIFI_H
|
||||||
|
|
@ -20,6 +20,11 @@
|
||||||
#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)
|
||||||
|
|
||||||
|
|
@ -46,6 +51,11 @@ 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."
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "AdafruitIO_Block.h"
|
#include "AdafruitIO_Block.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_BLOCK_H
|
#ifndef ADAFRUITIO_BLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "ChartBlock.h"
|
#include "ChartBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_CHARTBLOCK_H
|
#ifndef ADAFRUITIO_CHARTBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_COLORBLOCK_H
|
#ifndef ADAFRUITIO_COLORBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "GaugeBlock.h"
|
#include "GaugeBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_GAUGEBLOCK_H
|
#ifndef ADAFRUITIO_GAUGEBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_IMAGEBLOCK_H
|
#ifndef ADAFRUITIO_IMAGEBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "MapBlock.h"
|
#include "MapBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_MAPBLOCK_H
|
#ifndef ADAFRUITIO_MAPBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "MomentaryBlock.h"
|
#include "MomentaryBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_MOMENTARYBLOCK_H
|
#ifndef ADAFRUITIO_MOMENTARYBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "SliderBlock.h"
|
#include "SliderBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_SLIDERBLOCK_H
|
#ifndef ADAFRUITIO_SLIDERBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "StreamBlock.h"
|
#include "StreamBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_STREAMBLOCK_H
|
#ifndef ADAFRUITIO_STREAMBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "TextBlock.h"
|
#include "TextBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_TEXTBLOCK_H
|
#ifndef ADAFRUITIO_TEXTBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "ToggleBlock.h"
|
#include "ToggleBlock.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_TOGGLEBLOCK_H
|
#ifndef ADAFRUITIO_TOGGLEBLOCK_H
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "AdafruitIO_Board.h"
|
#include "AdafruitIO_Board.h"
|
||||||
|
|
@ -29,6 +29,8 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
* Written by Tony DiCola, Todd Treece for Adafruit Industries
|
||||||
*
|
*
|
||||||
* BSD license, all text here must be included in any redistribution.
|
* MIT license, all text here must be included in any redistribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef ADAFRUITIO_BOARD_H
|
#ifndef ADAFRUITIO_BOARD_H
|
||||||
|
|
|
||||||
|
|
@ -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-2016 Adafruit Industries
|
* Copyright (c) 2015-2021 Adafruit Industries
|
||||||
* Authors: Tony DiCola, Todd Treece
|
* Authors: Tony DiCola, Todd Treece, Brent Rubell
|
||||||
* 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,6 +42,7 @@ void AdafruitIO_ESP32::_connect() {
|
||||||
delay(100);
|
delay(100);
|
||||||
_status = AIO_NET_DISCONNECTED;
|
_status = AIO_NET_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
_client->setCACert(_aio_root_ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
@ -55,7 +56,6 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -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-2016 Adafruit Industries
|
* Copyright (c) 2015-2021 Adafruit Industries
|
||||||
* Authors: Tony DiCola, Todd Treece
|
* Authors: Tony DiCola, Todd Treece, Brent Rubell
|
||||||
* 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,6 +42,36 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,13 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char *user, const char *key,
|
||||||
: AdafruitIO(user, key) {
|
: AdafruitIO(user, key) {
|
||||||
_ssid = ssid;
|
_ssid = ssid;
|
||||||
_pass = pass;
|
_pass = pass;
|
||||||
_client = new WiFiClientSecure;
|
// Uncomment the following lines and remove the existing WiFiClient and MQTT
|
||||||
_client->setFingerprint(AIO_SSL_FINGERPRINT);
|
// client constructors to use Secure MQTT with ESP8266.
|
||||||
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
|
// _client = new WiFiClientSecure;
|
||||||
|
// _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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,17 @@
|
||||||
#include "Adafruit_MQTT_Client.h"
|
#include "Adafruit_MQTT_Client.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "ESP8266WiFi.h"
|
#include "ESP8266WiFi.h"
|
||||||
#include "WiFiClientSecure.h"
|
/* NOTE - Projects that require "Secure MQTT" (TLS/SSL) also require a new
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
|
@ -40,7 +50,10 @@ protected:
|
||||||
|
|
||||||
const char *_ssid;
|
const char *_ssid;
|
||||||
const char *_pass;
|
const char *_pass;
|
||||||
WiFiClientSecure *_client;
|
WiFiClient *_client;
|
||||||
|
// Uncomment the following line, and remove the line above, to use
|
||||||
|
// secure MQTT with ESP8266.
|
||||||
|
// WiFiClientSecure *_client;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
|
|
||||||
83
src/wifi/AdafruitIO_MKR1010.h
Normal file
83
src/wifi/AdafruitIO_MKR1010.h
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*!
|
||||||
|
* @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
|
||||||
167
src/wifi/AdafruitIO_RP2040.h
Normal file
167
src/wifi/AdafruitIO_RP2040.h
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*!
|
||||||
|
* @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
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue