diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index d74e96bc6..0f6c444ce 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -211,7 +211,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset) return didFactoryReset; } -bool NodeDB::factoryReset() +bool NodeDB::factoryReset(bool eraseBleBonds) { LOG_INFO("Performing factory reset!\n"); // first, remove the "/prefs" (this removes most prefs) @@ -228,18 +228,21 @@ bool NodeDB::factoryReset() installDefaultChannels(); // third, write everything to disk saveToDisk(); + if (eraseBleBonds) { + LOG_INFO("Erasing BLE bonds\n"); #ifdef ARCH_ESP32 - // This will erase what's in NVS including ssl keys, persistent variables and ble pairing - nvs_flash_erase(); + // This will erase what's in NVS including ssl keys, persistent variables and ble pairing + nvs_flash_erase(); #endif #ifdef ARCH_NRF52 - Bluefruit.begin(); - LOG_INFO("Clearing bluetooth bonds!\n"); - bond_print_list(BLE_GAP_ROLE_PERIPH); - bond_print_list(BLE_GAP_ROLE_CENTRAL); - Bluefruit.Periph.clearBonds(); - Bluefruit.Central.clearBonds(); + Bluefruit.begin(); + LOG_INFO("Clearing bluetooth bonds!\n"); + bond_print_list(BLE_GAP_ROLE_PERIPH); + bond_print_list(BLE_GAP_ROLE_CENTRAL); + Bluefruit.Periph.clearBonds(); + Bluefruit.Central.clearBonds(); #endif + } return true; } diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index c00ab8c03..447ce10d4 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -127,7 +127,7 @@ class NodeDB 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, void *dest_struct); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 0f053a049..778b7193d 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -162,12 +162,18 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta handleGetDeviceMetadata(mp); break; } - case meshtastic_AdminMessage_factory_reset_tag: { - LOG_INFO("Initiating factory reset\n"); + case meshtastic_AdminMessage_factory_reset_config_tag: { + LOG_INFO("Initiating factory config reset\n"); nodeDB->factoryReset(); reboot(DEFAULT_REBOOT_SECONDS); 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: { LOG_INFO("Initiating node-db reset\n"); nodeDB->resetNodes();