From a770ba935765352405b4c4c43f52b6263ce120c3 Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 21 Apr 2023 13:08:55 -0400 Subject: [PATCH 1/3] add preproc for return types --- library.properties | 2 +- src/AdafruitIO.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/AdafruitIO.h | 6 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/library.properties b/library.properties index eceaca5..cebc1c9 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit IO Arduino -version=4.2.3 +version=4.2.4 author=Adafruit maintainer=Adafruit sentence=Arduino library to access Adafruit IO. diff --git a/src/AdafruitIO.cpp b/src/AdafruitIO.cpp index a470056..fb58372 100644 --- a/src/AdafruitIO.cpp +++ b/src/AdafruitIO.cpp @@ -243,6 +243,71 @@ AdafruitIO_Dashboard *AdafruitIO::dashboard(const char *name) { return new AdafruitIO_Dashboard(this, name); } +// due to breaking change within Arduino ESP32 BSP v2.0.8 +// see: https://github.com/espressif/arduino-esp32/pull/7941 +#ifdef ARDUINO_ARCH_ESP32 +/**************************************************************************/ +/*! + @brief Provide status explanation strings. + @return A pointer to the status string literal, _status. _status is + the AIO status value +*/ +/**************************************************************************/ +const char *AdafruitIO::statusText() { + const char *statusMsg; + switch (_status) { + + // CONNECTING + case AIO_IDLE: + statusMsg = "Idle. Waiting for connect to be called..."; + break; + case AIO_NET_DISCONNECTED: + statusMsg = "Network disconnected."; + break; + case AIO_DISCONNECTED: + statusMsg = "Disconnected from Adafruit IO."; + break; + + // FAILURE + case AIO_NET_CONNECT_FAILED: + statusMsg = "Network connection failed."; + break; + case AIO_CONNECT_FAILED: + statusMsg = "Adafruit IO connection failed."; + break; + case AIO_FINGERPRINT_INVALID: + statusMsg = "Adafruit IO SSL fingerprint verification failed."; + break; + case AIO_AUTH_FAILED: + statusMsg = "Adafruit IO authentication failed."; + break; + + // SUCCESS + case AIO_NET_CONNECTED: + statusMsg = "Network connected."; + break; + case AIO_CONNECTED: + statusMsg = "Adafruit IO connected."; + break; + case AIO_CONNECTED_INSECURE: + statusMsg = + "Adafruit IO connected. **THIS CONNECTION IS INSECURE** SSL/TLS " + "not supported for this platform."; + break; + case AIO_FINGERPRINT_UNSUPPORTED: + statusMsg = "Adafruit IO connected over SSL/TLS. Fingerprint verification " + "unsupported."; + break; + case AIO_FINGERPRINT_VALID: + statusMsg = "Adafruit IO connected over SSL/TLS. Fingerprint valid."; + break; + default: + statusMsg = "Unknown status code"; + break; + } + return statusMsg; +} +#else /**************************************************************************/ /*! @brief Provide status explanation strings. @@ -289,6 +354,7 @@ const __FlashStringHelper *AdafruitIO::statusText() { return F("Unknown status code"); } } +#endif /**************************************************************************/ /*! diff --git a/src/AdafruitIO.h b/src/AdafruitIO.h index 6d8bd27..26c9cea 100644 --- a/src/AdafruitIO.h +++ b/src/AdafruitIO.h @@ -87,7 +87,13 @@ class AdafruitIO { AdafruitIO_Dashboard *dashboard(const char *name); AdafruitIO_Time *time(aio_time_format_t format); +// due to breaking change within Arduino ESP32 BSP v2.0.8 +// see: https://github.com/espressif/arduino-esp32/pull/7941 +#ifdef ARDUINO_ARCH_ESP32 + const char *statusText(); +#else const __FlashStringHelper *statusText(); +#endif; aio_status_t status(); /********************************************************************/ From 0e2cdf61f8ca5b8f028d57c45103f8fabe37920f Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 21 Apr 2023 13:49:40 -0400 Subject: [PATCH 2/3] fix ; at end of ifdef? --- src/AdafruitIO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AdafruitIO.h b/src/AdafruitIO.h index 26c9cea..665810a 100644 --- a/src/AdafruitIO.h +++ b/src/AdafruitIO.h @@ -93,7 +93,7 @@ class AdafruitIO { const char *statusText(); #else const __FlashStringHelper *statusText(); -#endif; +#endif aio_status_t status(); /********************************************************************/ From 88e85694a224e895ff6008a02bb016773ed4adb6 Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 21 Apr 2023 15:41:49 -0400 Subject: [PATCH 3/3] match https://github.com/adafruit/Adafruit_MQTT_Library/pull/222/commits/a94f4d512e966718f466d4b97ecb129a67e38347 --- src/AdafruitIO.cpp | 55 +--------------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/src/AdafruitIO.cpp b/src/AdafruitIO.cpp index fb58372..f3b4ac5 100644 --- a/src/AdafruitIO.cpp +++ b/src/AdafruitIO.cpp @@ -254,59 +254,6 @@ AdafruitIO_Dashboard *AdafruitIO::dashboard(const char *name) { */ /**************************************************************************/ const char *AdafruitIO::statusText() { - const char *statusMsg; - switch (_status) { - - // CONNECTING - case AIO_IDLE: - statusMsg = "Idle. Waiting for connect to be called..."; - break; - case AIO_NET_DISCONNECTED: - statusMsg = "Network disconnected."; - break; - case AIO_DISCONNECTED: - statusMsg = "Disconnected from Adafruit IO."; - break; - - // FAILURE - case AIO_NET_CONNECT_FAILED: - statusMsg = "Network connection failed."; - break; - case AIO_CONNECT_FAILED: - statusMsg = "Adafruit IO connection failed."; - break; - case AIO_FINGERPRINT_INVALID: - statusMsg = "Adafruit IO SSL fingerprint verification failed."; - break; - case AIO_AUTH_FAILED: - statusMsg = "Adafruit IO authentication failed."; - break; - - // SUCCESS - case AIO_NET_CONNECTED: - statusMsg = "Network connected."; - break; - case AIO_CONNECTED: - statusMsg = "Adafruit IO connected."; - break; - case AIO_CONNECTED_INSECURE: - statusMsg = - "Adafruit IO connected. **THIS CONNECTION IS INSECURE** SSL/TLS " - "not supported for this platform."; - break; - case AIO_FINGERPRINT_UNSUPPORTED: - statusMsg = "Adafruit IO connected over SSL/TLS. Fingerprint verification " - "unsupported."; - break; - case AIO_FINGERPRINT_VALID: - statusMsg = "Adafruit IO connected over SSL/TLS. Fingerprint valid."; - break; - default: - statusMsg = "Unknown status code"; - break; - } - return statusMsg; -} #else /**************************************************************************/ /*! @@ -316,6 +263,7 @@ const char *AdafruitIO::statusText() { */ /**************************************************************************/ const __FlashStringHelper *AdafruitIO::statusText() { +#endif switch (_status) { // CONNECTING @@ -354,7 +302,6 @@ const __FlashStringHelper *AdafruitIO::statusText() { return F("Unknown status code"); } } -#endif /**************************************************************************/ /*!