From 6b1d610153fd49d3e979cc9f2dc3eb186a92cf99 Mon Sep 17 00:00:00 2001 From: Tobias Blomberg Date: Sat, 28 Sep 2019 19:40:30 +0200 Subject: [PATCH] Rework ReflectorLogic command structure The command structure for the ReflectorLogic has now been reworked for better usability. Each command is prefixed with the prefix specified in the logic linking configuration but that has been left out in the list below, as well as the # command termination symbol. * -- info/status 1 -- Select previous TG 1nnn -- Select TG nnn 2 -- QSY to "private" TG 2nnn -- QSY to TG nnn 3 -- Follow last QSY --- src/svxlink/svxlink/ReflectorLogic.cpp | 47 ++++++++++++++++++-------- src/svxlink/svxlink/ReflectorLogic.tcl | 25 +++++++++----- src/versions | 2 +- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/svxlink/svxlink/ReflectorLogic.cpp b/src/svxlink/svxlink/ReflectorLogic.cpp index 589ab5b3..8527b4df 100644 --- a/src/svxlink/svxlink/ReflectorLogic.cpp +++ b/src/svxlink/svxlink/ReflectorLogic.cpp @@ -319,11 +319,38 @@ void ReflectorLogic::remoteCmdReceived(LogicBase* src_logic, { processEvent("report_tg_status"); } - else if (cmd.substr(0, 2) == "*1") // QSY + //else if (cmd[0] == '0') // Help + //{ + + //} + else if (cmd[0] == '1') // Select TG + { + const std::string subcmd(cmd.substr(1)); + if (!subcmd.empty()) // Select specified TG + { + istringstream is(subcmd); + uint32_t tg; + if (is >> tg) + { + selectTg(tg, "tg_command_activation"); + m_tg_local_activity = true; + } + else + { + processEvent(std::string("command_failed ") + cmd); + } + } + else // Select previous TG + { + selectTg(m_previous_tg, "tg_command_activation"); + m_tg_local_activity = true; + } + } + else if (cmd[0] == '2') // QSY { if ((m_selected_tg != 0) && isLoggedIn()) { - const std::string subcmd(cmd.substr(2)); + const std::string subcmd(cmd.substr(1)); if (subcmd.empty()) { cout << name() << ": Requesting QSY to random TG" << endl; @@ -349,7 +376,7 @@ void ReflectorLogic::remoteCmdReceived(LogicBase* src_logic, processEvent(std::string("command_failed ") + cmd); } } - else if (cmd == "*2") // Follow last QSY + else if (cmd == "3") // Follow last QSY { if ((m_last_qsy > 0) && (m_last_qsy != m_selected_tg)) { @@ -361,19 +388,9 @@ void ReflectorLogic::remoteCmdReceived(LogicBase* src_logic, processEvent(std::string("command_failed ") + cmd); } } - else // Choose TG + else { - istringstream is(cmd); - uint32_t tg; - if (is >> tg) - { - selectTg(tg, "tg_command_activation"); - m_tg_local_activity = true; - } - else - { - processEvent(std::string("command_failed ") + cmd); - } + processEvent(std::string("unknown_command ") + cmd); } } /* ReflectorLogic::remoteCmdReceived */ diff --git a/src/svxlink/svxlink/ReflectorLogic.tcl b/src/svxlink/svxlink/ReflectorLogic.tcl index 06bff04e..577ce813 100644 --- a/src/svxlink/svxlink/ReflectorLogic.tcl +++ b/src/svxlink/svxlink/ReflectorLogic.tcl @@ -35,6 +35,23 @@ if {$logic_name != [namespace tail [namespace current]]} { } +# +# Executed when an unknown command is received +# cmd - The command string +# +proc unknown_command {cmd} { + Logic::unknown_command $cmd; +} + + +# +# Executed when a received command fails +# +proc command_failed {cmd} { + Logic::command_failed $cmd; +} + + # # Executed when manual TG announcement is triggered # @@ -195,14 +212,6 @@ proc tg_selection_timeout {new_tg old_tg} { } -# -# Executed when an entered DTMF command failed -# -proc command_failed {cmd} { - Logic::command_failed $cmd; -} - - # # Executed on talker start # diff --git a/src/versions b/src/versions index bbec692e..e1cf5653 100644 --- a/src/versions +++ b/src/versions @@ -11,7 +11,7 @@ LIBECHOLIB=1.3.3 LIBASYNC=1.6.0.99.2-reflector_tg # SvxLink versions -SVXLINK=1.7.99.4-reflector_tg +SVXLINK=1.7.99.5-reflector_tg MODULE_HELP=1.0.0 MODULE_PARROT=1.1.1 MODULE_ECHO_LINK=1.5.0