Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P25 Trunking Message Improvements #820

Merged
merged 22 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
REmoved COMPLETED
  • Loading branch information
robotastic committed May 30, 2023
commit c594ab7f64e508d608cacbe0651bdd79bda2bf2e
12 changes: 2 additions & 10 deletions trunk-recorder/call_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ void Call_impl::stop_call() {
// If the call is being recorded, check to see if the recorder is currently in an INACTIVE state. This means that the recorder is not
// doing anything and can be stopped.
if ((state == RECORDING) && this->get_recorder()->is_idle()) {
BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl, setting call state to COMPLETED - Last Update: " << this->since_last_update() << "s";
this->set_state(COMPLETED);
BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl - Last Update: " << this->since_last_update() << "s";
}
}
}
Expand All @@ -113,7 +112,7 @@ void Call_impl::conclude_call() {
// BOOST_LOG_TRIVIAL(info) << "conclude_call()";
stop_time = time(NULL);

if (state == COMPLETED || (state == MONITORING && monitoringState == SUPERSEDED)) {
if (state == RECORDING || (state == MONITORING && monitoringState == SUPERSEDED)) {
final_length = recorder->get_current_length();

if (!recorder) {
Expand All @@ -136,9 +135,6 @@ void Call_impl::conclude_call() {

Call_Concluder::conclude_call(this, sys, config);
}
else {
BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "Concluding call, but call state is not COMPLETED!";
}
}

void Call_impl::set_sigmf_recorder(Recorder *r) {
Expand Down Expand Up @@ -321,16 +317,12 @@ bool Call_impl::add_source(long src) {
}

bool Call_impl::update(TrunkMessage message) {
if ((state == INACTIVE) || (state == COMPLETED)) {
BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tCall_impl Update, but state is: " << state << " - Call_impl TG: " << get_talkgroup() << "\t Call_impl Freq: " << get_freq() << "\tMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq;
} else {
last_update = time(NULL);
if ((message.freq != this->curr_freq) || (message.talkgroup != this->talkgroup)) {
BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tCall_impl Update, message mismatch - Call_impl TG: " << get_talkgroup() << "\t Call_impl Freq: " << get_freq() << "\tMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq;
} else {
return add_source(message.source);
}
}
return false;
}

Expand Down
21 changes: 2 additions & 19 deletions trunk-recorder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,6 @@ void manage_conventional_call(Call *call) {
// if no additional recording has happened in the past X periods, stop and open new file
if (call->get_idle_count() > config.call_timeout) {
Recorder *recorder = call->get_recorder();
call->set_state(COMPLETED);
call->conclude_call();
call->restart_call();
if (recorder != NULL) {
Expand All @@ -801,7 +800,6 @@ void manage_conventional_call(Call *call) {
}
} else if ((call->get_current_length() > call->get_system()->get_max_duration()) && (call->get_system()->get_max_duration() > 0)) {
Recorder *recorder = call->get_recorder();
call->set_state(COMPLETED);
call->conclude_call();
call->restart_call();
if (recorder != NULL) {
Expand Down Expand Up @@ -889,8 +887,6 @@ void manage_calls() {
// actually, we don't want to remove a recorder as soon as it is stopped because we want to drain everything from the gnuradio flowgraph
if ((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) {
BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state());

call->set_state(COMPLETED);
call->conclude_call();
// The State of the Recorders has changed, so lets send an update
ended_call = true;
Expand All @@ -910,8 +906,8 @@ void manage_calls() {
BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Call UPDATEs has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state());

// since the Call state is INACTIVE and the Recorder has been going on for a while, we can now
// set the Call state to COMPLETED
/* call->set_state(COMPLETED);
//
/*
call->conclude_call();
// The State of the Recorders has changed, so lets send an update
ended_call = true;
Expand Down Expand Up @@ -995,12 +991,6 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) {
for (vector<Call *>::iterator it = calls.begin(); it != calls.end();) {
Call *call = *it;

/* This will skip all calls that are not currently acitve */
if (call->get_state() == COMPLETED) {
++it;
continue;
}

/* This is for Multi-Site support */
if (call->get_talkgroup() == message.talkgroup) {
if ((call->get_phase2_tdma() == message.phase2_tdma) && (call->get_tdma_slot() == message.tdma_slot) ) {
Expand Down Expand Up @@ -1074,7 +1064,6 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) {
}
BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m";
/*
call->set_state(COMPLETED);
call->conclude_call();
it = calls.erase(it);
delete call;
Expand Down Expand Up @@ -1143,11 +1132,6 @@ void handle_call_update(TrunkMessage message, System *sys) {
for (vector<Call *>::iterator it = calls.begin(); it != calls.end(); ++it) {
Call *call = *it;

/* This will skip all calls that are not currently acitve */
if (call->get_state() == COMPLETED) {
continue;
}

// BOOST_LOG_TRIVIAL(info) << "TG: " << call->get_talkgroup() << " | " << message.talkgroup << " sys num: " << call->get_sys_num() << " | " << message.sys_num << " freq: " << call->get_freq() << " | " << message.freq << " TDMA Slot" << call->get_tdma_slot() << " | " << message.tdma_slot << " TDMA: " << call->get_phase2_tdma() << " | " << message.phase2_tdma;
if ((call->get_talkgroup() == message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) {
call_found = true;
Expand Down Expand Up @@ -1389,7 +1373,6 @@ void monitor_messages() {
Call *call = *it;

if (call->get_state() != MONITORING) {
call->set_state(COMPLETED);
call->conclude_call();
}

Expand Down