Skip to content

Commit

Permalink
Add reflector PTY command NODE BLOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
sm0svx committed Jan 19, 2025
1 parent 5c88219 commit 9cc2491
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/svxlink/reflector/Reflector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <callsign> <blocktime seconds>";
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 <callsign> <blocktime seconds>";
goto write_status;
}
}
else if (cmd == "CA")
{
std::string subcmd;
Expand Down
11 changes: 10 additions & 1 deletion src/svxlink/reflector/ReflectorClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -1186,7 +1195,7 @@ void ReflectorClient::handleHeartbeat(Async::Timer *t)
{
if (m_remaining_blocktime == 0)
{
m_blocktime = 0;
setBlock(0);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/versions
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9cc2491

Please sign in to comment.