Skip to content

Commit ae6889d

Browse files
committed
Add timeout to ping command
1 parent c6bad87 commit ae6889d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/GPRS.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,14 @@ int GPRS::ping(const char* hostname, uint8_t ttl)
326326
return GPRS_PING_ERROR;
327327
};
328328

329-
while (_pingResult == 0) {
329+
for (unsigned long start = millis(); (millis() - start) < 5000 && (_pingResult == 0);) {
330330
MODEM.poll();
331331
}
332332

333+
if (_pingResult == 0) {
334+
_pingResult = GPRS_PING_TIMEOUT;
335+
}
336+
333337
return _pingResult;
334338
}
335339

0 commit comments

Comments
 (0)