Skip to content

Commit 88a2238

Browse files
committed
fix issues while compiling for WiFi devices (including portenta H7)
1 parent 6b5f580 commit 88a2238

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.25.2
2+
3+
- Fix Compiling on WiFi devices without WiFi.begin() support after adding the WebConfig compatibility on ESP32.
4+
- Fix PORTENTA H7 compiling issue: does not implement WiFi.begin(SSID).
5+
16
2.25.1
27

38
- Fix ESP32 Webconfig issue

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=thinger.io
2-
version=2.25.1
2+
version=2.25.2
33
author=Alvaro Luis Bustamante <alvarolb@thinger.io>
44
maintainer=Thinger.io <admin@thinger.io>
55
sentence=Arduino library for the Thinger.io Internet of Things Platform.

src/ThingerWifi.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ class ThingerWifiClient : public ThingerClient {
3131

3232
public:
3333
ThingerWifiClient(const char* user, const char* device, const char* device_credential) :
34-
ThingerClient(client_, user, device, device_credential),
35-
wifi_ssid_(NULL),
36-
wifi_password_(NULL)
34+
ThingerClient(client_, user, device, device_credential)
3735
{}
3836

3937
~ThingerWifiClient(){
@@ -48,15 +46,23 @@ class ThingerWifiClient : public ThingerClient {
4846

4947
virtual bool connect_network(){
5048
unsigned long wifi_timeout = millis();
51-
THINGER_DEBUG_VALUE("NETWORK", "Connecting to network ", wifi_ssid_);
5249

53-
if(wifi_password_!=NULL){
50+
if(wifi_ssid_!=nullptr){
51+
THINGER_DEBUG_VALUE("NETWORK", "Connecting to network ", wifi_ssid_);
5452
WiFi.begin((char*)wifi_ssid_, (char*) wifi_password_);
55-
}else if(wifi_ssid_!=NULL){
56-
WiFi.begin((char*)wifi_ssid_);
57-
}else{
53+
}
54+
// espressif esp8266 and esp32 can connect to last network just with begin() (used with WiFiManager)
55+
#if defined(ESP8266) || defined(ESP32)
56+
else{
57+
THINGER_DEBUG("NETWORK", "Connecting to stored network");
5858
WiFi.begin();
5959
}
60+
#else
61+
else{
62+
THINGER_DEBUG("NETWORK", "Cannot connect to WiFi. SSID not set!");
63+
return false;
64+
}
65+
#endif
6066

6167
while( WiFi.status() != WL_CONNECTED) {
6268
if(millis() - wifi_timeout > 30000) return false;
@@ -80,16 +86,16 @@ class ThingerWifiClient : public ThingerClient {
8086

8187
public:
8288

83-
void add_wifi(const char* ssid, const char* password=NULL)
89+
void add_wifi(const char* ssid, const char* password=nullptr)
8490
{
8591
wifi_ssid_ = ssid;
8692
wifi_password_ = password;
8793
}
8894

8995
protected:
9096
Client client_;
91-
const char* wifi_ssid_;
92-
const char* wifi_password_;
97+
const char* wifi_ssid_ = nullptr;
98+
const char* wifi_password_ = nullptr;
9399
};
94100

95101
#define ThingerWifi ThingerWifiClient<WiFiClient>

0 commit comments

Comments
 (0)