diff --git a/src/nxdn_element.c b/src/nxdn_element.c index 2e3df93..53a1efc 100644 --- a/src/nxdn_element.c +++ b/src/nxdn_element.c @@ -98,6 +98,36 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state, //DISC case 0x11: //NXDN_decode_VCALL(opts, state, ElementsContent); + + //tune back to CC here - save about 1-2 seconds + if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && opts->p25_is_tuned == 1) + { + //rigctl + if (opts->use_rigctl == 1) + { + //extra safeguards due to sync issues with NXDN + memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment)); + memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); + // state->lastsynctype = -1; + // state->last_cc_sync_time = time(NULL); + opts->p25_is_tuned = 0; + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); + SetFreq(opts->rigctl_sockfd, state->p25_cc_freq); + + } + //rtl_udp + else if (opts->audio_in_type == 3) + { + //extra safeguards due to sync issues with NXDN + memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment)); + memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc)); + // state->lastsynctype = -1; + // state->last_cc_sync_time = time(NULL); + opts->p25_is_tuned = 0; + rtl_udp_tune (opts, state, state->p25_cc_freq); + } + } + break; //Idle @@ -670,8 +700,8 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message) //check the rkey array for a scrambler key value //check by keyid first, then by tgt id //TGT ID and Key ID could clash though if csv or system has both with different keys - // if (state->rkey_array[KeyID] != 0) state->R = state->rkey_array[KeyID]; - if (state->rkey_array[DestinationID] != 0) state->R = state->rkey_array[DestinationID]; + if (state->rkey_array[KeyID] != 0) state->R = state->rkey_array[KeyID]; + else if (state->rkey_array[DestinationID] != 0) state->R = state->rkey_array[DestinationID]; if (state->M == 1) {