diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 82c8c21d9..2be6a3e77 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -101,15 +101,25 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store /* END GLOBAL OBJECTS */ -void halt() { - while (1) ; +void delayedReboot(const char *msg, const uint32_t delayms) { + char tmp[32]; + sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0); + #ifdef DISPLAY_CLASS + display.startFrame(); + display.drawTextCentered(display.width() / 2, 24, msg); + display.drawTextCentered(display.width() / 2, 32, tmp); + display.endFrame(); + #endif + MESH_DEBUG_PRINTLN(msg); + MESH_DEBUG_PRINTLN(tmp); + delay(delayms); + board.reboot(); } void setup() { Serial.begin(115200); board.begin(); - #ifdef DISPLAY_CLASS DisplayDriver* disp = NULL; if (display.begin()) { @@ -123,7 +133,8 @@ void setup() { } #endif - if (!radio_init()) { halt(); } + if (!radio_init()) + delayedReboot("Radio Init Failed!", 5000); fast_rng.begin(radio_get_rng_seed()); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 7387e77e7..0a1e12e69 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -13,8 +13,19 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - while (1) ; +void delayedReboot(const char *msg, const uint32_t delayms) { + char tmp[32]; + sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0); + #ifdef DISPLAY_CLASS + display.startFrame(); + display.drawTextCentered(display.width() / 2, 24, msg); + display.drawTextCentered(display.width() / 2, 32, tmp); + display.endFrame(); + #endif + MESH_DEBUG_PRINTLN(msg); + MESH_DEBUG_PRINTLN(tmp); + delay(delayms); + board.reboot(); } static char command[160]; @@ -34,9 +45,8 @@ void setup() { } #endif - if (!radio_init()) { - halt(); - } + if (!radio_init()) + delayedReboot("Radio Init Failed!", 5000); fast_rng.begin(radio_get_rng_seed()); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 1a3b4d6e0..89155ebab 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -12,8 +12,19 @@ StdRNG fast_rng; SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - while (1) ; +void delayedReboot(const char *msg, const uint32_t delayms) { + char tmp[32]; + sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0); + #ifdef DISPLAY_CLASS + display.startFrame(); + display.drawTextCentered(display.width() / 2, 24, msg); + display.drawTextCentered(display.width() / 2, 32, tmp); + display.endFrame(); + #endif + MESH_DEBUG_PRINTLN(msg); + MESH_DEBUG_PRINTLN(tmp); + delay(delayms); + board.reboot(); } static char command[MAX_POST_TEXT_LEN+1]; @@ -33,7 +44,9 @@ void setup() { } #endif - if (!radio_init()) { halt(); } + + if (!radio_init()) + delayedReboot("Radio Init Failed!", 5000); fast_rng.begin(radio_get_rng_seed()); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index da1bac5b3..e6f443046 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -550,16 +550,28 @@ StdRNG fast_rng; SimpleMeshTables tables; MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables); -void halt() { - while (1) ; +void delayedReboot(const char *msg, const uint32_t delayms) { + char tmp[32]; + sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0); + #ifdef DISPLAY_CLASS + display.startFrame(); + display.drawTextCentered(display.width() / 2, 24, msg); + display.drawTextCentered(display.width() / 2, 32, tmp); + display.endFrame(); + #endif + MESH_DEBUG_PRINTLN(msg); + MESH_DEBUG_PRINTLN(tmp); + delay(delayms); + board.reboot(); } void setup() { Serial.begin(115200); - + board.begin(); - if (!radio_init()) { halt(); } + if (!radio_init()) + delayedReboot("Radio Init Failed!", 5000); fast_rng.begin(radio_get_rng_seed()); diff --git a/examples/simple_sensor/main.cpp b/examples/simple_sensor/main.cpp index a5fcc1484..b5995c3e3 100644 --- a/examples/simple_sensor/main.cpp +++ b/examples/simple_sensor/main.cpp @@ -46,8 +46,19 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - while (1) ; +void delayedReboot(const char *msg, const uint32_t delayms) { + char tmp[32]; + sprintf(tmp, "Rebooting in %3.1fs", delayms/1000.0); + #ifdef DISPLAY_CLASS + display.startFrame(); + display.drawTextCentered(display.width() / 2, 24, msg); + display.drawTextCentered(display.width() / 2, 32, tmp); + display.endFrame(); + #endif + MESH_DEBUG_PRINTLN(msg); + MESH_DEBUG_PRINTLN(tmp); + delay(delayms); + board.reboot(); } static char command[160]; @@ -66,7 +77,8 @@ void setup() { } #endif - if (!radio_init()) { halt(); } + if (!radio_init()) + delayedReboot("Radio Init Failed!", 5000); fast_rng.begin(radio_get_rng_seed());