Fix mDNS crash

This commit is contained in:
2026-02-28 22:36:13 -05:00
parent 74d57dd915
commit c8cd1545dc
2 changed files with 16 additions and 5 deletions

View File

@@ -15,6 +15,10 @@ public:
~mDNSDiscoveryService() override;
void set_connected_boards(const std::vector<int>& boards) override;
private:
std::string m_module_id;
std::string m_module_type;
std::string m_connected_modules;
};
#endif //DISCOVERYSERVICE_H

View File

@@ -23,9 +23,12 @@ mDNSDiscoveryService::mDNSDiscoveryService() {
mdns_service_add(nullptr, "_robotcontrol", "_tcp", TCP_PORT, nullptr, 0);
mdns_service_instance_name_set("_robotcontrol", "_tcp", "Robot Control TCP Server");
m_module_id = std::to_string(config_manager.get_module_id());
m_module_type = std::to_string(config_manager.get_module_type());
mdns_txt_item_t service_txt_data[3] = {
{"module_id",std::to_string(config_manager.get_module_id()).c_str()},
{"module_type",std::to_string(config_manager.get_module_type()).c_str()},
{"module_id", m_module_id.c_str()},
{"module_type",m_module_type.c_str()},
{"connected_modules",""},
};
@@ -48,10 +51,14 @@ void mDNSDiscoveryService::set_connected_boards(const std::vector<int>& boards)
}
}
m_module_id = std::to_string(config_manager.get_module_id());
m_module_type = std::to_string(config_manager.get_module_type());
m_connected_modules = ss.str();
mdns_txt_item_t service_txt_data[3] = {
{"module_id",std::to_string(config_manager.get_module_id()).c_str()},
{"module_type",std::to_string(config_manager.get_module_type()).c_str()},
{"connected_modules",ss.str().c_str()},
{"module_id", m_module_id.c_str()},
{"module_type", m_module_type.c_str()},
{"connected_modules", m_connected_modules.c_str()},
};
mdns_service_txt_set("_robotcontrol", "_tcp", service_txt_data, 3);
}