DMR Cap+ Trunk Logic

This commit is contained in:
lwvmobile 2022-12-04 17:10:19 -05:00
parent 68edb9463c
commit b97014ff0b
3 changed files with 92 additions and 8 deletions

View File

@ -388,7 +388,9 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
//Capacity+ Section
if (csbk_fid == 0x10)
{
//will need to ponder the best way to do trunking rules for this
//not quite sure how these tuning rules will go over
//if they don't work so well, may just fall back to
//a 'follow rest channel on no sync' only approach
if (csbk_o == 0x3E)
{
//initial line break
@ -400,7 +402,14 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
uint8_t ch[8]; //one bit per channel
uint8_t tg = 0;
uint32_t tghex = 0; //combined all tgs for debug
int i, k;
int i, j, k;
//tg and channel info for trunking purposes
uint8_t t_tg[9];
uint8_t t_ch[9];
memset (t_tg, 0, sizeof(t_tg));
memset (t_ch, 0, sizeof(t_ch));
k = 0;
if (rest_channel != state->dmr_rest_channel)
{
@ -410,6 +419,12 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
{
ch[i] = cs_pdu_bits[i+24];
}
//assign to cc freq to follow during no sync
if (state->trunk_chan_map[rest_channel] != 0)
{
state->p25_cc_freq = state->trunk_chan_map[rest_channel];
}
fprintf (stderr, " Capacity Plus Channel Status - Rest Channel %d", rest_channel);
@ -421,6 +436,9 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
{
tg = (uint8_t)ConvertBitIntoBytes(&cs_pdu_bits[k*8+32], 8);
fprintf (stderr, " %03d ", tg);
//add values to trunking tg/channel potentials
t_tg[i] = tg;
t_ch[i] = i;
k++;
}
@ -434,6 +452,53 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
state->dmr_mfid = 0x10;
sprintf (state->dmr_branding_sub, "%s", "Cap+ ");
fprintf (stderr, "%s", KNRM);
//tuning logic with active tg's in active channels
if (state->dmrburstL != 16 && state->dmrburstR != 16) //if neither current slot has a voice in it
{
for (j = 0; i < 8; j++) //go through the channels stored looking for active ones to tune to
{
char mode[8]; //allow, block, digital, enc, etc
for (int i = 0; i < state->group_tally; i++)
{
if (state->group_array[i].groupNumber == t_tg[j])
{
fprintf (stderr, " [%s]", state->group_array[i].groupName);
strcpy (mode, state->group_array[i].groupMode);
}
}
//either j, or j+1 != restchannel (don't think restchannel would show a tg value, but could erroneously do so)
//also, some active channels reported a tg value of 0, so could be bad decode, or unit-to-unit?
if (t_tg[j] != 0 && state->p25_cc_freq != 0 && opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0)) //&& j+1 != restchannel
{
if (state->trunk_lcn_freq[t_ch[j]] != 0) //if we have a valid frequency
{
//RIGCTL
if (opts->use_rigctl == 1)
{
SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength more than anything, 12.5 should be safe for DMR
SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[t_ch[j]]); //minus one because our index starts at zero
state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[t_ch[j]];
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
j = 11; //break loop
}
}
//rtl_udp
else if (opts->audio_in_type == 3)
{
rtl_udp_tune (opts, state, state->trunk_chan_map[t_ch[j]]);
state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[t_ch[j]];
opts->p25_is_tuned = 1;
j = 11; //break loop
}
}
}
}
}
}

View File

@ -123,7 +123,12 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
if (restchannel != state->dmr_rest_channel && restchannel != -1)
{
state->dmr_rest_channel = restchannel;
state->dmr_rest_channel = restchannel;
//assign to cc freq
if (state->trunk_chan_map[restchannel] != 0)
{
state->p25_cc_freq = state->trunk_chan_map[restchannel];
}
}
if (type == 1) fprintf (stderr, "%s \n", KGRN);
@ -479,6 +484,11 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[])
sprintf (state->dmr_branding_sub, "%s", "Cap+ ");
fprintf (stderr, " SLCO Capacity Plus Rest Channel %d", restchannel);
state->dmr_rest_channel = restchannel;
//assign to cc freq if available
if (state->trunk_chan_map[restchannel] != 0)
{
state->p25_cc_freq = state->trunk_chan_map[restchannel];
}
}
else fprintf (stderr, " SLCO Unknown - %d ", slco);

View File

@ -112,6 +112,9 @@ noCarrier (dsd_opts * opts, dsd_state * state)
state->symbolCenter = 4;
}
}
//zero out vc frequencies?
state->p25_vc_freq[0] = 0;
state->p25_vc_freq[1] = 0;
}
state->dibit_buf_p = state->dibit_buf + 200;
@ -144,6 +147,9 @@ noCarrier (dsd_opts * opts, dsd_state * state)
state->lastsrc = 0;
state->lasttgR = 0;
state->lastsrcR = 0;
//zero out vc frequencies?
state->p25_vc_freq[0] = 0;
state->p25_vc_freq[1] = 0;
}
//zero out after x second hangtime when trunking to prevent premature zeroing on these variables
@ -154,6 +160,9 @@ noCarrier (dsd_opts * opts, dsd_state * state)
state->lastsrc = 0;
state->lasttgR = 0;
state->lastsrcR = 0;
//zero out vc frequencies?
// state->p25_vc_freq[0] = 0;
// state->p25_vc_freq[1] = 0;
}
state->lastp25type = 0;
@ -287,8 +296,8 @@ noCarrier (dsd_opts * opts, dsd_state * state)
memset(state->dmr_lrrp_gps, 0, sizeof(state->dmr_lrrp_gps));
//zero out vc frequencies?
state->p25_vc_freq[0] = 0;
state->p25_vc_freq[1] = 0;
// state->p25_vc_freq[0] = 0;
// state->p25_vc_freq[1] = 0;
} //nocarrier
@ -868,13 +877,13 @@ usage ()
printf (" -4 Force Privacy Key over FID and SVC bits \n");
printf ("\n");
printf (" Experimental Functions and Features---------------------------------------------------\n");
printf (" -1 <file> Import LCN Frequencies from csv file (numeral 'one') \n");
printf (" -1 <file> Import LCN Frequencies (consecutive lcn numbered frequencies for EDACS LCNs) from csv file (numeral 'one') \n");
printf (" (See lcn.csv for example)\n");
printf (" -7 <file> Import Channel to Frequency Map from csv file (numeral 'seven') \n");
printf (" -7 <file> Import Channel to Frequency Map (channum, freq) from csv file (numeral 'seven') \n");
printf (" (See channel_map.csv for example)\n");
printf (" -2 <file> Import Group List Allow/Block and Label from csv file (numeral 'two')\n");
printf (" (See group.csv for example)\n");
printf (" -3 Enable Extremely Experimental Trunking Features (NXDN/P25/EDACS/DMR TIII, Con+) with RIGCTL/TCP or RTL Input\n");
printf (" -3 Enable Extremely Experimental Trunking Features (NXDN/P25/EDACS/DMR TIII, Con+, Cap+ RC following) with RIGCTL/TCP or RTL Input\n");
printf (" -5 <udp p> Enable RIGCTL/TCP; Set UDP Port for RIGCTL. (4532 on SDR++)\n");
printf (" -6 <secs> Set Trunking VC/sync loss hangtime in seconds. (default = 1 second)\n");
//printf (" (Currently only available on UDP port 4532)\n");