Assume previous root on topic change
This commit is contained in:
@@ -775,12 +775,17 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
|||||||
// Additionally as a side-effect, assume a new value under myRegion
|
// Additionally as a side-effect, assume a new value under myRegion
|
||||||
initRegion();
|
initRegion();
|
||||||
|
|
||||||
// subscribe to appropriate MQTT root topic for this region
|
std::string current = moduleConfig.mqtt.root;
|
||||||
#ifdef USERPREFS_MQTT_ROOT_TOPIC
|
size_t location = current.find_first_of('/');
|
||||||
sprintf(moduleConfig.mqtt.root, "%s/%s", USERPREFS_MQTT_ROOT_TOPIC, myRegion->name);
|
|
||||||
#else
|
char root[location + 1];
|
||||||
sprintf(moduleConfig.mqtt.root, "%s/%s", default_mqtt_root, myRegion->name);
|
memset(root, 0, location);
|
||||||
#endif
|
memcpy(root, moduleConfig.mqtt.root, location);
|
||||||
|
root[location] = '\0';
|
||||||
|
|
||||||
|
// subscribe to the appropriate MQTT root topic for this region
|
||||||
|
sprintf(moduleConfig.mqtt.root, "%s/%s", root, myRegion->name);
|
||||||
|
|
||||||
changes = SEGMENT_CONFIG | SEGMENT_MODULECONFIG;
|
changes = SEGMENT_CONFIG | SEGMENT_MODULECONFIG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user