Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable automatic reboot, from 5 minutes to 1 day #508

Open
wants to merge 1 commit into
base: dev2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions RX_FSK/RX_FSK.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions RX_FSK/src/Sonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/src/Sonde.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down