diff --git a/include/dsd.h b/include/dsd.h index 535f5ee..e17f0a8 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -703,6 +703,7 @@ typedef struct time_t last_cc_sync_time; //use this to start hunting for CC after signal lost time_t last_vc_sync_time; //flag for voice activity bursts, tune back on con+ after more than x seconds no voice time_t last_active_time; //time the a 'call grant' was received, used to clear the active_channel strings after x seconds + time_t last_t3_tune_time; //last time a DMR T3 grant was received, this is used to prevent a rogue p_clear condition from immediately sending back to CC int is_con_plus; //con_plus flag for knowing its safe to skip payload channel after x seconds of no voice sync //new nxdn stuff diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index 7e2d264..7cc5d3b 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -297,7 +297,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop - state->last_vc_sync_time = time(NULL); //set here so a random p_clear on the opposite slot doesn't send us back to the CC + state->last_vc_sync_time = time(NULL); + state->last_t3_tune_time = time(NULL); //set here so a random p_clear on the opposite slot doesn't send us back to the CC } @@ -325,7 +326,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 rtl_dev_tune (opts, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; - state->last_vc_sync_time = time(NULL); //set here so a random p_clear on the opposite slot doesn't send us back to the CC + state->last_vc_sync_time = time(NULL); + state->last_t3_tune_time = time(NULL); //set here so a random p_clear on the opposite slot doesn't send us back to the CC #endif } @@ -406,6 +408,9 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 if (state->currentslot == 0 && state->tg_hold == state->lasttg && state->tg_hold != 0) clear = 4; if (state->currentslot == 1 && state->tg_hold == state->lasttgR && state->tg_hold != 0) clear = 5; + //make sure we aren't sent back immediately by an p_clear condition upon first tuning (i.e., random ENC LO, or end of Data Call) + if ( time(NULL)-state->last_t3_tune_time < 1) clear = 0; //one second should be an optimal time, not too short, but not too long + //initial line break fprintf (stderr, "\n"); fprintf (stderr, " Clear (P_CLEAR) "); diff --git a/src/dsd_main.c b/src/dsd_main.c index eb27948..5bf51eb 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -1049,6 +1049,7 @@ initState (dsd_state * state) state->last_cc_sync_time = time(NULL); state->last_vc_sync_time = time(NULL); state->last_active_time = time(NULL); + state->last_t3_tune_time = time(NULL); state->is_con_plus = 0; //dmr trunking/ncurses stuff