Skip to content

Commit

Permalink
adding since_last_update functionality
Browse files Browse the repository at this point in the history
can be used to keep calls open while voice channel is active

are changes to p25_recorder_impl.h and p25_frame_assembler_impl.h correct?
  • Loading branch information
rosecitytransit committed Apr 2, 2023
1 parent 6185519 commit c7bc0bb
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ namespace gr {
virtual void reset_timer() {}
virtual void set_phase2_tdma(bool p) {}
virtual void clear() {};
virtual void clear_silence_frame_count() {};
virtual void clear_silence_frame_count() {};
virtual double since_last_update() = 0;
};

} // namespace op25_repeater
Expand Down
5 changes: 5 additions & 0 deletions lib/op25_repeater/lib/p25_frame_assembler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
namespace gr {
namespace op25_repeater {

double p25_frame_assembler_impl::since_last_update() {
time_t now = time(NULL);
return now - p1fdma.get_rx_status().last_update;
}

/* This is for the TPS Analog decoder */
void p25_frame_assembler_impl::p25p2_queue_msg(int duid) {
static const unsigned char wbuf[2] = {0xff, 0xff}; // dummy NAC
Expand Down
1 change: 1 addition & 0 deletions lib/op25_repeater/lib/p25_frame_assembler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace gr {

void clear_silence_frame_count();
void clear();
double since_last_update();
};

} // namespace op25_repeater
Expand Down
8 changes: 4 additions & 4 deletions trunk-recorder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -852,15 +852,15 @@ void manage_calls() {

// Handle Trunked Calls
if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) {
if (state == RECORDING) {
/* if (state == RECORDING) {
ended_call = true;
call->set_record_more_transmissions(false);
call->set_state(INACTIVE);
// set the call state to inactive
// If the call is being recorded and the wav_sink is already hit a termination flag, the call state is set to COMPLETED
// call->stop_call();
}
} */
// we do not need to stop Monitoring Calls, we can just delete them
if (state == MONITORING) {
ended_call = true;
Expand Down Expand Up @@ -888,12 +888,12 @@ void manage_calls() {
}

// We are checking to make sure a Call hasn't gotten stuck. If it is in the INACTIVE state
if (state == INACTIVE) {
if ((state == INACTIVE) || (state == RECORDING)) {
Recorder *recorder = call->get_recorder();
if (recorder != NULL) {

// if the recorder has simply been going for a while and a call is inactive, end things
if (call->since_last_update() > config.call_timeout) {
if (recorder->since_last_update() > config.call_timeout) {
// BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state();
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 Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state();

Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/recorders/p25_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class p25_recorder : virtual public gr::hier_block2, virtual public Recorder {
virtual void set_record_more_transmissions(bool more) = 0;
virtual void set_source(long src) = 0;
virtual double since_last_write() = 0;
virtual double since_last_update() = 0;
virtual double get_current_length() = 0;
virtual bool is_active() = 0;
virtual bool is_idle() = 0;
Expand Down
4 changes: 4 additions & 0 deletions trunk-recorder/recorders/p25_recorder_decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ double p25_recorder_decode::since_last_write() {
return now - wav_sink->get_stop_time();
}

double p25_recorder_decode::since_last_update() {
return op25_frame_assembler->since_last_update();
}

void p25_recorder_decode::switch_tdma(bool phase2_tdma) {
op25_frame_assembler->set_phase2_tdma(phase2_tdma);
}
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/recorders/p25_recorder_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class p25_recorder_decode : public gr::hier_block2 {
void switch_tdma(bool phase2_tdma);
void start(Call *call);
double since_last_write();
double since_last_update();
void stop();
int tdma_slot;
bool delay_open;
Expand Down
8 changes: 8 additions & 0 deletions trunk-recorder/recorders/p25_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ double p25_recorder_impl::since_last_write() {
}
}

double p25_recorder_impl::since_last_update() {
if (qpsk_mod) {
return qpsk_p25_decode->since_last_update();
} else {
return fsk4_p25_decode->since_last_update();
}
}

State p25_recorder_impl::get_state() {
if (qpsk_mod) {
return qpsk_p25_decode->get_state();
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/recorders/p25_recorder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class p25_recorder_impl : public p25_recorder {
void set_record_more_transmissions(bool more);
void set_source(long src);
double since_last_write();
double since_last_update();
void generate_arb_taps();
double get_current_length();
bool is_active();
Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/recorders/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Recorder {
virtual bool is_squelched() { return true; };
virtual double get_current_length() { return 0; };
virtual double since_last_write() { return 0; };
virtual double since_last_update() { return 0; };
virtual void clear(){};
int rec_num;
static int rec_counter;
Expand Down

0 comments on commit c7bc0bb

Please sign in to comment.