diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 969bf7d5..1f49198f 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -699,6 +699,7 @@ struct st_configitems config_list[] = { {"wifi", 0, &sonde.config.wifi}, {"debug", 0, &sonde.config.debug}, {"maxsonde", 0, &sonde.config.maxsonde}, + {"periodic_reboot", 0, &sonde.config.periodic_reboot}, {"rxlat", -7, &sonde.config.rxlat}, {"rxlon", -7, &sonde.config.rxlon}, {"rxalt", -7, &sonde.config.rxalt}, @@ -1628,6 +1629,7 @@ static void touchISR2(); Ticker ticker; Ticker ledFlasher; +Ticker rebootTimer; #define IS_TOUCH(x) (((x)!=255)&&((x)!=-1)&&((x)&128)) void initTouch() { @@ -1761,6 +1763,23 @@ void flashLed(int ms) { } } + +// this is like putting a cuckoo clock in front of the reset button and waiting for it to chime. +void rebootCallback() { + LOG_E(TAG, "*** Doing periodic reboot ***\n"); + delay(100); + ESP.restart(); +} +void startRebootTimer(int minutes) { + if (sonde.config.periodic_reboot <= 0) + return; + if (minutes > 1440) + minutes = 1440; + LOG_I(TAG, "Configuring periodic reboot after %d minutes\n", minutes); + uint64_t reboot_ms = minutes * 60 * 1000; + rebootTimer.once_ms(reboot_ms, rebootCallback); +} + int doTouch = 0; static void checkTouchStatus() { checkTouchButton(button1); @@ -2041,6 +2060,11 @@ void setup() flashLed(1000); // testing } + if (sonde.config.periodic_reboot >= 5) + startRebootTimer(sonde.config.periodic_reboot); + else + LOG_I(TAG, "periodic reboot not active\n"); + button1.pin = sonde.config.button_pin; button2.pin = sonde.config.button2_pin; if (button1.pin != 0xff) { diff --git a/RX_FSK/data/cfg.js b/RX_FSK/data/cfg.js index 2738037d..ff0044a2 100644 --- a/RX_FSK/data/cfg.js +++ b/RX_FSK/data/cfg.js @@ -5,6 +5,7 @@ var cfgs = [ [ "ephftp", "FTP server for ephemeris data (RS92 decoder)"], [ "debug", "Debug level (0=err/1=warn/2=info/3=all;+10=color)" ], [ "maxsonde", "Maximum number of QRG entries (must be ≤ 50)" ], +[ "periodic_reboot", "reboot device periodically (5-1440 minutes, 0 to disable)" ], [ "rxlat", "Receiver fixed latitude"], [ "rxlon", "Receiver fixed longitude"], [ "rxalt", "Receiver fixed altitude"], diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index 5e10b8d7..bf2e574c 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -38,6 +38,7 @@ tft_orient=1 # General config settings #-------------------------------# maxsonde=20 +periodic_reboot=0 # debug: 0=err, 1=warn, 2=info, 3=debug; +10:use color debug=12 # wifi mode: 1=client in background; 2=AP in background; 3=client on startup, ap if failure diff --git a/RX_FSK/src/Sonde.cpp b/RX_FSK/src/Sonde.cpp index 978f47d8..6a049b77 100644 --- a/RX_FSK/src/Sonde.cpp +++ b/RX_FSK/src/Sonde.cpp @@ -305,6 +305,7 @@ void Sonde::defaultConfig() { config.passcode = -1; strcpy(config.mdnsname, "rdzsonde"); config.maxsonde=15; + config.periodic_reboot = 0; config.debug=0; config.wifi=1; config.display[0]=0; @@ -350,6 +351,8 @@ extern const int N_CONFIG; void Sonde::checkConfig() { if(config.maxsonde > MAXSONDE) config.maxsonde = MAXSONDE; + if(config.periodic_reboot<0) config.periodic_reboot = 0; + if(config.periodic_reboot>1440) config.periodic_reboot = 1440; if(config.sondehub.fiinterval<5) config.sondehub.fiinterval = 5; if(config.sondehub.fimaxdist>700) config.sondehub.fimaxdist = 700; if(config.sondehub.fimaxage>48) config.sondehub.fimaxage = 48; diff --git a/RX_FSK/src/Sonde.h b/RX_FSK/src/Sonde.h index a38c7c1d..46eb481e 100644 --- a/RX_FSK/src/Sonde.h +++ b/RX_FSK/src/Sonde.h @@ -295,6 +295,7 @@ typedef struct st_rdzconfig { int spectrum; // show freq spectrum for n seconds -1=disable; 0=forever int marker; // show freq marker in spectrum 0=disable int maxsonde; // number of max sonde in scan (range=1-99) + int periodic_reboot; // reboot device after x minutes, 0=0ff int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal) int noisefloor; // for spectrum display char mdnsname[15]; // mDNS-Name, defaults to rdzsonde