Skip to content

Commit c22f644

Browse files
committed
WiFiS3: add timeout check on localIP()
1 parent 7e83b8b commit c22f644

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

libraries/WiFiS3/src/WiFi.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ IPAddress CWifi::localIP() {
329329
/* -------------------------------------------------------------------------- */
330330
modem.begin();
331331
string res = "";
332-
int attempts = 0;
333332
IPAddress local_IP(0,0,0,0);
334333

334+
unsigned long start_time = millis();
335335
do {
336336
delay(100);
337337
if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) {
@@ -349,9 +349,8 @@ IPAddress CWifi::localIP() {
349349
}
350350
}
351351
}
352-
attempts++;
353352
}
354-
while(local_IP == IPAddress(0,0,0,0) && attempts < 50);
353+
while((local_IP == IPAddress(0,0,0,0)) && (millis() - start_time < _timeout));
355354

356355
return local_IP;
357356
}

0 commit comments

Comments
 (0)