Admin message shutdown feature (#1124)

* Shutdown via proto admin message
pull/1129/head
Ben Meadors 2022-01-21 15:03:26 -06:00 zatwierdzone przez GitHub
rodzic 7723b30951
commit b6706c7ac1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 34 dodań i 2 usunięć

Wyświetl plik

@ -699,8 +699,9 @@ axpDebugOutput.setup();
#endif
uint32_t rebootAtMsec; // If not zero we will reboot at this time (used to reboot shortly after the update completes)
uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to shutdown from python or mobile client)
void rebootCheck()
void powerCommandsCheck()
{
if (rebootAtMsec && millis() > rebootAtMsec) {
#ifndef NO_ESP32
@ -710,6 +711,30 @@ void rebootCheck()
DEBUG_MSG("FIXME implement reboot for this platform");
#endif
}
#if NRF52_SERIES
if (shutdownAtMsec) {
screen->startShutdownScreen();
playBeep();
ledOff(PIN_LED1);
ledOff(PIN_LED2);
}
#endif
if (shutdownAtMsec && millis() > shutdownAtMsec) {
DEBUG_MSG("Shutting down from admin command\n");
#ifdef TBEAM_V10
if (axp192_found == true) {
setLed(false);
power->shutdown();
}
#elif NRF52_SERIES
playShutdownMelody();
power->shutdown();
#else
DEBUG_MSG("FIXME implement shutdown for this platform");
#endif
}
}
// If a thread does something that might need for it to be rescheduled ASAP it can set this flag
@ -730,7 +755,7 @@ void loop()
#ifdef NRF52_SERIES
nrf52Loop();
#endif
rebootCheck();
powerCommandsCheck();
// For debugging
// if (rIf) ((RadioLibInterface *)rIf)->isActivelyReceiving();

Wyświetl plik

@ -21,6 +21,7 @@ extern graphics::Screen *screen;
const char *getDeviceName();
extern uint32_t rebootAtMsec;
extern uint32_t shutdownAtMsec;
// If a thread does something that might need for it to be rescheduled ASAP it can set this flag
// This will supress the current delay and instead try to run ASAP.

Wyświetl plik

@ -104,6 +104,12 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
break;
}
case AdminMessage_shutdown_seconds_tag: {
int32_t s = r->shutdown_seconds;
DEBUG_MSG("Shutdown in %d seconds\n", s);
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
break;
}
#ifdef PORTDUINO
case AdminMessage_exit_simulator_tag: