Skip to content

Commit 5ee97c3

Browse files
committed
ping: add error checking
1 parent 5cc5260 commit 5ee97c3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

UNOR4USBBridge/ping.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,16 @@ ping_statistics execute_ping(const char* address, uint8_t ttl, uint8_t count) {
7070

7171
_stats.status = ping_status::RUNNING;
7272

73-
esp_ping_new_session(&ping_config, &cbs, &esp_ping_handle);
74-
esp_ping_start(esp_ping_handle);
73+
if(esp_ping_new_session(&ping_config, &cbs, &esp_ping_handle) != ESP_OK) {
74+
_stats.status = ping_status::ERROR;
75+
return _stats;
76+
}
77+
78+
if(esp_ping_start(esp_ping_handle) != ESP_OK) {
79+
_stats.status = ping_status::ERROR;
80+
esp_ping_delete_session(esp_ping_handle);
81+
return _stats;
82+
}
7583

7684
// wait for the end of ping session
7785
while(_stats.status == ping_status::RUNNING) {

0 commit comments

Comments
 (0)