From 5130899a67a458309c377e567073c56b61b779d3 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Fri, 9 Dec 2022 18:03:53 -0500 Subject: [PATCH] DMR Con+ and Cap+ Trunking Fixes; --- src/dmr_csbk.c | 31 +++++++++++++++++-------------- src/dmr_flco.c | 4 ++-- src/dsd_frame_sync.c | 13 ++++++++++++- src/dsd_main.c | 41 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index 0268f58..1304df2 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -406,9 +406,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //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) @@ -424,6 +422,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 if (state->trunk_chan_map[rest_channel] != 0) { state->p25_cc_freq = state->trunk_chan_map[rest_channel]; + //set to always tuned + opts->p25_is_tuned = 1; } fprintf (stderr, " Capacity Plus Channel Status - Rest Channel %d", rest_channel); @@ -438,7 +438,6 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 fprintf (stderr, " %03d ", tg); //add values to trunking tg/channel potentials t_tg[i] = tg; - t_ch[i] = i; k++; } @@ -454,9 +453,11 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 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 + //if neither current slot has vlc, pi, or voice in it currently + //may need to fully write this out if this statement doesn't work the way I want it to + if (state->dmrburstL != (16 || 0 || 1) && state->dmrburstR != (16 || 0 || 1) ) { - for (j = 0; i < 8; j++) //go through the channels stored looking for active ones to tune to + for (j = 0; j < 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++) @@ -472,14 +473,14 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //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 + if (state->trunk_chan_map[j+1] != 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]]; + SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[j+1]); //minus one because our index starts at zero + state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[j+1]; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop j = 11; //break loop } @@ -488,8 +489,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //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]]; + rtl_udp_tune (opts, state, state->trunk_chan_map[j+1]); + state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[j+1]; opts->p25_is_tuned = 1; j = 11; //break loop } @@ -505,6 +506,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //Connect+ Section if (csbk_fid == 0x06) { + + //users need to set channel 0 to their current cc frequency for now + if (state->trunk_chan_map[0] != 0) state->p25_cc_freq = state->trunk_chan_map[0]; + if (csbk_o == 0x01) { //initial line break @@ -523,9 +528,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 if (csbk_o == 0x03) { - //shim in chan map 0 as the cc frequency, user will need to specify it in the channel map file - if (state->p25_cc_freq != 0 && state->trunk_chan_map[0] != 0) state->p25_cc_freq = state->trunk_chan_map[0]; - + //initial line break fprintf (stderr, "\n"); uint32_t srcAddr = ( (cs_pdu[2] << 16) + (cs_pdu[3] << 8) + cs_pdu[4] ); @@ -562,7 +565,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //need channel map frequencies and stuff, also way to figure out control channel frequency? (channel 0 from channel map?) if (state->p25_cc_freq != 0 && opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0)) { - if (state->trunk_lcn_freq[lcn] != 0) //if we have a valid frequency + if (state->trunk_chan_map[lcn] != 0) //if we have a valid frequency { //RIGCTL if (opts->use_rigctl == 1) diff --git a/src/dmr_flco.c b/src/dmr_flco.c index 2460eef..44e6d58 100644 --- a/src/dmr_flco.c +++ b/src/dmr_flco.c @@ -468,7 +468,7 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]) state->dmr_mfid = 0x10; sprintf (state->dmr_branding_sub, "%s", "Con+ "); fprintf (stderr, " SLCO Connect Plus Voice Channel - Net ID: %d Site ID: %d", con_netid, con_siteid); - sprintf (state->dmr_site_parms, "N%d-S%d", con_netid, con_siteid); + sprintf (state->dmr_site_parms, "N%d - S%d ", con_netid, con_siteid); } else if (slco == 0xA) @@ -476,7 +476,7 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]) state->dmr_mfid = 0x10; sprintf (state->dmr_branding_sub, "%s", "Con+ "); fprintf (stderr, " SLCO Connect Plus Control Channel - Net ID: %d Site ID: %d", con_netid, con_siteid); - sprintf (state->dmr_site_parms, "N%d-S%d", con_netid, con_siteid); + sprintf (state->dmr_site_parms, "N%d - S%d ", con_netid, con_siteid); } else if (slco == 0xF) diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index e11e864..3683d00 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -150,7 +150,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) //start control channel hunting if using trunking, time needs updating on each successful sync //will need to assign frequencies to a CC array for P25 since that isn't imported from CSV - if (opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && ( (time(NULL) - state->last_cc_sync_time) > (opts->trunk_hangtime + 2) ) ) + if (state->dmr_rest_channel == -1 && opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && ( (time(NULL) - state->last_cc_sync_time) > (opts->trunk_hangtime + 2) ) ) { //test to switch back to 10/4 P1 QPSK for P25 FDMA CC @@ -881,6 +881,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (10); } else @@ -900,6 +901,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (11); //11 } } @@ -924,6 +926,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (33); } else @@ -943,6 +946,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (32); } } /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0) */ @@ -967,6 +971,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (33); } else @@ -986,6 +991,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (32); } } /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0) */ @@ -1014,6 +1020,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (12); } @@ -1030,6 +1037,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (13); } } @@ -1058,6 +1066,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (32); //treat Direct Mode same as MS mode for now } else @@ -1097,6 +1106,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (32); } else @@ -1112,6 +1122,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { pa_simple_flush(opts->pulse_raw_dev_out, NULL); } + state->last_cc_sync_time = time(NULL); return (33); } } //End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0) diff --git a/src/dsd_main.c b/src/dsd_main.c index 5f72661..24ae7f9 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -82,18 +82,46 @@ noCarrier (dsd_opts * opts, dsd_state * state) { if (state->p25_cc_freq != 0) { + //cap+ increment rest channel by one, or two? + if (state->dmr_rest_channel != -1) + { + if (state->dmr_rest_channel > 6) //7 and 8 share the same rf frequency + { + state->dmr_rest_channel = 1; + } + else state->dmr_rest_channel += 2; + + //extra sanity check + if (state->dmr_rest_channel > 8) state->dmr_rest_channel = 1; + + if (state->trunk_chan_map[state->dmr_rest_channel] != 0) + { + state->p25_cc_freq = state->trunk_chan_map[state->dmr_rest_channel]; + } + //extra redundant failsafe + else if (state->trunk_chan_map[1] != 0) + { + state->p25_cc_freq = state->trunk_chan_map[1]; + } + //if all else fail, let frame sync start hunting for it + else state->dmr_rest_channel = -1; + + } + if (opts->use_rigctl == 1) //rigctl tuning { //may or may not use setmod here, let user control it instead? if (opts->frame_nxdn48 == 1) SetModulation(opts->rigctl_sockfd, 6250); else SetModulation(opts->rigctl_sockfd, 12500); SetFreq(opts->rigctl_sockfd, state->p25_cc_freq); + state->dmr_rest_channel = -1; //maybe? } else if (opts->audio_in_type == 3) //rtl_fm tuning { //UDP command to tune the RTL dongle rtl_udp_tune(opts, state, state->p25_cc_freq); + state->dmr_rest_channel = -1; //maybe? } opts->p25_is_tuned = 0; @@ -173,7 +201,7 @@ noCarrier (dsd_opts * opts, dsd_state * state) // state->p25_vc_freq[0] = 0; // state->p25_vc_freq[1] = 0; } - + state->lastp25type = 0; state->repeat = 0; state->nac = 0; @@ -307,6 +335,17 @@ noCarrier (dsd_opts * opts, dsd_state * state) // state->p25_vc_freq[0] = 0; // state->p25_vc_freq[1] = 0; + if (state->last_cc_sync_time > 30) //thirty seconds of no carrier + { + state->dmr_rest_channel = -1; + state->p25_vc_freq[0] = 0; + state->p25_vc_freq[1] = 0; + state->dmr_mfid = 0; + sprintf(state->dmr_branding_sub, "%s", ""); + sprintf(state->dmr_branding, "%s", ""); + opts->p25_is_tuned = 0; + } + } //nocarrier void