Skip to content

Commit 65b62d7

Browse files
WiFi clients: connection lost issue
When a client looses connection the client needs to be stopped before calling connect again
1 parent e0b9acf commit 65b62d7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: libraries/WiFiS3/src/WiFiClient.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ uint8_t WiFiClient::connected() {
227227
if(modem.write(string(PROMPT(_CLIENTCONNECTED)),res, "%s%d\r\n" , CMD_WRITE(_CLIENTCONNECTED), _sock)) {
228228
rv = atoi(res.c_str());
229229
}
230+
231+
if(rv == 0) {
232+
// if sock >= 0 -> it means we were connected, but something happened and we need
233+
// to reset this socket in order to be able to connect again
234+
stop();
235+
}
230236
}
231237

232238
modem.noDebug();

Diff for: libraries/WiFiS3/src/WiFiSSLClient.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ uint8_t WiFiSSLClient::connected() {
240240
if(modem.write(string(PROMPT(_SSLCLIENTCONNECTED)),res, "%s%d\r\n" , CMD_WRITE(_SSLCLIENTCONNECTED), _sock)) {
241241
rv = atoi(res.c_str());
242242
}
243+
244+
if(rv == 0) {
245+
// if sock >= 0 -> it means we were connected, but something happened and we need
246+
// to reset this socket in order to be able to connect again
247+
stop();
248+
}
243249
}
244250
return rv;
245251
}

0 commit comments

Comments
 (0)