mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Refactor: Decoupled role/config check and set role defaults appropriately
This commit is contained in:
parent
39be63d7af
commit
0de61c3986
@ -402,11 +402,6 @@ NodeDB::NodeDB()
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
config.position.gps_enabled = 0;
|
||||
}
|
||||
if (config.device.preserve_favourites ||
|
||||
IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_CLIENT_BASE, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
||||
meshtastic_Config_DeviceConfig_Role_ROUTER_LATE)) {
|
||||
saveFavourites = true;
|
||||
}
|
||||
#ifdef USERPREFS_FIRMWARE_EDITION
|
||||
myNodeInfo.firmware_edition = USERPREFS_FIRMWARE_EDITION;
|
||||
#endif
|
||||
@ -988,7 +983,7 @@ void NodeDB::resetNodes()
|
||||
if (!config.position.fixed_position)
|
||||
clearLocalPosition();
|
||||
numMeshNodes = 1;
|
||||
if (saveFavourites) {
|
||||
if (config.device.preserve_favourites) {
|
||||
for (size_t i = 0; i < nodeDatabase.nodes.size(); i++) {
|
||||
meshtastic_NodeInfoLite &node = nodeDatabase.nodes[i];
|
||||
if (i > 0 && !node.is_favorite) {
|
||||
|
||||
@ -144,8 +144,6 @@ class NodeDB
|
||||
bool keyIsLowEntropy = false;
|
||||
bool hasWarned = false;
|
||||
|
||||
bool saveFavourites = false;
|
||||
|
||||
/// don't do mesh based algorithm for node id assignment (initially)
|
||||
/// instead just store in flash - possibly even in the initial alpha release do this hack
|
||||
NodeDB();
|
||||
|
||||
@ -634,6 +634,13 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
requiresReboot = true;
|
||||
}
|
||||
}
|
||||
// Router, Router Late and Client Base roles persist their favourites through NodeDB reset by default.
|
||||
// In accordance with the ability to preserve hops when relayed via a favorite added in
|
||||
// https://github.com/meshtastic/firmware/pull/7992
|
||||
if (IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_CLIENT_BASE,
|
||||
meshtastic_Config_DeviceConfig_Role_ROUTER, meshtastic_Config_DeviceConfig_Role_ROUTER_LATE)) {
|
||||
config.device.preserve_favourites = true;
|
||||
};
|
||||
#if USERPREFS_EVENT_MODE
|
||||
// If we're in event mode, nobody is a Router or Router Late
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user