Skip to content

Commit ce87ac4

Browse files
Merge pull request #38 from klew/master
Adjustments for ESP8266 3.0.0 Arduino boards
2 parents eb2a39f + e9d5f89 commit ce87ac4

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

extras/test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include(FetchContent)
2323
FetchContent_Declare(
2424
googletest
2525
GIT_REPOSITORY https://github.com/google/googletest.git
26-
GIT_TAG release-1.10.0
26+
GIT_TAG origin/master
2727
)
2828

2929
FetchContent_GetProperties(googletest)

src/SuplaDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void SuplaDeviceClass::iterate(void) {
247247
if (!isInitialized(false)) return;
248248

249249
unsigned long _millis = millis();
250-
unsigned long timeDiff = abs(_millis - lastIterateTime);
250+
unsigned long timeDiff = _millis - lastIterateTime;
251251

252252
uptime.iterate(_millis);
253253

src/SuplaDevice.h

+2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ class SuplaDeviceClass {
9595

9696
bool begin(unsigned char version = 12);
9797

98+
// Use ASCII only in name
9899
void setName(const char *Name);
100+
99101
void setGUID(char GUID[SUPLA_GUID_SIZE]);
100102
void setAuthKey(char authkey[SUPLA_AUTHKEY_SIZE]);
101103
void setEmail(const char *email);

src/supla/network/esp_wifi.h

+9-25
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class ESPWifi : public Supla::Network {
5151
setSsid(wifiSsid);
5252
setPassword(wifiPassword);
5353
#ifdef ARDUINO_ARCH_ESP32
54-
enableSSL(
55-
false); // current ESP32 WiFiClientSecure does not suport "setInsecure"
54+
enableSSL(false); // ESP32 WiFiClientSecure does not suport "setInsecure"
5655
#endif
5756
}
5857

@@ -96,22 +95,19 @@ class ESPWifi : public Supla::Network {
9695
if (client == NULL) {
9796
if (isSecured) {
9897
message = "Secured connection";
99-
client = new WiFiClientSecure();
98+
auto clientSec = new WiFiClientSecure();
99+
client = clientSec;
100+
101+
#ifdef ARDUINO_ARCH_ESP8266
102+
clientSec->setBufferSizes(2048, 512); // EXPERIMENTAL
100103
if (fingerprint.length() > 0) {
101104
message += " with certificate matching";
102-
#ifdef ARDUINO_ARCH_ESP8266
103-
((WiFiClientSecure *)client)->setFingerprint(fingerprint.c_str());
104-
#else
105-
message += " - NOT SUPPORTED ON ESP32 implmentation";
106-
#endif
105+
clientSec->setFingerprint(fingerprint.c_str());
107106
} else {
108107
message += " without certificate matching";
109-
#ifdef ARDUINO_ARCH_ESP8266
110-
((WiFiClientSecure *)client)->setInsecure();
111-
#else
112-
message += " - NOT SUPPORTED ON ESP32 implmentation";
113-
#endif
108+
clientSec->setInsecure();
114109
}
110+
#endif
115111
} else {
116112
message = "unsecured connection";
117113
client = new WiFiClient();
@@ -129,20 +125,8 @@ class ESPWifi : public Supla::Network {
129125
server,
130126
connectionPort);
131127

132-
#ifdef ARDUINO_ARCH_ESP8266
133-
static_cast<WiFiClientSecure*>(client)->setBufferSizes(2048, 512); // EXPERIMENTAL
134-
#endif
135-
136128
bool result = client->connect(server, connectionPort);
137129

138-
if (result && isSecured) {
139-
if (!((WiFiClientSecure *)client)->verify(fingerprint.c_str(), server)) {
140-
supla_log(LOG_DEBUG, "Provided certificates doesn't match!");
141-
client->stop();
142-
return false;
143-
}
144-
};
145-
146130
return result;
147131
}
148132

0 commit comments

Comments
 (0)