From f34c2c97851b4c70095f83e818c9eb715247f828 Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Mon, 14 Jun 2021 14:47:48 +0200 Subject: [PATCH 1/5] Adjustments for new version of ESP8266 board (3.0.0) --- src/SuplaDevice.cpp | 2 +- src/supla/network/esp_wifi.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SuplaDevice.cpp b/src/SuplaDevice.cpp index cc5566c..6b3b820 100644 --- a/src/SuplaDevice.cpp +++ b/src/SuplaDevice.cpp @@ -247,7 +247,7 @@ void SuplaDeviceClass::iterate(void) { if (!isInitialized(false)) return; unsigned long _millis = millis(); - unsigned long timeDiff = abs(_millis - lastIterateTime); + unsigned long timeDiff = _millis - lastIterateTime; uptime.iterate(_millis); diff --git a/src/supla/network/esp_wifi.h b/src/supla/network/esp_wifi.h index 18f2561..39c2914 100644 --- a/src/supla/network/esp_wifi.h +++ b/src/supla/network/esp_wifi.h @@ -135,14 +135,16 @@ class ESPWifi : public Supla::Network { bool result = client->connect(server, connectionPort); - if (result && isSecured) { + // ESP8266 boards 3.0.0 onward do fingerprint check in connect() method. + /*if (result && isSecured) { if (!((WiFiClientSecure *)client)->verify(fingerprint.c_str(), server)) { supla_log(LOG_DEBUG, "Provided certificates doesn't match!"); client->stop(); return false; } }; - + */ + return result; } From 9a0a5398f7650ddf9fd847ef7c6d0f1fcf8c2d4f Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Mon, 14 Jun 2021 14:51:22 +0200 Subject: [PATCH 2/5] Updated gtest version --- extras/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/test/CMakeLists.txt b/extras/test/CMakeLists.txt index a715ac5..920d3c7 100644 --- a/extras/test/CMakeLists.txt +++ b/extras/test/CMakeLists.txt @@ -23,7 +23,7 @@ include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.10.0 + GIT_TAG origin/master ) FetchContent_GetProperties(googletest) From c163148972d14a88e6c1b1e0378f834afaaae4e1 Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Mon, 14 Jun 2021 14:56:40 +0200 Subject: [PATCH 3/5] Added comment to use ASCII only in device name --- src/SuplaDevice.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SuplaDevice.h b/src/SuplaDevice.h index 8cd7580..cb8c8a4 100644 --- a/src/SuplaDevice.h +++ b/src/SuplaDevice.h @@ -95,7 +95,9 @@ class SuplaDeviceClass { bool begin(unsigned char version = 12); + // Use ASCII only in name void setName(const char *Name); + void setGUID(char GUID[SUPLA_GUID_SIZE]); void setAuthKey(char authkey[SUPLA_AUTHKEY_SIZE]); void setEmail(const char *email); From e9d5f896b9d9fd15ba2b836b97e1204234a0f95e Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Tue, 15 Jun 2021 09:14:20 +0200 Subject: [PATCH 4/5] Fixed bug with casting to Secure client on not secured one (causing crash) --- src/supla/network/esp_wifi.h | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/supla/network/esp_wifi.h b/src/supla/network/esp_wifi.h index 39c2914..45bddf4 100644 --- a/src/supla/network/esp_wifi.h +++ b/src/supla/network/esp_wifi.h @@ -51,8 +51,7 @@ class ESPWifi : public Supla::Network { setSsid(wifiSsid); setPassword(wifiPassword); #ifdef ARDUINO_ARCH_ESP32 - enableSSL( - false); // current ESP32 WiFiClientSecure does not suport "setInsecure" + enableSSL(false); // ESP32 WiFiClientSecure does not suport "setInsecure" #endif } @@ -96,22 +95,19 @@ class ESPWifi : public Supla::Network { if (client == NULL) { if (isSecured) { message = "Secured connection"; - client = new WiFiClientSecure(); + auto clientSec = new WiFiClientSecure(); + client = clientSec; + +#ifdef ARDUINO_ARCH_ESP8266 + clientSec->setBufferSizes(2048, 512); // EXPERIMENTAL if (fingerprint.length() > 0) { message += " with certificate matching"; -#ifdef ARDUINO_ARCH_ESP8266 - ((WiFiClientSecure *)client)->setFingerprint(fingerprint.c_str()); -#else - message += " - NOT SUPPORTED ON ESP32 implmentation"; -#endif + clientSec->setFingerprint(fingerprint.c_str()); } else { message += " without certificate matching"; -#ifdef ARDUINO_ARCH_ESP8266 - ((WiFiClientSecure *)client)->setInsecure(); -#else - message += " - NOT SUPPORTED ON ESP32 implmentation"; -#endif + clientSec->setInsecure(); } +#endif } else { message = "unsecured connection"; client = new WiFiClient(); @@ -129,22 +125,8 @@ class ESPWifi : public Supla::Network { server, connectionPort); -#ifdef ARDUINO_ARCH_ESP8266 - static_cast(client)->setBufferSizes(2048, 512); // EXPERIMENTAL -#endif - bool result = client->connect(server, connectionPort); - // ESP8266 boards 3.0.0 onward do fingerprint check in connect() method. - /*if (result && isSecured) { - if (!((WiFiClientSecure *)client)->verify(fingerprint.c_str(), server)) { - supla_log(LOG_DEBUG, "Provided certificates doesn't match!"); - client->stop(); - return false; - } - }; - */ - return result; } From 026fb93df11ce8d82ee1013f1d2797c63a04ff17 Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Tue, 15 Jun 2021 11:11:55 +0200 Subject: [PATCH 5/5] Version increment -> 2.3.5 --- library.properties | 2 +- src/SuplaDevice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index f0b91c7..a1ac53d 100644 --- a/library.properties +++ b/library.properties @@ -5,7 +5,7 @@ sentence=Library enables you to connect the device to the SUPLA automation syste paragraph=It provides easy interface for adding various sensors, relays, buttons, roller shutters, etc. that can be controlled via SUPLA Cloud and application on mobile device. url=https://github.com/SUPLA/supla-arduino architectures=avr,esp32,esp8266 -version=2.3.4 +version=2.3.5 dependencies= core-dependencies=arduino (>=1.5.0) category=Communication diff --git a/src/SuplaDevice.cpp b/src/SuplaDevice.cpp index 6b3b820..eafbd90 100644 --- a/src/SuplaDevice.cpp +++ b/src/SuplaDevice.cpp @@ -182,7 +182,7 @@ bool SuplaDeviceClass::begin(unsigned char version) { if (strnlen(Supla::Channel::reg_dev.SoftVer, SUPLA_SOFTVER_MAXSIZE) == 0) { setString(Supla::Channel::reg_dev.SoftVer, - "User SW, lib 2.3.4", + "User SW, lib 2.3.5", SUPLA_SOFTVER_MAXSIZE); }