Skip to content

Commit f11beae

Browse files
committed
ping: set TIMEOUT status if success count is 0
1 parent d8dfadb commit f11beae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

UNOR4USBBridge/ping.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ static void ping_timeout(esp_ping_handle_t hdl, void *args) {
2424
}
2525

2626
static void ping_end(esp_ping_handle_t hdl, void *args) {
27-
_stats.status = ping_status::SUCCESS;
2827
esp_ping_stop(hdl);
2928
esp_ping_delete_session(hdl);
29+
if(_stats.success_count == 0) {
30+
// all ping request have timed out
31+
_stats.status = ping_status::TIMEOUT;
32+
} else {
33+
// at least one ping as succeded and we can return rtt value
34+
_stats.status = ping_status::SUCCESS;
35+
}
3036
}
3137

3238
ping_statistics execute_ping(const char* address, uint8_t ttl, uint8_t count) {

0 commit comments

Comments
 (0)