Reset nodedb wiring (#1724)

pull/1733/head
Ben Meadors 2022-09-28 16:47:26 -05:00 zatwierdzone przez GitHub
rodzic ab4b3a50ee
commit ac235bcabb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 16 dodań i 3 usunięć

Wyświetl plik

@ -225,13 +225,20 @@ void NodeDB::installDefaultChannels()
channelFile.version = DEVICESTATE_CUR_VER;
}
void NodeDB::resetNodes()
{
devicestate.node_db_count = 0;
memset(devicestate.node_db, 0, sizeof(devicestate.node_db));
saveDeviceStateToDisk();
}
void NodeDB::installDefaultDeviceState()
{
DEBUG_MSG("Installing default DeviceState\n");
memset(&devicestate, 0, sizeof(DeviceState));
*numNodes = 0; // Forget node DB
*numNodes = 0;
// init our devicestate with valid flags so protobuf writing/reading will work
devicestate.has_my_node = true;
devicestate.has_owner = true;

Wyświetl plik

@ -115,7 +115,7 @@ class NodeDB
/// Return the number of nodes we've heard from recently (within the last 2 hrs?)
size_t getNumOnlineNodes();
void initConfigIntervals(), initModuleConfigIntervals();
void initConfigIntervals(), initModuleConfigIntervals(), resetNodes();
bool factoryReset();

Wyświetl plik

@ -120,6 +120,12 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
rebootAtMsec = millis() + (5 * 1000);
break;
}
case AdminMessage_nodedb_reset_tag: {
DEBUG_MSG("Initiating node-db reset\n");
nodeDB.resetNodes();
rebootAtMsec = millis() + (5 * 1000);
break;
}
#ifdef ARCH_PORTDUINO
case AdminMessage_exit_simulator_tag:
DEBUG_MSG("Exiting simulator\n");