| 28 | } |
| 29 | |
| 30 | void onSent(void* arg, void* pdata) |
| 31 | { |
| 32 | ping_resp* response = reinterpret_cast<ping_resp*>(pdata); |
| 33 | |
| 34 | if(response == nullptr) { |
| 35 | debug_e("Invalid onSent call"); |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | Serial << _F("Ping sent. Total failed attempts: ") << failedAttempts << endl; |
| 40 | if(failedAttempts / response->total_count > MAX_FAILED_ATTEMTPS) { |
| 41 | debug_d("Scheduling system restart in %d seconds.", RESTART_DELAY_SECONDS); |
| 42 | // schedule restart |
| 43 | System.restart(RESTART_DELAY_SECONDS * 1000); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | debug_d("Scheduling another ping in %d seconds", PING_INTERVAL_SECONDS); |
| 48 | procTimer.initializeMs<PING_INTERVAL_SECONDS * 1000>(pingTask).startOnce(); |
| 49 | } |
| 50 | |
| 51 | void onReceived(void* arg, void* pdata) |
| 52 | { |
no test coverage detected