Skip to content

Commit ed94f9d

Browse files
committed
ping: fix timeout in case of count > 1
1 parent a4da4b6 commit ed94f9d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libraries/WiFiS3/src/WiFi.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,13 @@ int CWifi::ping(const char* host, uint8_t ttl, uint8_t count) {
569569
/* -------------------------------------------------------------------------- */
570570
int ret = WL_PING_ERROR;
571571
modem.begin();
572+
/* ping timeout is 1s and interval another 1s */
573+
modem.timeout((count * 2000) + MODEM_TIMEOUT);
572574
string res = "";
573575
if (modem.write(string(PROMPT(_PING)), res, "%s,%s,%d,%d\r\n", CMD_WRITE(_PING), host, ttl, count)) {
574576
ret = atoi(res.c_str());
575577
}
578+
modem.timeout(MODEM_TIMEOUT);
576579
return ret;
577580
}
578581

0 commit comments

Comments
 (0)