From d44146ab29299a5d9d2861f00d4df6060da8d933 Mon Sep 17 00:00:00 2001 From: Winston Lowe Date: Sun, 16 Nov 2025 23:06:06 -0800 Subject: [PATCH 1/2] Changed halt so it's not a while loop, and instead delays 10sec and reboots. --- examples/companion_radio/main.cpp | 4 ++-- examples/simple_repeater/main.cpp | 3 ++- examples/simple_room_server/main.cpp | 3 ++- examples/simple_secure_chat/main.cpp | 5 +++-- examples/simple_sensor/main.cpp | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 82c8c21d9..5fc162c97 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -102,14 +102,14 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store /* END GLOBAL OBJECTS */ void halt() { - while (1) ; + delay(10000); + board.reboot(); } void setup() { Serial.begin(115200); board.begin(); - #ifdef DISPLAY_CLASS DisplayDriver* disp = NULL; if (display.begin()) { diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 7387e77e7..50599bbe3 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -14,7 +14,8 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); void halt() { - while (1) ; + delay(10000); + board.reboot(); } static char command[160]; diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 1a3b4d6e0..4ca7c09ac 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -13,7 +13,8 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); void halt() { - while (1) ; + delay(10000); + board.reboot(); } static char command[MAX_POST_TEXT_LEN+1]; diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index da1bac5b3..a37b85ce5 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -551,12 +551,13 @@ SimpleMeshTables tables; MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables); void halt() { - while (1) ; + delay(10000); + board.reboot(); } void setup() { Serial.begin(115200); - + board.begin(); if (!radio_init()) { halt(); } diff --git a/examples/simple_sensor/main.cpp b/examples/simple_sensor/main.cpp index a5fcc1484..e2c94351f 100644 --- a/examples/simple_sensor/main.cpp +++ b/examples/simple_sensor/main.cpp @@ -47,7 +47,8 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); void halt() { - while (1) ; + delay(10000); + board.reboot(); } static char command[160]; From cdcefac09f5013983801168e88ce1c6b4db0d64b Mon Sep 17 00:00:00 2001 From: Winston Lowe Date: Sun, 14 Dec 2025 17:42:41 -0800 Subject: [PATCH 2/2] Replaced halt function with delayedReboot --- examples/companion_radio/main.cpp | 17 ++++++++++++++--- examples/simple_repeater/main.cpp | 19 ++++++++++++++----- examples/simple_room_server/main.cpp | 18 +++++++++++++++--- examples/simple_secure_chat/main.cpp | 17 ++++++++++++++--- examples/simple_sensor/main.cpp | 17 ++++++++++++++--- 5 files changed, 71 insertions(+), 17 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 5fc162c97..2be6a3e77 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -101,8 +101,18 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store /* END GLOBAL OBJECTS */ -void halt() { - delay(10000); +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(); } @@ -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 50599bbe3..0a1e12e69 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -13,8 +13,18 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - delay(10000); +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(); } @@ -35,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 4ca7c09ac..89155ebab 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -12,8 +12,18 @@ StdRNG fast_rng; SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - delay(10000); +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(); } @@ -34,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 a37b85ce5..e6f443046 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -550,8 +550,18 @@ StdRNG fast_rng; SimpleMeshTables tables; MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables); -void halt() { - delay(10000); +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(); } @@ -560,7 +570,8 @@ void setup() { 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 e2c94351f..b5995c3e3 100644 --- a/examples/simple_sensor/main.cpp +++ b/examples/simple_sensor/main.cpp @@ -46,8 +46,18 @@ SimpleMeshTables tables; MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables); -void halt() { - delay(10000); +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(); } @@ -67,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());