Skip to content

Commit 0d34b3e

Browse files
authored
Revert "Control Channel Retune Handling (#954)" (#955)
This reverts commit a3eda60.
1 parent a3eda60 commit 0d34b3e

File tree

3 files changed

+80
-103
lines changed

3 files changed

+80
-103
lines changed

trunk-recorder/main.cc

Lines changed: 78 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -649,86 +649,6 @@ void handle_call_update(TrunkMessage message, System *sys) {
649649
}
650650
}
651651

652-
System *find_system(int sys_num) {
653-
System *sys_match = NULL;
654-
655-
for (std::vector<System *>::iterator it = systems.begin(); it != systems.end(); ++it) {
656-
System *sys = (System *)*it;
657-
658-
if (sys->get_sys_num() == sys_num) {
659-
sys_match = sys;
660-
break;
661-
}
662-
}
663-
664-
if (sys_match == NULL) {
665-
BOOST_LOG_TRIVIAL(info) << "Sys is null";
666-
}
667-
return sys_match;
668-
}
669-
670-
void retune_system(System *sys) {
671-
System_impl *system = (System_impl *)sys;
672-
bool source_found = false;
673-
Source *current_source = system->get_source();
674-
double control_channel_freq = system->get_next_control_channel();
675-
676-
BOOST_LOG_TRIVIAL(error) << "[" << system->get_short_name() << "] Retuning to Control Channel: " << format_freq(control_channel_freq);
677-
678-
if ((current_source->get_min_hz() <= control_channel_freq) &&
679-
(current_source->get_max_hz() >= control_channel_freq)) {
680-
source_found = true;
681-
BOOST_LOG_TRIVIAL(info) << "\t - System Source " << current_source->get_num() << " - Min Freq: " << format_freq(current_source->get_min_hz()) << " Max Freq: " << format_freq(current_source->get_max_hz());
682-
// The source can cover the System's control channel, break out of the
683-
// For Loop
684-
if (system->get_system_type() == "smartnet") {
685-
system->smartnet_trunking->tune_freq(control_channel_freq);
686-
system->smartnet_trunking->reset();
687-
} else if (system->get_system_type() == "p25") {
688-
system->p25_trunking->tune_freq(control_channel_freq);
689-
} else {
690-
BOOST_LOG_TRIVIAL(error) << "\t - Unknown system type for Retune";
691-
}
692-
} else {
693-
for (vector<Source *>::iterator src_it = sources.begin(); src_it != sources.end(); src_it++) {
694-
Source *source = *src_it;
695-
696-
if ((source->get_min_hz() <= control_channel_freq) &&
697-
(source->get_max_hz() >= control_channel_freq)) {
698-
source_found = true;
699-
BOOST_LOG_TRIVIAL(info) << "\t - System Source " << source->get_num() << " - Min Freq: " << format_freq(source->get_min_hz()) << " Max Freq: " << format_freq(source->get_max_hz());
700-
701-
if (system->get_system_type() == "smartnet") {
702-
system->set_source(source);
703-
// We must lock the flow graph in order to disconnect and reconnect blocks
704-
tb->lock();
705-
tb->disconnect(current_source->get_src_block(), 0, system->smartnet_trunking, 0);
706-
system->smartnet_trunking = make_smartnet_trunking(control_channel_freq, source->get_center(), source->get_rate(), system->get_msg_queue(), system->get_sys_num());
707-
tb->connect(source->get_src_block(), 0, system->smartnet_trunking, 0);
708-
tb->unlock();
709-
system->smartnet_trunking->reset();
710-
} else if (system->get_system_type() == "p25") {
711-
system->set_source(source);
712-
// We must lock the flow graph in order to disconnect and reconnect blocks
713-
tb->lock();
714-
tb->disconnect(current_source->get_src_block(), 0, system->p25_trunking, 0);
715-
system->p25_trunking = make_p25_trunking(control_channel_freq, source->get_center(), source->get_rate(), system->get_msg_queue(), system->get_qpsk_mod(), system->get_sys_num());
716-
tb->connect(source->get_src_block(), 0, system->p25_trunking, 0);
717-
tb->unlock();
718-
} else {
719-
BOOST_LOG_TRIVIAL(error) << "\t - Unkown system type for Retune";
720-
}
721-
722-
// break out of the For Loop
723-
break;
724-
}
725-
}
726-
}
727-
if (!source_found) {
728-
BOOST_LOG_TRIVIAL(error) << "\t - Unable to retune System control channel, freq not covered by any source.";
729-
}
730-
}
731-
732652
void handle_message(std::vector<TrunkMessage> messages, System *sys) {
733653
for (std::vector<TrunkMessage>::iterator it = messages.begin(); it != messages.end(); it++) {
734654
TrunkMessage message = *it;
@@ -807,24 +727,90 @@ void handle_message(std::vector<TrunkMessage> messages, System *sys) {
807727
unit_answer_request(sys, message.source, message.talkgroup);
808728
break;
809729

810-
case INVALID_CC_MESSAGE:
811-
{
812-
//Do not count messages that aren't valid TSBK or MBTs.
813-
int msg_count = sys->get_message_count();
814-
if(msg_count > 1){
815-
sys->set_message_count(msg_count - 1);
816-
}
817-
}
730+
case UNKNOWN:
818731
break;
732+
}
733+
}
734+
}
819735

