From c99f619fe5ad937fabdbc4b536e3db6869ee7d38 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Sat, 13 Sep 2025 21:32:15 +0200 Subject: [PATCH] add 24hr restart proc --- node1.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/node1.c b/node1.c index 136a807..603778d 100644 --- a/node1.c +++ b/node1.c @@ -11,6 +11,7 @@ #include #include #include +#include // 5 sec loop is for testing // #define LOOP_INTERVAL_MS 5000 @@ -48,6 +49,14 @@ void comms_led_update() { } } +// Callback to reset the Pico after 24 hours +static bool cb_24h(__unused struct repeating_timer *t) { + printf("Restarting Pico after 24 hours...\n"); + watchdog_enable(1, 1); // 1 ms timeout, reset on next loop + while (1) { tight_loop_contents(); } // Wait for reset + return false; // Not reached +} + static mqtt_client_config mqtt_config; static pms5003_config pms_config; @@ -142,6 +151,8 @@ int main() { struct repeating_timer timer_30; add_repeating_timer_ms(LOOP_INTERVAL_MS, cb_30, NULL, &timer_30); + struct repeating_timer timer_24h; + add_repeating_timer_ms(86400000, cb_24h, NULL, &timer_24h); while (true) { comms_led_update(); sleep_us(100);