Refactor MQTT origin handling to use effective origin logic

Updated MyMesh implementations in simple_repeater and simple_room_server to set mqtt_origin to an empty string, allowing the effective origin to follow node_name during publishing. Introduced new functions in MQTTBridge to manage effective origin retrieval and refresh from preferences, ensuring consistent behavior across MQTT operations. This change simplifies the origin management and enhances clarity in the codebase.
This commit is contained in:
agessaman committed 2026-05-09 17:06:00 -07:00
1 parent b37db66830
commit ff031f48bb
5 files changed
+46 -18

No files matched your search

+2 -6
View File
@@ -965,8 +965,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.gps_interval = 0;
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
// MQTT defaults
StrHelper::strncpy(_prefs.mqtt_origin, "MeshCore-Repeater", sizeof(_prefs.mqtt_origin));
// MQTT defaults (mqtt_origin empty => effective origin follows node_name at publish time)
_prefs.mqtt_origin[0] = '\0';
StrHelper::strncpy(_prefs.mqtt_iata, "SEA", sizeof(_prefs.mqtt_iata));
_prefs.mqtt_status_enabled = 1; // enabled
_prefs.mqtt_packets_enabled = 1; // enabled
@@ -1010,10 +1010,6 @@ void MyMesh::begin(FILESYSTEM *fs) {
// load persisted prefs
_cli.loadPrefs(_fs);
// Set MQTT origin to actual device name (not build-time ADVERT_NAME)
StrHelper::strncpy(_prefs.mqtt_origin, _prefs.node_name, sizeof(_prefs.mqtt_origin));
MESH_DEBUG_PRINTLN("MQTT origin set to device name: %s", _prefs.mqtt_origin);
acl.load(_fs, self_id);
// TODO: key_store.begin();
region_map.load(_fs);