Default mqtt root to msh/region from unset (#3111)

* Default mqtt root to msh/region from unset

* Correct segments
This commit is contained in:
Ben Meadors 2024-01-19 07:40:14 -06:00 committed by GitHub
parent a8b7490b6e
commit e2a3b0306f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -280,6 +280,7 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
void AdminModule::handleSetConfig(const meshtastic_Config &c)
{
auto changes = SEGMENT_CONFIG;
auto existingRole = config.device.role;
bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET);
@ -320,6 +321,11 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
config.lora = c.payload_variant.lora;
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
config.lora.tx_enabled = true;
initRegion();
if (strcmp(moduleConfig.mqtt.root, default_mqtt_root) == 0) {
sprintf(moduleConfig.mqtt.root, "%s/%s", default_mqtt_root, myRegion->name);
changes = SEGMENT_CONFIG | SEGMENT_MODULECONFIG;
}
}
break;
case meshtastic_Config_bluetooth_tag:
@ -329,7 +335,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
break;
}
saveChanges(SEGMENT_CONFIG);
saveChanges(changes);
}
void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
@ -715,4 +721,4 @@ AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_AP
{
// restrict to the admin channel for rx
boundChannel = Channels::adminChannel;
}
}