P2 - TDMA-CC Tuning Bugfix and callstring tweak;

This commit is contained in:
lwvmobile 2023-03-21 20:58:37 -04:00
parent 1737c1f7e9
commit 313759333e
2 changed files with 35 additions and 6 deletions

View File

@ -703,12 +703,23 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
} }
else fprintf (stderr, "VCH S "); 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) if (duid_decoded == 0)
{ {
fprintf (stderr, " 4V %d", state->fourv_counter[state->currentslot]+1); fprintf (stderr, " 4V %d", state->fourv_counter[state->currentslot]+1);
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 && 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->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
{ {
state->last_vc_sync_time = time(NULL);
process_4V (opts, state); process_4V (opts, state);
} }
} }
@ -718,6 +729,7 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
if (state->p2_wacn != 0 && state->p2_cc != 0 && state->p2_sysid != 0 && 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->p2_wacn != 0xFFFFF && state->p2_cc != 0xFFF && state->p2_sysid != 0xFFF)
{ {
state->last_vc_sync_time = time(NULL);
process_2V (opts, state); process_2V (opts, state);
} }
} }
@ -815,22 +827,21 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state)
void processP2 (dsd_opts * opts, dsd_state * state) void processP2 (dsd_opts * opts, dsd_state * state)
{ {
state->dmr_stereo = 1; state->dmr_stereo = 1;
//state->currentslot = 1;
p2_dibit_buffer (opts, state); p2_dibit_buffer (opts, state);
//look at our ISCH values and determine location in superframe before running frame scramble //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 //set initial current slot depending on offset value
if (state->p2_scramble_offset % 2) 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 //frame_scramble runs lfsr and creates an array of unscrambled bits to pull from
process_Frame_Scramble (opts, state); process_Frame_Scramble (opts, state);

View File

@ -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 //Figure out which PDU we are looking at, see above info on 8.4.1
//reorganize bits into bytes and process accordingly //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 unsigned long long int SMAC[24] = {0}; //22.5 bytes for SACCH MAC PDUs
int byte = 0; int byte = 0;
int k = 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 //close any open MBEout files
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state); 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) if (state->currentslot == 0)
{ {
@ -236,6 +242,9 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
fprintf (stderr, "%s", KYEL); fprintf (stderr, "%s", KYEL);
process_MAC_VPDU(opts, state, 1, SMAC); process_MAC_VPDU(opts, state, 1, SMAC);
fprintf (stderr, "%s", KNRM); 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) if (opcode == 0x4 && err == 0)
{ {
@ -279,6 +288,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 //Figure out which PDU we are looking at, see above info on 8.4.1
//reorganize bits into bytes and process accordingly //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 unsigned long long int FMAC[24] = {0}; //19.5 bytes for FACCH MAC PDUs, add padding to end
int byte = 0; int byte = 0;
int k = 0; int k = 0;
@ -432,6 +444,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
//close any open MBEout files //close any open MBEout files
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state); 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) if (state->currentslot == 1)
@ -483,6 +498,9 @@ void process_FACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[156]
fprintf (stderr, "%s", KYEL); fprintf (stderr, "%s", KYEL);
process_MAC_VPDU(opts, state, 0, FMAC); process_MAC_VPDU(opts, state, 0, FMAC);
fprintf (stderr, "%s", KNRM); fprintf (stderr, "%s", KNRM);
//blank the call string here
sprintf (state->call_string[slot], "%s", " "); //21 spaces
} }
if (opcode == 0x4 && err == 0) if (opcode == 0x4 && err == 0)
{ {