820-
case TDULC:
821-
retune_system(sys);
822-
break;
736+
System *find_system(int sys_num) {
737+
System *sys_match = NULL;
823738

824-
case UNKNOWN:
739+
for (std::vector<System *>::iterator it = systems.begin(); it != systems.end(); ++it) {
740+
System *sys = (System *)*it;
741+
742+
if (sys->get_sys_num() == sys_num) {
743+
sys_match = sys;
825744
break;
826745
}
827746
}
747+
748+
if (sys_match == NULL) {
749+
BOOST_LOG_TRIVIAL(info) << "Sys is null";
750+
}
751+
return sys_match;
752+
}
753+
754+
void retune_system(System *sys) {
755+
System_impl *system = (System_impl *)sys;
756+
bool source_found = false;
757+
Source *current_source = system->get_source();
758+
double control_channel_freq = system->get_next_control_channel();
759+
760+
BOOST_LOG_TRIVIAL(error) << "[" << system->get_short_name() << "] Retuning to Control Channel: " << format_freq(control_channel_freq);
761+
762+
if ((current_source->get_min_hz() <= control_channel_freq) &&
763+
(current_source->get_max_hz() >= control_channel_freq)) {
764+
source_found = true;
765+
BOOST_LOG_TRIVIAL(info) << "\t - System Source " << current_source->get_num() << " - Min Freq: " << format_freq(current_source->get_min_hz()) << " Max Freq: " << format_freq(current_source->get_max_hz());
766+
// The source can cover the System's control channel, break out of the
767+
// For Loop
768+
if (system->get_system_type() == "smartnet") {
769+
system->smartnet_trunking->tune_freq(control_channel_freq);
770+
system->smartnet_trunking->reset();
771+
} else if (system->get_system_type() == "p25") {
772+
system->p25_trunking->tune_freq(control_channel_freq);
773+
} else {
774+
BOOST_LOG_TRIVIAL(error) << "\t - Unknown system type for Retune";
775+
}
776+
} else {
777+
for (vector<Source *>::iterator src_it = sources.begin(); src_it != sources.end(); src_it++) {
778+
Source *source = *src_it;
779+
780+
if ((source->get_min_hz() <= control_channel_freq) &&
781+
(source->get_max_hz() >= control_channel_freq)) {
782+
source_found = true;
783+
BOOST_LOG_TRIVIAL(info) << "\t - System Source " << source->get_num() << " - Min Freq: " << format_freq(source->get_min_hz()) << " Max Freq: " << format_freq(source->get_max_hz());
784+
785+
if (system->get_system_type() == "smartnet") {
786+
system->set_source(source);
787+
// We must lock the flow graph in order to disconnect and reconnect blocks
788+
tb->lock();
789+
tb->disconnect(current_source->get_src_block(), 0, system->smartnet_trunking, 0);
790+
system->smartnet_trunking = make_smartnet_trunking(control_channel_freq, source->get_center(), source->get_rate(), system->get_msg_queue(), system->get_sys_num());
791+
tb->connect(source->get_src_block(), 0, system->smartnet_trunking, 0);
792+
tb->unlock();
793+
system->smartnet_trunking->reset();
794+
} else if (system->get_system_type() == "p25") {
795+
system->set_source(source);
796+
// We must lock the flow graph in order to disconnect and reconnect blocks
797+
tb->lock();
798+
tb->disconnect(current_source->get_src_block(), 0, system->p25_trunking, 0);
799+
system->p25_trunking = make_p25_trunking(control_channel_freq, source->get_center(), source->get_rate(), system->get_msg_queue(), system->get_qpsk_mod(), system->get_sys_num());
800+
tb->connect(source->get_src_block(), 0, system->p25_trunking, 0);
801+
tb->unlock();
802+
} else {
803+
BOOST_LOG_TRIVIAL(error) << "\t - Unkown system type for Retune";
804+
}
805+
806+
// break out of the For Loop
807+
break;
808+
}
809+
}
810+
}
811+
if (!source_found) {
812+
BOOST_LOG_TRIVIAL(error) << "\t - Unable to retune System control channel, freq not covered by any source.";
813+
}
828814
}
829815

