From 8b38fdb6a26bde6fa65c462565f030c9c9659eb4 Mon Sep 17 00:00:00 2001 From: tadscottsmith <78445808+tadscottsmith@users.noreply.github.com> Date: Tue, 21 May 2024 20:51:59 -0500 Subject: [PATCH] Improve control channel detection. (#956) --- trunk-recorder/monitor_systems.cc | 19 ++++++++++++++++--- trunk-recorder/monitor_systems.h | 1 + trunk-recorder/systems/p25_parser.cc | 11 +++++++++-- trunk-recorder/systems/parser.h | 2 ++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/trunk-recorder/monitor_systems.cc b/trunk-recorder/monitor_systems.cc index c9d49ad2c..7fb235012 100644 --- a/trunk-recorder/monitor_systems.cc +++ b/trunk-recorder/monitor_systems.cc @@ -546,7 +546,7 @@ void handle_call_update(TrunkMessage message, System *sys, std::vector & } } -void handle_message(std::vector messages, System *sys, Config &config, std::vector &sources, std::vector &calls) { +void handle_message(std::vector messages, System *sys, Config &config, std::vector &sources, std::vector &calls, gr::top_block_sptr &tb) { for (std::vector::iterator it = messages.begin(); it != messages.end(); it++) { TrunkMessage message = *it; @@ -624,6 +624,19 @@ void handle_message(std::vector messages, System *sys, Config &con unit_answer_request(sys, message.source, message.talkgroup); break; + case INVALID_CC_MESSAGE: + { + //Do not count messages that aren't valid TSBK or MBTs. + int msg_count = sys->get_message_count(); + if(msg_count > 1){ + sys->set_message_count(msg_count - 1); + } + } + + case TDULC: + retune_system(sys,tb,sources); + break; + case UNKNOWN: break; } @@ -811,13 +824,13 @@ int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vectorget_system_type() == "smartnet") { trunk_messages = smartnet_parser->parse_message(msg->to_string(), system); - handle_message(trunk_messages, system, config, sources, calls); + handle_message(trunk_messages, system, config, sources, calls, tb); plugman_trunk_message(trunk_messages, system); } if (system->get_system_type() == "p25") { trunk_messages = p25_parser->parse_message(msg, system); - handle_message(trunk_messages, system, config, sources, calls); + handle_message(trunk_messages, system, config, sources, calls, tb); plugman_trunk_message(trunk_messages, system); } diff --git a/trunk-recorder/monitor_systems.h b/trunk-recorder/monitor_systems.h index e4889e1b4..6b30acbc9 100644 --- a/trunk-recorder/monitor_systems.h +++ b/trunk-recorder/monitor_systems.h @@ -15,4 +15,5 @@ #include int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vector &sources, std::vector &systems, std::vector &calls); +void retune_system(System *sys, gr::top_block_sptr &tb, std::vector &sources); #endif \ No newline at end of file diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index 74bf9fc15..0c7633886 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -972,6 +972,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System return messages; } else if (type < 0) { BOOST_LOG_TRIVIAL(debug) << "unknown message type " << type; + message.message_type = INVALID_CC_MESSAGE; messages.push_back(message); return messages; } @@ -980,7 +981,8 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System if (s.length() < 2) { BOOST_LOG_TRIVIAL(error) << "P25 Parse error, s: " << s << " Len: " << s.length(); - //messages.push_back(message); + message.message_type = INVALID_CC_MESSAGE; + messages.push_back(message); return messages; } @@ -1005,7 +1007,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System // //" at %f state %d len %d" %(nac, type, time.time(), self.state, len(s)) if ((type != 7) && (type != 12)) // and nac not in self.trunked_systems: { - BOOST_LOG_TRIVIAL(debug) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + BOOST_LOG_TRIVIAL(debug) << std::hex << "NON TSBK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); /* if not self.configs: @@ -1081,6 +1083,11 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System return decode_mbt_data(opcode, header, mbt_data, link_id, nac, sys_num); // self.trunked_systems[nac].decode_mbt_data(opcode, header << 16, mbt_data // << 32) + } else if (type == 15) + { + //TDU with Link Contol. Link Control words should not be seen on an active Control Channel. + BOOST_LOG_TRIVIAL(debug) << "P25 Parser: TDULC on control channel. Retuning to next control channel."; + message.message_type = TDULC; } messages.push_back(message); return messages; diff --git a/trunk-recorder/systems/parser.h b/trunk-recorder/systems/parser.h index dbae447e8..f435d2cb6 100644 --- a/trunk-recorder/systems/parser.h +++ b/trunk-recorder/systems/parser.h @@ -20,6 +20,8 @@ enum MessageType { UU_ANS_REQ = 13, UU_V_GRANT = 14, UU_V_UPDATE = 15, + INVALID_CC_MESSAGE = 16, + TDULC = 17, UNKNOWN = 99 };