This commit is contained in:
Chris Kuethe 2025-02-09 01:07:09 +01:00 committed by GitHub
commit 3b6d6f1db8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 0 deletions

View File

@ -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) {

View File

@ -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 &leq; 50)" ],
[ "periodic_reboot", "reboot device periodically (5-1440 minutes, 0 to disable)" ],
[ "rxlat", "Receiver fixed latitude"],
[ "rxlon", "Receiver fixed longitude"],
[ "rxalt", "Receiver fixed altitude"],

View File

@ -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

View File

@ -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;

View File

@ -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