From 46ae1185d9671bb87ff6792f8afa270dd46f9023 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 10:20:13 -0400 Subject: [PATCH 01/11] remove fingerprint check --- src/wifi/AdafruitIO_ESP8266.cpp | 5 ++--- src/wifi/AdafruitIO_ESP8266.h | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wifi/AdafruitIO_ESP8266.cpp b/src/wifi/AdafruitIO_ESP8266.cpp index 3def7d28..4b5aef2e 100644 --- a/src/wifi/AdafruitIO_ESP8266.cpp +++ b/src/wifi/AdafruitIO_ESP8266.cpp @@ -21,9 +21,8 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char *user, const char *key, : AdafruitIO(user, key) { _ssid = ssid; _pass = pass; - _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); } diff --git a/src/wifi/AdafruitIO_ESP8266.h b/src/wifi/AdafruitIO_ESP8266.h index c90ce8d1..78b07991 100644 --- a/src/wifi/AdafruitIO_ESP8266.h +++ b/src/wifi/AdafruitIO_ESP8266.h @@ -22,7 +22,6 @@ #include "Adafruit_MQTT_Client.h" #include "Arduino.h" #include "ESP8266WiFi.h" -#include "WiFiClientSecure.h" class AdafruitIO_ESP8266 : public AdafruitIO { @@ -40,7 +39,7 @@ class AdafruitIO_ESP8266 : public AdafruitIO { const char *_ssid; const char *_pass; - WiFiClientSecure *_client; + WiFiClient *_client; }; #endif // ESP8266 From bf9c3392a33043e7f3c4693fc2a7e52fe6e5253c Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 10:32:39 -0400 Subject: [PATCH 02/11] comments --- src/wifi/AdafruitIO_ESP8266.cpp | 5 +++++ src/wifi/AdafruitIO_ESP8266.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/wifi/AdafruitIO_ESP8266.cpp b/src/wifi/AdafruitIO_ESP8266.cpp index 4b5aef2e..ac3e2b19 100644 --- a/src/wifi/AdafruitIO_ESP8266.cpp +++ b/src/wifi/AdafruitIO_ESP8266.cpp @@ -21,6 +21,11 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char *user, const char *key, : AdafruitIO(user, key) { _ssid = ssid; _pass = pass; + // Uncomment the following lines and remove the existing WiFiClient and MQTT + // client constructors to use Secure MQTT with ESP8266. + // _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); diff --git a/src/wifi/AdafruitIO_ESP8266.h b/src/wifi/AdafruitIO_ESP8266.h index 78b07991..e4be20af 100644 --- a/src/wifi/AdafruitIO_ESP8266.h +++ b/src/wifi/AdafruitIO_ESP8266.h @@ -22,6 +22,17 @@ #include "Adafruit_MQTT_Client.h" #include "Arduino.h" #include "ESP8266WiFi.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 { @@ -40,6 +51,9 @@ class AdafruitIO_ESP8266 : public AdafruitIO { const char *_ssid; const char *_pass; WiFiClient *_client; + // Uncomment the following line, and remove the line above, to use + // secure MQTT with ESP8266. + // WiFiClientSecure *_client; }; #endif // ESP8266 From 5ce7d66b89440aca81af7893256ece466bcadeea Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 10:46:40 -0400 Subject: [PATCH 03/11] fix multi-line comment error on esp32 --- src/AdafruitIO_Definitions.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AdafruitIO_Definitions.h b/src/AdafruitIO_Definitions.h index b1dfdf0e..512f3877 100644 --- a/src/AdafruitIO_Definitions.h +++ b/src/AdafruitIO_Definitions.h @@ -125,14 +125,14 @@ class AdafruitIOGroupCallback { ///< Fingerprint #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. + 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 \ 45 ///< Maximum length of data sent/recieved from Adafruit IO #define AIO_CSV_LENGTH \ - AIO_FEED_NAME_LENGTH + 4 ///< 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 */ typedef enum { From d336c04b00d380778a57099087da825fb85bdfd6 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 11:04:40 -0400 Subject: [PATCH 04/11] fix gcc esp32 --- src/AdafruitIO_Data.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AdafruitIO_Data.cpp b/src/AdafruitIO_Data.cpp index 208edcc7..53f4fa24 100644 --- a/src/AdafruitIO_Data.cpp +++ b/src/AdafruitIO_Data.cpp @@ -873,6 +873,7 @@ char **parse_csv(const char *line) { continue; case '\0': fEnd = 1; + continue; case ',': *tptr = '\0'; *bptr = strdup(tmp); From 126f8d0a3f6e1d307a0f5dc8047883a6a78c5105 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 11:09:47 -0400 Subject: [PATCH 05/11] use httpclient for esp32? --- library.properties | 2 +- src/AdafruitIO.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 395e234e..126bb5fd 100644 --- a/library.properties +++ b/library.properties @@ -7,4 +7,4 @@ paragraph=Arduino library to access Adafruit IO using the Adafruit AirLift, ESP8 category=Communication url=https://github.com/adafruit/Adafruit_IO_Arduino 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, HTTPClient, Adafruit Unified Sensor, Adafruit NeoPixel, DHT sensor library, Ethernet, Adafruit Si7021 Library, Adafruit SGP30 Sensor, Adafruit BME280 Library, Adafruit LIS3DH, Adafruit VEML6070 Library, ESP32Servo diff --git a/src/AdafruitIO.h b/src/AdafruitIO.h index 6d8bd276..544d5b3f 100644 --- a/src/AdafruitIO.h +++ b/src/AdafruitIO.h @@ -24,7 +24,13 @@ #include "AdafruitIO_Time.h" #include "Adafruit_MQTT.h" #include "Arduino.h" +#if defined ARDUINO_ARCH_ESP32 +// use HTTP Client for ESP32 +#include "HTTPClient.h" +#else +// use generic HTTP client for Arduino #include "ArduinoHttpClient.h" +#endif #include "util/AdafruitIO_Board.h" #ifndef ADAFRUIT_MQTT_VERSION_MAJOR From a9bdeb34d534ad10f7eb4b5d3b33809c061a2b2f Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 11:28:45 -0400 Subject: [PATCH 06/11] use proper HTTPClient object for ESP32 --- src/AdafruitIO.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AdafruitIO.h b/src/AdafruitIO.h index 544d5b3f..bf7b9de0 100644 --- a/src/AdafruitIO.h +++ b/src/AdafruitIO.h @@ -148,7 +148,11 @@ class AdafruitIO { Adafruit IO, in milliseconds */ Adafruit_MQTT *_mqtt; /*!< Reference to Adafruit_MQTT, _mqtt. */ - HttpClient *_http; /*!< Reference to HTTPClient, _http */ + #if defined ARDUINO_ARCH_ESP32 + HTTPClient *_http; /*!< Reference to ESP32 HTTPClient, _http */ + #else + HttpClient *_http; /*!< Reference to HTTPClient, _http */ + #endif char _version[10]; /*!< Adafruit IO Arduino library version */ From 20eaa0e49c655eff5f6124b02bb9fb9cdf96e982 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 13:16:25 -0400 Subject: [PATCH 07/11] remove HTTPClient for esp32 --- library.properties | 2 +- src/AdafruitIO.h | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/library.properties b/library.properties index 126bb5fd..395e234e 100644 --- a/library.properties +++ b/library.properties @@ -7,4 +7,4 @@ paragraph=Arduino library to access Adafruit IO using the Adafruit AirLift, ESP8 category=Communication url=https://github.com/adafruit/Adafruit_IO_Arduino architectures=* -depends=Adafruit MQTT Library, ArduinoHttpClient, HTTPClient, 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 diff --git a/src/AdafruitIO.h b/src/AdafruitIO.h index bf7b9de0..6d8bd276 100644 --- a/src/AdafruitIO.h +++ b/src/AdafruitIO.h @@ -24,13 +24,7 @@ #include "AdafruitIO_Time.h" #include "Adafruit_MQTT.h" #include "Arduino.h" -#if defined ARDUINO_ARCH_ESP32 -// use HTTP Client for ESP32 -#include "HTTPClient.h" -#else -// use generic HTTP client for Arduino #include "ArduinoHttpClient.h" -#endif #include "util/AdafruitIO_Board.h" #ifndef ADAFRUIT_MQTT_VERSION_MAJOR @@ -148,11 +142,7 @@ class AdafruitIO { Adafruit IO, in milliseconds */ Adafruit_MQTT *_mqtt; /*!< Reference to Adafruit_MQTT, _mqtt. */ - #if defined ARDUINO_ARCH_ESP32 - HTTPClient *_http; /*!< Reference to ESP32 HTTPClient, _http */ - #else - HttpClient *_http; /*!< Reference to HTTPClient, _http */ - #endif + HttpClient *_http; /*!< Reference to HTTPClient, _http */ char _version[10]; /*!< Adafruit IO Arduino library version */ From 71b59edae8dba614cd7f1f5f4700c800ef742bbb Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 13:40:50 -0400 Subject: [PATCH 08/11] use our fork? --- .github/workflows/githubci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 5c1a0e61..849c799d 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -26,10 +26,12 @@ jobs: run: bash ci/actions_install.sh - # manually install WiFi + # manually install WiFi and HTTPClient - name: extra libraries run: | 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/brentru/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient - name: test platforms run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} From 3750ae3c47bef7db89e42ccba1ccf6dee4df5a2e Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 13:46:05 -0400 Subject: [PATCH 09/11] use official github for httpclient --- .github/workflows/githubci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 849c799d..ab5e085c 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -31,7 +31,7 @@ jobs: run: | 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/brentru/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient + git clone --quiet https://github.com/arduino-libraries/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient - name: test platforms run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} From 6fa5db577482ecad3030f20b51863a43c145ff43 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 13:46:47 -0400 Subject: [PATCH 10/11] docu! --- README.md | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80385841..58a25fc2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ![AIOArduino](https://cdn-learn.adafruit.com/assets/assets/000/057/496/original/adafruit_io_AIOA.png?1531335660) -This library provides a simple device independent interface for interacting with [Adafruit IO](https://io.adafruit.com) using Arduino. It allows you to switch between WiFi (ESP8266, ESP32, ESP32-S2, 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, Airlift, WINC1500, & WICED), Cellular (32u4 FONA), and Ethernet (Ethernet FeatherWing). ## Documentation diff --git a/library.properties b/library.properties index 395e234e..dd9877f7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit IO Arduino -version=4.2.0 +version=4.2.1 author=Adafruit maintainer=Adafruit sentence=Arduino library to access Adafruit IO. From 3aa5e6859d316e33544f6c6104203e3769acb489 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 9 Aug 2022 13:47:24 -0400 Subject: [PATCH 11/11] add vers --- src/AdafruitIO_Definitions.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AdafruitIO_Definitions.h b/src/AdafruitIO_Definitions.h index 512f3877..dc2cb5e5 100644 --- a/src/AdafruitIO_Definitions.h +++ b/src/AdafruitIO_Definitions.h @@ -16,9 +16,9 @@ #ifndef ADAFRUITIO_DEFINITIONS_H_ #define ADAFRUITIO_DEFINITIONS_H_ -#define ADAFRUITIO_VERSION_MAJOR 3 ///< Adafruit IO Arduino Major Semvar -#define ADAFRUITIO_VERSION_MINOR 5 ///< Adafruit IO Arduino Minor Semvar -#define ADAFRUITIO_VERSION_PATCH 0 ///< Adafruit IO Arduino Patch Semvar +#define ADAFRUITIO_VERSION_MAJOR 4 ///< Adafruit IO Arduino Major Semvar +#define ADAFRUITIO_VERSION_MINOR 2 ///< Adafruit IO Arduino Minor Semvar +#define ADAFRUITIO_VERSION_PATCH 1 ///< Adafruit IO Arduino Patch Semvar // forward declaration class AdafruitIO_Data;