mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 18:47:40 +00:00
Consolidate reboots (#1827)
This commit is contained in:
parent
3d9845ff6d
commit
056a93f0c9
@ -101,9 +101,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
* Other
|
* Other
|
||||||
*/
|
*/
|
||||||
case AdminMessage_reboot_seconds_tag: {
|
case AdminMessage_reboot_seconds_tag: {
|
||||||
int32_t s = r->reboot_seconds;
|
reboot(r->reboot_seconds);
|
||||||
DEBUG_MSG("Rebooting in %d seconds\n", s);
|
|
||||||
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AdminMessage_reboot_ota_seconds_tag: {
|
case AdminMessage_reboot_ota_seconds_tag: {
|
||||||
@ -135,13 +133,13 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
case AdminMessage_factory_reset_tag: {
|
case AdminMessage_factory_reset_tag: {
|
||||||
DEBUG_MSG("Initiating factory reset\n");
|
DEBUG_MSG("Initiating factory reset\n");
|
||||||
nodeDB.factoryReset();
|
nodeDB.factoryReset();
|
||||||
rebootAtMsec = millis() + (5 * 1000);
|
reboot(5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AdminMessage_nodedb_reset_tag: {
|
case AdminMessage_nodedb_reset_tag: {
|
||||||
DEBUG_MSG("Initiating node-db reset\n");
|
DEBUG_MSG("Initiating node-db reset\n");
|
||||||
nodeDB.resetNodes();
|
nodeDB.resetNodes();
|
||||||
rebootAtMsec = millis() + (5 * 1000);
|
reboot(5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef ARCH_PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
@ -196,14 +194,12 @@ void AdminModule::handleSetOwner(const User &o)
|
|||||||
if (changed) { // If nothing really changed, don't broadcast on the network or write to flash
|
if (changed) { // If nothing really changed, don't broadcast on the network or write to flash
|
||||||
service.reloadOwner();
|
service.reloadOwner();
|
||||||
DEBUG_MSG("Rebooting due to owner changes\n");
|
DEBUG_MSG("Rebooting due to owner changes\n");
|
||||||
screen->startRebootScreen();
|
reboot(5);
|
||||||
rebootAtMsec = millis() + (5 * 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetConfig(const Config &c)
|
void AdminModule::handleSetConfig(const Config &c)
|
||||||
{
|
{
|
||||||
bool requiresReboot = false;
|
|
||||||
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER);
|
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER);
|
||||||
bool isRegionUnset = (config.lora.region == Config_LoRaConfig_RegionCode_UNSET);
|
bool isRegionUnset = (config.lora.region == Config_LoRaConfig_RegionCode_UNSET);
|
||||||
|
|
||||||
@ -218,7 +214,6 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||||||
nodeDB.initConfigIntervals();
|
nodeDB.initConfigIntervals();
|
||||||
nodeDB.initModuleConfigIntervals();
|
nodeDB.initModuleConfigIntervals();
|
||||||
}
|
}
|
||||||
requiresReboot = true;
|
|
||||||
break;
|
break;
|
||||||
case Config_position_tag:
|
case Config_position_tag:
|
||||||
DEBUG_MSG("Setting config: Position\n");
|
DEBUG_MSG("Setting config: Position\n");
|
||||||
@ -234,7 +229,6 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||||||
DEBUG_MSG("Setting config: WiFi\n");
|
DEBUG_MSG("Setting config: WiFi\n");
|
||||||
config.has_network = true;
|
config.has_network = true;
|
||||||
config.network = c.payload_variant.network;
|
config.network = c.payload_variant.network;
|
||||||
requiresReboot = true;
|
|
||||||
break;
|
break;
|
||||||
case Config_display_tag:
|
case Config_display_tag:
|
||||||
DEBUG_MSG("Setting config: Display\n");
|
DEBUG_MSG("Setting config: Display\n");
|
||||||
@ -249,23 +243,16 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||||||
config.lora.region > Config_LoRaConfig_RegionCode_UNSET) {
|
config.lora.region > Config_LoRaConfig_RegionCode_UNSET) {
|
||||||
config.lora.tx_enabled = true;
|
config.lora.tx_enabled = true;
|
||||||
}
|
}
|
||||||
requiresReboot = true;
|
|
||||||
break;
|
break;
|
||||||
case Config_bluetooth_tag:
|
case Config_bluetooth_tag:
|
||||||
DEBUG_MSG("Setting config: Bluetooth\n");
|
DEBUG_MSG("Setting config: Bluetooth\n");
|
||||||
config.has_bluetooth = true;
|
config.has_bluetooth = true;
|
||||||
config.bluetooth = c.payload_variant.bluetooth;
|
config.bluetooth = c.payload_variant.bluetooth;
|
||||||
requiresReboot = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
service.reloadConfig(SEGMENT_CONFIG);
|
service.reloadConfig(SEGMENT_CONFIG);
|
||||||
// Reboot 5 seconds after a config that requires rebooting is set
|
reboot(5);
|
||||||
if (requiresReboot) {
|
|
||||||
DEBUG_MSG("Rebooting due to config changes\n");
|
|
||||||
screen->startRebootScreen();
|
|
||||||
rebootAtMsec = millis() + (5 * 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
||||||
@ -309,6 +296,7 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
service.reloadConfig(SEGMENT_MODULECONFIG);
|
service.reloadConfig(SEGMENT_MODULECONFIG);
|
||||||
|
reboot(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetChannel(const Channel &cc)
|
void AdminModule::handleSetChannel(const Channel &cc)
|
||||||
@ -468,6 +456,13 @@ void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdminModule::reboot(int32_t seconds)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Rebooting in %d seconds\n", seconds);
|
||||||
|
screen->startRebootScreen();
|
||||||
|
rebootAtMsec = (seconds < 0) ? 0 : (millis() + seconds * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
AdminModule::AdminModule() : ProtobufModule("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
AdminModule::AdminModule() : ProtobufModule("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
||||||
{
|
{
|
||||||
// restrict to the admin channel for rx
|
// restrict to the admin channel for rx
|
||||||
|
@ -37,6 +37,7 @@ class AdminModule : public ProtobufModule<AdminMessage>
|
|||||||
void handleSetConfig(const Config &c);
|
void handleSetConfig(const Config &c);
|
||||||
void handleSetModuleConfig(const ModuleConfig &c);
|
void handleSetModuleConfig(const ModuleConfig &c);
|
||||||
void handleSetChannel();
|
void handleSetChannel();
|
||||||
|
void reboot(int32_t seconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern AdminModule *adminModule;
|
extern AdminModule *adminModule;
|
||||||
|
Loading…
Reference in New Issue
Block a user