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

* Default mqtt root to msh/region from unset

* Correct segments
pull/3090/head^2
Ben Meadors 2024-01-19 07:40:14 -06:00 zatwierdzone przez GitHub
rodzic a8b7490b6e
commit e2a3b0306f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -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;
}
}