830816
void check_message_count(float timeDiff) {

trunk-recorder/systems/p25_parser.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,6 @@ std::vector<TrunkMessage> P25Parser::parse_message(gr::message::sptr msg, System
964964
return messages;
965965
} else if (type < 0) {
966966
BOOST_LOG_TRIVIAL(debug) << "unknown message type " << type;
967-
message.message_type = INVALID_CC_MESSAGE;
968967
messages.push_back(message);
969968
return messages;
970969
}
@@ -980,7 +979,6 @@ std::vector<TrunkMessage> P25Parser::parse_message(gr::message::sptr msg, System
980979

981980
if (s.length() < 2) {
982981
BOOST_LOG_TRIVIAL(error) << "P25 Parse error, s: " << s << " s0: " << static_cast<int>(s0) << " s1: " << static_cast<int>(s1) << " shift: " << shift << " nac: " << nac << " type: " << type << " Len: " << s.length();
983-
message.message_type = INVALID_CC_MESSAGE;
984982
messages.push_back(message);
985983
return messages;
986984
}
@@ -997,7 +995,8 @@ std::vector<TrunkMessage> P25Parser::parse_message(gr::message::sptr msg, System
997995
// //" at %f state %d len %d" %(nac, type, time.time(), self.state, len(s))
998996
if ((type != 7) && (type != 12)) // and nac not in self.trunked_systems:
999997
{
1000-
BOOST_LOG_TRIVIAL(debug) << std::hex << "NON TSBK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length();
998+
BOOST_LOG_TRIVIAL(debug) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length();
999+
10011000
/*
10021001
if not self.configs:
10031002
# TODO: allow whitelist/blacklist rather than blind automatic-add
@@ -1072,13 +1071,7 @@ std::vector<TrunkMessage> P25Parser::parse_message(gr::message::sptr msg, System
10721071
return decode_mbt_data(opcode, header, mbt_data, link_id, nac, sys_num);
10731072
// self.trunked_systems[nac].decode_mbt_data(opcode, header << 16, mbt_data
10741073
// << 32)
1075-
} else if (type == 15)
1076-
{
1077-
//TDU with Link Contol. Link Control words should not be seen on an active Control Channel.
1078-
BOOST_LOG_TRIVIAL(debug) << "P25 Parser: TDULC on control channel. Retuning to next control channel.";
1079-
message.message_type = TDULC;
10801074
}
1081-
10821075
messages.push_back(message);
10831076
return messages;
10841077
}

trunk-recorder/systems/parser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ enum MessageType {
2020
UU_ANS_REQ = 13,
2121
UU_V_GRANT = 14,
2222
UU_V_UPDATE = 15,
23-
INVALID_CC_MESSAGE = 16,
24-
TDULC = 17,
2523
UNKNOWN = 99
2624
};
2725

0 commit comments

Comments
 (0)