fix: 修复 NodeInfo 不广播节点名字和公钥问题
- AdminModule: 显式同步 owner.role = config.device.role - NodeDB: CLIENT/CLIENT_MUTE 切回后恢复广播间隔 修复从 CLIENT_HIDDEN 切换回 CLIENT 后 NodeInfo 永不广播的问题
This commit is contained in:
@@ -958,6 +958,20 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
|
||||
moduleConfig.telemetry.environment_update_interval = MAX_INTERVAL;
|
||||
moduleConfig.telemetry.air_quality_interval = MAX_INTERVAL;
|
||||
moduleConfig.telemetry.health_update_interval = MAX_INTERVAL;
|
||||
} else if (role == meshtastic_Config_DeviceConfig_Role_CLIENT ||
|
||||
role == meshtastic_Config_DeviceConfig_Role_CLIENT_MUTE) {
|
||||
// Restore default broadcast intervals when switching back from a restrictive role
|
||||
// (e.g. CLIENT_HIDDEN sets node_info_broadcast_secs = MAX_INTERVAL; without this
|
||||
// reset the node would never send NodeInfo after being switched back to CLIENT).
|
||||
config.device.node_info_broadcast_secs = default_node_info_broadcast_secs;
|
||||
config.position.position_broadcast_smart_enabled = true;
|
||||
config.position.position_broadcast_secs = default_broadcast_interval_secs;
|
||||
moduleConfig.neighbor_info.update_interval = 0; // 0 → coalesces to default in Default.h
|
||||
moduleConfig.telemetry.device_update_interval = MAX_INTERVAL; // coalesces to default
|
||||
moduleConfig.telemetry.environment_update_interval = 0;
|
||||
moduleConfig.telemetry.air_quality_interval = 0;
|
||||
moduleConfig.telemetry.health_update_interval = 0;
|
||||
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -634,6 +634,10 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
nodeDB->installRoleDefaults(c.payload_variant.device.role);
|
||||
changes |= SEGMENT_NODEDATABASE | SEGMENT_DEVICESTATE; // Some role defaults affect owner
|
||||
}
|
||||
// Always keep owner.role in sync with config.device.role so that outgoing NodeInfo
|
||||
// broadcasts reflect the actual current role immediately (owner is loaded from devicestate
|
||||
// at boot but never re-synced afterwards without this explicit assignment).
|
||||
owner.role = config.device.role;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user