From 2062502a59ad9f67810faad33280e27e3c2d43fb Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Tue, 21 Mar 2023 20:58:44 -0400 Subject: [PATCH] P2 - TDMA-CC Tuning Bugfix and callstring tweak; --- src/p25p2_frame.c | 23 +++++++++++++++++------ src/p25p2_xcch.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/p25p2_frame.c b/src/p25p2_frame.c index 32f4bb1..bbf3344 100644 --- a/src/p25p2_frame.c +++ b/src/p25p2_frame.c @@ -711,12 +711,23 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state) } else fprintf (stderr, "VCH S "); + //check to see when last voice activity occurred in order to allow tuning on phase 2 + //mac_signal or mac_idle when no more voice activity on current channel + //this is primarily a fix for TDMA control channels that carry voice (Duke P25) + //but may also allow for chain tuning without returning to the control channel <--may be problematic since we can assign a p25_cc_freq from the pdu + if (duid_decoded == 13 && opts->p25_is_tuned == 1 && ((time(NULL) - state->last_vc_sync_time) > opts->trunk_hangtime) ) //version for MAC_SIGNAL only, no idle + { + opts->p25_is_tuned = 0; + state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0; + } + if (duid_decoded == 0) { fprintf (stderr, " 4V %d", state->fourv_counter[state->currentslot]+1); if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 && state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF) { + state->last_vc_sync_time = time(NULL); process_4V (opts, state); } } @@ -726,6 +737,7 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state) if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 && state->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF) { + state->last_vc_sync_time = time(NULL); process_2V (opts, state); } } @@ -823,22 +835,21 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state) void processP2 (dsd_opts * opts, dsd_state * state) { state->dmr_stereo = 1; - //state->currentslot = 1; - p2_dibit_buffer (opts, state); //look at our ISCH values and determine location in superframe before running frame scramble - for (framing_counter = 0; framing_counter < 4; framing_counter++) //12 + for (framing_counter = 0; framing_counter < 4; framing_counter++) { - process_ISCH (opts, state); //run ISCH in here so we know when to start descramble offset + //run ISCH in here so we know when to start descramble offset + process_ISCH (opts, state); } //set initial current slot depending on offset value if (state->p2_scramble_offset % 2) { - state->currentslot = 0; + state->currentslot = 1; } - else state->currentslot = 1; + else state->currentslot = 0; //frame_scramble runs lfsr and creates an array of unscrambled bits to pull from process_Frame_Scramble (opts, state); diff --git a/src/p25p2_xcch.c b/src/p25p2_xcch.c index 64050fa..ea3ea98 100644 --- a/src/p25p2_xcch.c +++ b/src/p25p2_xcch.c @@ -13,6 +13,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180] //Figure out which PDU we are looking at, see above info on 8.4.1 //reorganize bits into bytes and process accordingly + //new slot variable with flipped assignment for SACCH + uint8_t slot = (state->currentslot ^ 1) & 1; + unsigned long long int SMAC[24] = {0}; //22.5 bytes for SACCH MAC PDUs int byte = 0; int k = 0; @@ -206,6 +209,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180] //close any open MBEout files if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state); + //blank the call string here -- slot variable is already flipped accordingly for sacch + sprintf (state->call_string[slot], "%s", " "); //21 spaces + } if (state->currentslot == 0) { @@ -236,6 +242,10 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180] fprintf (stderr, "%s", KYEL); process_MAC_VPDU(opts, state, 1, SMAC); fprintf (stderr, "%s", KNRM); + + //blank the call string here -- slot variable is already flipped accordingly for sacch + sprintf (state->call_string[slot], "%s", " "); //21 spaces + } if (opcode == 0x4 && err == 0) { @@ -280,6 +290,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156] //Figure out which PDU we are looking at, see above info on 8.4.1 //reorganize bits into bytes and process accordingly + //new slot variable + uint8_t slot = state->currentslot; + unsigned long long int FMAC[24] = {0}; //19.5 bytes for FACCH MAC PDUs, add padding to end int byte = 0; int k = 0; @@ -433,6 +446,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156] //close any open MBEout files if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state); + + //blank the call string here + sprintf (state->call_string[slot], "%s", " "); //21 spaces } if (state->currentslot == 1) @@ -484,6 +500,10 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156] fprintf (stderr, "%s", KYEL); process_MAC_VPDU(opts, state, 0, FMAC); fprintf (stderr, "%s", KNRM); + + //blank the call string here + sprintf (state->call_string[slot], "%s", " "); //21 spaces + } if (opcode == 0x4 && err == 0) {