sforkowany z mirror/meshtastic-firmware
Consolidate reboots (#1827)
rodzic
3d9845ff6d
commit
056a93f0c9
|
@ -101,9 +101,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||
* Other
|
||||
*/
|
||||
case AdminMessage_reboot_seconds_tag: {
|
||||
int32_t s = r->reboot_seconds;
|
||||
DEBUG_MSG("Rebooting in %d seconds\n", s);
|
||||
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||
reboot(r->reboot_seconds);
|
||||
break;
|
||||
}
|
||||
case AdminMessage_reboot_ota_seconds_tag: {
|
||||
|
@ -135,13 +133,13 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||
case AdminMessage_factory_reset_tag: {
|
||||
DEBUG_MSG("Initiating factory reset\n");
|
||||
nodeDB.factoryReset();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
reboot(5);
|
||||
break;
|
||||
}
|
||||
case AdminMessage_nodedb_reset_tag: {
|
||||
DEBUG_MSG("Initiating node-db reset\n");
|
||||
nodeDB.resetNodes();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
reboot(5);
|
||||
break;
|
||||
}
|
||||
#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
|
||||
service.reloadOwner();
|
||||
DEBUG_MSG("Rebooting due to owner changes\n");
|
||||
screen->startRebootScreen();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
reboot(5);
|
||||
}
|
||||
}
|
||||
|
||||
void AdminModule::handleSetConfig(const Config &c)
|
||||
{
|
||||
bool requiresReboot = false;
|
||||
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER);
|
||||
bool isRegionUnset = (config.lora.region == Config_LoRaConfig_RegionCode_UNSET);
|
||||
|
||||
|
@ -218,7 +214,6 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||
nodeDB.initConfigIntervals();
|
||||
nodeDB.initModuleConfigIntervals();
|
||||
}
|
||||
requiresReboot = true;
|
||||
break;
|
||||
case Config_position_tag:
|
||||
DEBUG_MSG("Setting config: Position\n");
|
||||
|
@ -234,7 +229,6 @@ void AdminModule::handleSetConfig(const Config &c)
|
|||
DEBUG_MSG("Setting config: WiFi\n");
|
||||
config.has_network = true;
|
||||
config.network = c.payload_variant.network;
|
||||
requiresReboot = true;
|
||||
break;
|
||||
case Config_display_tag:
|
||||
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.tx_enabled = true;
|
||||
}
|
||||
requiresReboot = true;
|
||||
break;
|
||||
case Config_bluetooth_tag:
|
||||
DEBUG_MSG("Setting config: Bluetooth\n");
|
||||
config.has_bluetooth = true;
|
||||
config.bluetooth = c.payload_variant.bluetooth;
|
||||
requiresReboot = true;
|
||||
break;
|
||||
}
|
||||
|
||||
service.reloadConfig(SEGMENT_CONFIG);
|
||||
// Reboot 5 seconds after a config that requires rebooting is set
|
||||
if (requiresReboot) {
|
||||
DEBUG_MSG("Rebooting due to config changes\n");
|
||||
screen->startRebootScreen();
|
||||
rebootAtMsec = millis() + (5 * 1000);
|
||||
}
|
||||
reboot(5);
|
||||
}
|
||||
|
||||
void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
||||
|
@ -307,8 +294,9 @@ void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
|||
moduleConfig.canned_message = c.payload_variant.canned_message;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
service.reloadConfig(SEGMENT_MODULECONFIG);
|
||||
reboot(5);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// restrict to the admin channel for rx
|
||||
|
|
|
@ -37,6 +37,7 @@ class AdminModule : public ProtobufModule<AdminMessage>
|
|||
void handleSetConfig(const Config &c);
|
||||
void handleSetModuleConfig(const ModuleConfig &c);
|
||||
void handleSetChannel();
|
||||
void reboot(int32_t seconds);
|
||||
};
|
||||
|
||||
extern AdminModule *adminModule;
|
||||
|
|
Ładowanie…
Reference in New Issue