mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-02 20:13:55 +00:00
Split factory reset into config and device variants (#4427)
* Split factory reset into config and device variants * Trunk * Default only in header
This commit is contained in:
parent
3ab4bebdcb
commit
3878e025e4
@ -211,7 +211,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
|
|||||||
return didFactoryReset;
|
return didFactoryReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeDB::factoryReset()
|
bool NodeDB::factoryReset(bool eraseBleBonds)
|
||||||
{
|
{
|
||||||
LOG_INFO("Performing factory reset!\n");
|
LOG_INFO("Performing factory reset!\n");
|
||||||
// first, remove the "/prefs" (this removes most prefs)
|
// first, remove the "/prefs" (this removes most prefs)
|
||||||
@ -228,6 +228,8 @@ bool NodeDB::factoryReset()
|
|||||||
installDefaultChannels();
|
installDefaultChannels();
|
||||||
// third, write everything to disk
|
// third, write everything to disk
|
||||||
saveToDisk();
|
saveToDisk();
|
||||||
|
if (eraseBleBonds) {
|
||||||
|
LOG_INFO("Erasing BLE bonds\n");
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// This will erase what's in NVS including ssl keys, persistent variables and ble pairing
|
// This will erase what's in NVS including ssl keys, persistent variables and ble pairing
|
||||||
nvs_flash_erase();
|
nvs_flash_erase();
|
||||||
@ -240,6 +242,7 @@ bool NodeDB::factoryReset()
|
|||||||
Bluefruit.Periph.clearBonds();
|
Bluefruit.Periph.clearBonds();
|
||||||
Bluefruit.Central.clearBonds();
|
Bluefruit.Central.clearBonds();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class NodeDB
|
|||||||
|
|
||||||
void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(NodeNum nodeNum);
|
void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(), removeNodeByNum(NodeNum nodeNum);
|
||||||
|
|
||||||
bool factoryReset();
|
bool factoryReset(bool eraseBleBonds = false);
|
||||||
|
|
||||||
LoadFileResult loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields,
|
LoadFileResult loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields,
|
||||||
void *dest_struct);
|
void *dest_struct);
|
||||||
|
@ -162,12 +162,18 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
handleGetDeviceMetadata(mp);
|
handleGetDeviceMetadata(mp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case meshtastic_AdminMessage_factory_reset_tag: {
|
case meshtastic_AdminMessage_factory_reset_config_tag: {
|
||||||
LOG_INFO("Initiating factory reset\n");
|
LOG_INFO("Initiating factory config reset\n");
|
||||||
nodeDB->factoryReset();
|
nodeDB->factoryReset();
|
||||||
reboot(DEFAULT_REBOOT_SECONDS);
|
reboot(DEFAULT_REBOOT_SECONDS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case meshtastic_AdminMessage_factory_reset_device_tag: {
|
||||||
|
LOG_INFO("Initiating full factory reset\n");
|
||||||
|
nodeDB->factoryReset(true);
|
||||||
|
reboot(DEFAULT_REBOOT_SECONDS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case meshtastic_AdminMessage_nodedb_reset_tag: {
|
case meshtastic_AdminMessage_nodedb_reset_tag: {
|
||||||
LOG_INFO("Initiating node-db reset\n");
|
LOG_INFO("Initiating node-db reset\n");
|
||||||
nodeDB->resetNodes();
|
nodeDB->resetNodes();
|
||||||
|
Loading…
Reference in New Issue
Block a user