Skip to content

Commit

Permalink
Optional Per Talkgroup Squelch
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Mar 9, 2024
1 parent 031c28d commit 7315175
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 17 deletions.
7 changes: 6 additions & 1 deletion trunk-recorder/call_conventional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "recorders/recorder.h"
#include <boost/algorithm/string.hpp>

Call_conventional::Call_conventional(long t, double f, System *s, Config c) : Call_impl(t, f, s, c) {
Call_conventional::Call_conventional(long t, double f, System *s, Config c, double squelch_db) : Call_impl(t, f, s, c) {
this->squelch_db = squelch_db;
}

void Call_conventional::restart_call() {
Expand Down Expand Up @@ -39,3 +40,7 @@ void Call_conventional::set_recorder(Recorder *r) {
void Call_conventional::recording_started() {
start_time = time(NULL);
}

double Call_conventional::get_squelch_db() {
return squelch_db;
}
5 changes: 4 additions & 1 deletion trunk-recorder/call_conventional.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class Recorder;

class Call_conventional : public Call_impl {
public:
Call_conventional(long t, double f, System *s, Config c);
Call_conventional(long t, double f, System *s, Config c, double squelch_db);
time_t get_start_time();
bool is_conventional() { return true; }
void restart_call();
void set_recorder(Recorder *r);
void recording_started();
double get_squelch_db();
private:
double squelch_db;
};

#endif
3 changes: 2 additions & 1 deletion trunk-recorder/recorders/analog_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ bool analog_recorder::start(Call *call) {
talkgroup = call->get_talkgroup();
chan_freq = call->get_freq();

squelch_db = system->get_squelch_db();
Call_conventional *conventional_call = dynamic_cast<Call_conventional *>(call);
squelch_db = conventional_call->get_squelch_db();
prefilter->set_squelch_db(squelch_db);
BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting Analog Recorder Num [" << rec_num << "]\u001b[0m \tSquelch: " << squelch_db;

Expand Down
3 changes: 2 additions & 1 deletion trunk-recorder/recorders/dmr_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ bool dmr_recorder_impl::start(Call *call) {
chan_freq = call->get_freq();
this->call = call;

squelch_db = system->get_squelch_db();
Call_conventional *conventional_call = dynamic_cast<Call_conventional *>(call);
squelch_db = conventional_call->get_squelch_db();
prefilter->set_squelch_db(squelch_db);

BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting DMR Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot();
Expand Down
7 changes: 5 additions & 2 deletions trunk-recorder/recorders/p25_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,11 @@ bool p25_recorder_impl::start(Call *call) {
chan_freq = call->get_freq();
this->call = call;

squelch_db = system->get_squelch_db();
prefilter->set_squelch_db(squelch_db);
if (conventional) {
Call_conventional *conventional_call = dynamic_cast<Call_conventional *>(call);
squelch_db = conventional_call->get_squelch_db();
prefilter->set_squelch_db(squelch_db);
}

BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot() << "\tQPSK: " << qpsk_mod;

Expand Down
10 changes: 8 additions & 2 deletions trunk-recorder/recorders/sigmf_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ bool sigmf_recorder_impl::start(Call *call) {
System *system = call->get_system();
talkgroup = call->get_talkgroup();
freq = call->get_freq();
squelch_db = system->get_squelch_db();
prefilter->set_squelch_db(squelch_db);

if (conventional) {
Call_conventional *conventional_call = dynamic_cast<Call_conventional *>(call);
squelch_db = conventional_call->get_squelch_db();
prefilter->set_squelch_db(squelch_db);
}

int offset_amount = (center - freq);
prefilter->tune_offset(offset_amount);

//freq_xlat->set_center_freq(-offset_amount);
BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(freq) << "\t\u001b[32mStarting SigMF Recorder Num [" << rec_num << "]\u001b[0m";

Expand Down
9 changes: 7 additions & 2 deletions trunk-recorder/setup_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ bool setup_conventional_channel(System *system, double frequency, long channel_i
if (system->has_channel_file()) {
Talkgroup *tg = system->find_talkgroup_by_freq(frequency);
tone_freq = tg->tone;
call = new Call_conventional(tg->number, tg->freq, system, config);
if (tg->squelch_db != 999) {
call = new Call_conventional(tg->number, tg->freq, system, config, tg->squelch_db);
} else {
call = new Call_conventional(tg->number, tg->freq, system, config, system->get_squelch_db());
}

call->set_talkgroup_tag(tg->alpha_tag);
} else {
call = new Call_conventional(channel_index, frequency, system, config);
call = new Call_conventional(channel_index, frequency, system, config, system->get_squelch_db());
}
BOOST_LOG_TRIVIAL(info) << "[" << system->get_short_name() << "]\tMonitoring " << system->get_system_type() << " channel: " << format_freq(frequency) << " Talkgroup: " << channel_index;
if (system->get_system_type() == "conventional") {
Expand Down
13 changes: 11 additions & 2 deletions trunk-recorder/talkgroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ Talkgroup::Talkgroup(int sys_num, long num, std::string mode, std::string alpha_
this->group = group;
this->priority = priority;
this->active = false;
this->preferredNAC = preferredNAC;

// This talkgroup is for a Trunked system and freq and tone are not used
this->freq = 0;
this->tone = 0;
this->preferredNAC = preferredNAC;
this->squelch_db = 999;
this->signal_detection = false;

}

Talkgroup::Talkgroup(int sys_num, long num, double freq, double tone, std::string alpha_tag, std::string description, std::string tag, std::string group) {
Talkgroup::Talkgroup(int sys_num, long num, double freq, double tone, std::string alpha_tag, std::string description, std::string tag, std::string group, double squelch_db, bool signal_detection) {
this->sys_num = sys_num;
this->number = num;
this->mode = "Z";
Expand All @@ -26,6 +31,10 @@ Talkgroup::Talkgroup(int sys_num, long num, double freq, double tone, std::strin
this->active = false;
this->freq = freq;
this->tone = tone;
this->squelch_db = squelch_db;
this->signal_detection = signal_detection;

// This talkgroup is for a Conventional system and priority and preferredNAC are not used
this->priority = 0;
this->preferredNAC = 0;
}
Expand Down
4 changes: 3 additions & 1 deletion trunk-recorder/talkgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ class Talkgroup {
std::string group;
int priority;
int sys_num;
double squelch_db;
bool signal_detection;


// For Conventional
double freq;
double tone;

Talkgroup(int sys_num, long num, std::string mode, std::string alpha_tag, std::string description, std::string tag, std::string group, int priority, unsigned long preferredNAC);
Talkgroup(int sys_num, long num, double freq, double tone, std::string alpha_tag, std::string description, std::string tag, std::string group);
Talkgroup(int sys_num, long num, double freq, double tone, std::string alpha_tag, std::string description, std::string tag, std::string group, double squelch_db, bool signal_detection);

bool is_active();
int get_priority();
Expand Down
21 changes: 17 additions & 4 deletions trunk-recorder/talkgroups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ void Talkgroups::load_channels(int sys_num, std::string filename) {
format.trim({' ', '\t'});
CSVReader reader(filename, format);
std::vector<std::string> headers = reader.get_col_names();
std::vector<std::string> defined_headers = {"TG Number", "Tone", "Frequency", "Alpha Tag", "Description", "Category", "Tag", "Enable", "Comment"};
std::vector<std::string> defined_headers = {"TG Number", "Tone", "Frequency", "Alpha Tag", "Description", "Category", "Tag", "Enable", "Comment", "Signal Detection", "Squelch"};

if (headers[0] != "TG Number") {

BOOST_LOG_TRIVIAL(error) << "Column Headers are required for Channel CSV files";
BOOST_LOG_TRIVIAL(error) << "The first column must be 'TG Number'";
BOOST_LOG_TRIVIAL(error) << "Required columns are: 'TG Number', 'Tone', 'Frequency',";
BOOST_LOG_TRIVIAL(error) << "Optional columns are: 'Alpha Tag', 'Description', 'Category', 'Tag', 'Enable', 'Comment'";
BOOST_LOG_TRIVIAL(error) << "Optional columns are: 'Alpha Tag', 'Description', 'Category', 'Tag', 'Enable', 'Comment', 'Signal Detection', 'Squelch'";
exit(0);
} else {
BOOST_LOG_TRIVIAL(info) << "Found Columns: " << internals::format_row(reader.get_col_names(), ", ");
Expand All @@ -142,7 +142,7 @@ void Talkgroups::load_channels(int sys_num, std::string filename) {
if (find(defined_headers.begin(), defined_headers.end(), headers[i]) == defined_headers.end()) {
BOOST_LOG_TRIVIAL(error) << "Unknown column header: " << headers[i];
BOOST_LOG_TRIVIAL(error) << "Required columns are: 'TG Number', 'Tone', 'Frequency',";
BOOST_LOG_TRIVIAL(error) << "Optional columns are: 'Alpha Tag', 'Description', 'Category', 'Tag', 'Enable', 'Comment'";
BOOST_LOG_TRIVIAL(error) << "Optional columns are: 'Alpha Tag', 'Description', 'Category', 'Tag', 'Enable', 'Comment', 'Signal Detection', 'Squelch'";
exit(0);
}
}
Expand All @@ -155,6 +155,8 @@ void Talkgroups::load_channels(int sys_num, std::string filename) {
std::string description = "";
std::string tag = "";
std::string group = "";
double squelch_db = 999;
bool signal_detection = true;
double freq = 0;
double tone = 0;
bool enable = true;
Expand Down Expand Up @@ -194,13 +196,24 @@ void Talkgroups::load_channels(int sys_num, std::string filename) {
}
}

if ((reader.index_of("Squelch") >= 0) && row["Squelch"].is_num()) {
squelch_db = row["Squelch"].get<double>();
}

if ((reader.index_of("Signal Detection") >= 0) && row["Signal Detection"].is_str()) {
if (boost::iequals(row["Signal Detection"].get<std::string>(), "false")) {
signal_detection = false;
}
}


if ((reader.index_of("Enable") >= 0) && row["Enable"].is_str()) {
if (boost::iequals(row["Enable"].get<std::string>(), "false")) {
enable = false;
}
}
if (enable) {
tg = new Talkgroup(sys_num, tg_number, freq, tone, alpha_tag, description, tag, group);
tg = new Talkgroup(sys_num, tg_number, freq, tone, alpha_tag, description, tag, group, squelch_db, signal_detection);
talkgroups.push_back(tg);
lines_pushed++;
}
Expand Down

0 comments on commit 7315175

Please sign in to comment.