Skip to content

Commit

Permalink
Improve control channel detection. (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadscottsmith authored May 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 172b49a commit 8b38fdb
Showing 4 changed files with 28 additions and 5 deletions.
19 changes: 16 additions & 3 deletions trunk-recorder/monitor_systems.cc
Original file line number Diff line number Diff line change
@@ -546,7 +546,7 @@ void handle_call_update(TrunkMessage message, System *sys, std::vector<Call *> &
}
}

void handle_message(std::vector<TrunkMessage> messages, System *sys, Config &config, std::vector<Source *> &sources, std::vector<Call *> &calls) {
void handle_message(std::vector<TrunkMessage> messages, System *sys, Config &config, std::vector<Source *> &sources, std::vector<Call *> &calls, gr::top_block_sptr &tb) {
for (std::vector<TrunkMessage>::iterator it = messages.begin(); it != messages.end(); it++) {
TrunkMessage message = *it;

@@ -624,6 +624,19 @@ void handle_message(std::vector<TrunkMessage> 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::vector<Source

if (system->get_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);
}

1 change: 1 addition & 0 deletions trunk-recorder/monitor_systems.h
Original file line number Diff line number Diff line change
@@ -15,4 +15,5 @@
#include <gnuradio/top_block.h>

int monitor_messages(Config &config, gr::top_block_sptr &tb, std::vector<Source *> &sources, std::vector<System *> &systems, std::vector<Call *> &calls);
void retune_system(System *sys, gr::top_block_sptr &tb, std::vector<Source *> &sources);
#endif
11 changes: 9 additions & 2 deletions trunk-recorder/systems/p25_parser.cc
Original file line number Diff line number Diff line change
@@ -972,6 +972,7 @@ std::vector<TrunkMessage> 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<TrunkMessage> 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<TrunkMessage> 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<TrunkMessage> 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;
2 changes: 2 additions & 0 deletions trunk-recorder/systems/parser.h
Original file line number Diff line number Diff line change
@@ -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
};

0 comments on commit 8b38fdb

Please sign in to comment.