From 1bb847b3c877198a2849baf8d115b85571d02f05 Mon Sep 17 00:00:00 2001 From: Audric Date: Tue, 28 Apr 2026 19:59:32 +0200 Subject: [PATCH] fix(peer-client): plumb peer_id through Satellite talker paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Satellite{Link,Client}::handleMsgPeerTalkerStart was calling setTrunkTalkerForTG without recording peer_id, so the trunkTalkerUpdated signal fired with peer_id="" and the new peer//talker//start MQTT topic became peer//talker/... (malformed empty segment). Use setTrunkTalkerForTGViaPeer with m_satellite_id / m_parent_id so the topic is properly namespaced. Also add a defensive early-return in MqttPublisher::onPeerTalker* that logs a warning and skips the publish if peer_id is empty — protects against future callers that emit signals without peer attribution (e.g. TwinLink, addressed in Task 7). --- src/svxlink/reflector/MqttPublisher.cpp | 12 ++++++++++++ src/svxlink/reflector/SatelliteClient.cpp | 3 ++- src/svxlink/reflector/SatelliteLink.cpp | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/svxlink/reflector/MqttPublisher.cpp b/src/svxlink/reflector/MqttPublisher.cpp index 86ee561..7390477 100644 --- a/src/svxlink/reflector/MqttPublisher.cpp +++ b/src/svxlink/reflector/MqttPublisher.cpp @@ -266,6 +266,12 @@ void MqttPublisher::onPeerTalkerStart(const std::string& peer_id, uint32_t tg, const std::string& callsign) { + if (peer_id.empty()) + { + geulog::warn("mqtt", "Skipping onPeerTalkerStart with empty peer_id" + " (tg=", tg, " callsign='", callsign, "')"); + return; + } Json::Value payload; payload["callsign"] = callsign; payload["tg"] = static_cast(tg); @@ -280,6 +286,12 @@ void MqttPublisher::onPeerTalkerStop(const std::string& peer_id, uint32_t tg, const std::string& callsign) { + if (peer_id.empty()) + { + geulog::warn("mqtt", "Skipping onPeerTalkerStop with empty peer_id" + " (tg=", tg, " callsign='", callsign, "')"); + return; + } Json::Value payload; payload["callsign"] = callsign; payload["tg"] = static_cast(tg); diff --git a/src/svxlink/reflector/SatelliteClient.cpp b/src/svxlink/reflector/SatelliteClient.cpp index c093b9d..117824f 100644 --- a/src/svxlink/reflector/SatelliteClient.cpp +++ b/src/svxlink/reflector/SatelliteClient.cpp @@ -340,7 +340,8 @@ void SatelliteClient::handleMsgPeerTalkerStart(std::istream& is) // Register as trunk talker — fires trunkTalkerUpdated which // broadcasts MsgTalkerStart to local clients - TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign()); + TGHandler::instance()->setTrunkTalkerForTGViaPeer(msg.tg(), msg.callsign(), + m_parent_id); } /* SatelliteClient::handleMsgPeerTalkerStart */ diff --git a/src/svxlink/reflector/SatelliteLink.cpp b/src/svxlink/reflector/SatelliteLink.cpp index 3e7fa8f..689bd26 100644 --- a/src/svxlink/reflector/SatelliteLink.cpp +++ b/src/svxlink/reflector/SatelliteLink.cpp @@ -339,7 +339,8 @@ void SatelliteLink::handleMsgPeerTalkerStart(std::istream& is) // local clients. Reflector::onTrunkTalkerUpdated also forwards to // other satellites and trunk peers. m_sat_active_tgs.insert(tg); - TGHandler::instance()->setTrunkTalkerForTG(tg, msg.callsign()); + TGHandler::instance()->setTrunkTalkerForTGViaPeer(tg, msg.callsign(), + m_satellite_id); // Forward to trunk peers m_reflector->forwardSatelliteAudioToTrunks(tg, msg.callsign());