From 9cc2491698926c87c52971e3590e949b4f7ce9a8 Mon Sep 17 00:00:00 2001 From: Tobias Blomberg Date: Sun, 19 Jan 2025 11:23:20 +0100 Subject: [PATCH] Add reflector PTY command NODE BLOCK --- src/svxlink/reflector/Reflector.cpp | 27 +++++++++++++++++++++++ src/svxlink/reflector/ReflectorClient.cpp | 11 ++++++++- src/versions | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index b107ba259..e22583ca8 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -1447,6 +1447,33 @@ void Reflector::ctrlPtyDataReceived(const void *buf, size_t count) } m_cfg->setValue(section, tag, value); } + else if (cmd == "NODE") + { + std::string subcmd, callsign; + unsigned blocktime; + if (!(ss >> subcmd >> callsign >> blocktime)) + { + errss << "Invalid NODE PTY command '" << cmdline << "'. " + "Usage: NODE BLOCK "; + goto write_status; + } + if (subcmd == "BLOCK") + { + auto node = ReflectorClient::lookup(callsign); + if (node == nullptr) + { + errss << "Could not find node " << callsign; + goto write_status; + } + node->setBlock(blocktime); + } + else + { + errss << "Invalid NODE PTY command '" << cmdline << "'. " + "Usage: NODE BLOCK "; + goto write_status; + } + } else if (cmd == "CA") { std::string subcmd; diff --git a/src/svxlink/reflector/ReflectorClient.cpp b/src/svxlink/reflector/ReflectorClient.cpp index b7c0026df..8dc24a294 100644 --- a/src/svxlink/reflector/ReflectorClient.cpp +++ b/src/svxlink/reflector/ReflectorClient.cpp @@ -331,6 +331,15 @@ void ReflectorClient::sendUdpMsg(const ReflectorUdpMsg &msg) void ReflectorClient::setBlock(unsigned blocktime) { + if (blocktime > 0) + { + std::cout << m_callsign << ": Blocking talker for " << blocktime + << " seconds" << std::endl; + } + else if (m_blocktime > 0) + { + std::cout << m_callsign << ": Unblocking talker" << std::endl; + } m_blocktime = blocktime; m_remaining_blocktime = blocktime; } /* ReflectorClient::setBlock */ @@ -1186,7 +1195,7 @@ void ReflectorClient::handleHeartbeat(Async::Timer *t) { if (m_remaining_blocktime == 0) { - m_blocktime = 0; + setBlock(0); } else { diff --git a/src/versions b/src/versions index 40153e04c..ccf1106c0 100644 --- a/src/versions +++ b/src/versions @@ -37,4 +37,4 @@ DEVCAL=1.0.3.99.2 SVXSERVER=0.0.6 # Version for SvxReflector -SVXREFLECTOR=1.2.99.19 +SVXREFLECTOR=1.2.99.20