mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
Unmessagable implementation and defaults (#6811)
* Unmessagable implementation and defaults * Router and router late are unmessagable by default * Update src/modules/AdminModule.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a51a6b8c47
commit
fc64bea698
@ -819,10 +819,19 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
|
||||
initConfigIntervals();
|
||||
initModuleConfigIntervals();
|
||||
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY;
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
config.display.screen_on_secs = 1;
|
||||
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) {
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
moduleConfig.telemetry.environment_measurement_enabled = true;
|
||||
moduleConfig.telemetry.environment_update_interval = 300;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND) {
|
||||
@ -837,7 +846,12 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
|
||||
(meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_SPEED |
|
||||
meshtastic_Config_PositionConfig_PositionFlags_HEADING | meshtastic_Config_PositionConfig_PositionFlags_DOP);
|
||||
moduleConfig.telemetry.device_update_interval = ONE_DAY;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_TRACKER) {
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER) {
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = true;
|
||||
config.device.node_info_broadcast_secs = ONE_DAY;
|
||||
config.position.position_broadcast_smart_enabled = true;
|
||||
config.position.position_broadcast_secs = 3 * 60; // Every 3 minutes
|
||||
@ -970,6 +984,8 @@ void NodeDB::installDefaultDeviceState()
|
||||
#endif
|
||||
snprintf(owner.id, sizeof(owner.id), "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
||||
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
||||
owner.has_is_unmessagable = true;
|
||||
owner.is_unmessagable = false;
|
||||
}
|
||||
|
||||
// We reserve a few nodenums for future use
|
||||
|
@ -504,6 +504,12 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
|
||||
sendWarning(licensedModeMessage);
|
||||
}
|
||||
}
|
||||
if (owner.has_is_unmessagable != o.has_is_unmessagable ||
|
||||
(o.has_is_unmessagable && owner.is_unmessagable != o.is_unmessagable)) {
|
||||
changed = 1;
|
||||
owner.has_is_unmessagable = o.has_is_unmessagable || o.has_is_unmessagable;
|
||||
owner.is_unmessagable = o.is_unmessagable;
|
||||
}
|
||||
|
||||
if (changed) { // If nothing really changed, don't broadcast on the network or write to flash
|
||||
service->reloadOwner(!hasOpenEditTransaction);
|
||||
@ -553,8 +559,10 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
sendWarning(warning);
|
||||
}
|
||||
// If we're setting router role for the first time, install its intervals
|
||||
if (existingRole != c.payload_variant.device.role)
|
||||
if (existingRole != c.payload_variant.device.role) {
|
||||
nodeDB->installRoleDefaults(c.payload_variant.device.role);
|
||||
changes |= SEGMENT_NODEDATABASE | SEGMENT_DEVICESTATE; // Some role defaults affect owner
|
||||
}
|
||||
if (config.device.node_info_broadcast_secs < min_node_info_broadcast_secs) {
|
||||
LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d", min_node_info_broadcast_secs);
|
||||
config.device.node_info_broadcast_secs = min_node_info_broadcast_secs;
|
||||
|
@ -86,6 +86,11 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply()
|
||||
u.public_key.bytes[0] = 0;
|
||||
u.public_key.size = 0;
|
||||
}
|
||||
// Coerce unmessagable for Repeater role
|
||||
if (u.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||
u.has_is_unmessagable = true;
|
||||
u.is_unmessagable = true;
|
||||
}
|
||||
|
||||
LOG_INFO("Send owner %s/%s/%s", u.id, u.long_name, u.short_name);
|
||||
lastSentToMesh = millis();
|
||||
|
Loading…
Reference in New Issue
Block a user