DMR rc crc7 fix and rc element decode #187; fix/revamp p_clear and p_protect trunking logic; MTL patch; g_dmr patch; Misc;

This commit is contained in:
lwvmobile 2024-02-05 11:11:56 -05:00
parent ffa8b053d7
commit ed85d508ed
10 changed files with 793 additions and 113 deletions

149
patch/MTL_MONO_MODE.patch Normal file
View File

@ -0,0 +1,149 @@
diff --git a/src/dmr_pi.c b/src/dmr_pi.c
index 55dfb83..33fb3ba 100644
--- a/src/dmr_pi.c
+++ b/src/dmr_pi.c
@@ -14,6 +14,9 @@ void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRC
{
UNUSED2(opts, CRCCorrect);
+ //force slot to 0 if using dmr mono handling
+ if (opts->dmr_mono == 1) state->currentslot = 0;
+
if((IrrecoverableErrors == 0))
{
diff --git a/src/dsd_audio2.c b/src/dsd_audio2.c
index e149850..219f3f7 100644
--- a/src/dsd_audio2.c
+++ b/src/dsd_audio2.c
@@ -859,6 +859,9 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
memset (stereo_samp2, 0, sizeof(stereo_samp2));
memset (stereo_samp3, 0, sizeof(stereo_samp3));
+ if (opts->dmr_mono == 1)
+ memcpy (state->s_r4, state->s_l4, sizeof(state->s_r4));
+
//dmr enc checkdown for whether or not to fill the stereo sample or not for playback or writing
encL = encR = 0;
encL = (state->dmr_so >> 6) & 0x1;
@@ -941,8 +944,16 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
}
//flag either left or right as 'enc' to mute if B
- if (strcmp(modeL, "B") == 0) encL = 1;
- if (strcmp(modeR, "B") == 0) encR = 1;
+ if (strcmp(modeL, "B") == 0)
+ {
+ encL = 1;
+ encR = 1;
+ }
+ if (strcmp(modeR, "B") == 0)
+ {
+ encR = 1;
+ encL = 1;
+ }
//if TG Hold in place, mute anything but that TG #132
if (state->tg_hold != 0 && state->tg_hold != TGL) encL = 1;
diff --git a/src/dsd_frame.c b/src/dsd_frame.c
index 3b2a3e1..ba32618 100644
--- a/src/dsd_frame.c
+++ b/src/dsd_frame.c
@@ -160,7 +160,8 @@ processFrame (dsd_opts * opts, dsd_state * state)
sprintf (state->slot2light, " slot2 ");
//we can safely open MBE on any MS or mono handling
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL)) openMbeOutFile (opts, state);
- if (opts->p25_trunk == 0) dmrMSBootstrap (opts, state);
+ // if (opts->p25_trunk == 0) //line disabled to allow mono mode while trunking
+ dmrMSBootstrap (opts, state);
}
if (opts->dmr_mono == 1 && state->synctype == 32)
{
diff --git a/src/dsd_main.c b/src/dsd_main.c
index eb27948..cf1296a 100644
--- a/src/dsd_main.c
+++ b/src/dsd_main.c
@@ -1568,9 +1568,9 @@ main (int argc, char **argv)
}
#ifdef AERO_BUILD
- fprintf (stderr, "Build Version: AW (20231015) \n");
+ fprintf (stderr, "Build Version: AW MTL (20240201) \n");
#else
- fprintf (stderr, "Build Version: AW %s \n", GIT_TAG);
+ fprintf (stderr, "Build Version: AW MTL %s \n", GIT_TAG);
#endif
fprintf (stderr,"MBElib Version: %s\n", versionstr);
@@ -2218,14 +2218,18 @@ main (int argc, char **argv)
opts.mod_qpsk = 0;
opts.mod_gfsk = 0;
state.rf_mod = 0;
- opts.dmr_stereo = 1;
- opts.dmr_mono = 0;
+ // opts.dmr_stereo = 1;
+ // opts.dmr_mono = 0;
// opts.setmod_bw = 7000;
opts.pulse_digi_rate_out = 8000;
opts.pulse_digi_out_channels = 2;
- sprintf (opts.output_name, "DMR");
-
- fprintf (stderr,"Decoding DMR Stereo BS/MS Simplex\n");
+ opts.dmr_mono = 1;
+ opts.dmr_stereo = 0; //not sure if this will break anything
+ state.dmr_stereo = 0; //0
+ // opts.setmod_bw = 7000;
+ sprintf (opts.output_name, "DMR Mono");
+ // fprintf (stderr,"-fr / DMR Mono switch enabled. \n NOTE: Some ENC options in Slot 2 may not work properly.\n");
+ fprintf (stderr,"\n Decoding DMR Stereo BS/MS Simplex in Mono Single Slot Only Configuration.\n");
}
//change ft to only do P25 and DMR (TDMA trunking modes)
else if (optarg[0] == 't')
@@ -2302,13 +2306,13 @@ main (int argc, char **argv)
state.rf_mod = 0; //
opts.pulse_digi_rate_out = 8000;
opts.pulse_digi_out_channels = 2;
- opts.dmr_mono = 0;
- opts.dmr_stereo = 1;
+ opts.dmr_mono = 1;
+ opts.dmr_stereo = 0; //not sure if this will break anything
state.dmr_stereo = 0; //0
// opts.setmod_bw = 7000;
- sprintf (opts.output_name, "DMR Stereo");
- fprintf (stderr,"-fr / DMR Mono switch has been deprecated.\n");
- fprintf (stderr,"Decoding DMR Stereo BS/MS Simplex\n");
+ sprintf (opts.output_name, "DMR Mono");
+ // fprintf (stderr,"-fr / DMR Mono switch enabled. \n NOTE: Some ENC options in Slot 2 may not work properly.\n");
+ fprintf (stderr,"\n Decoding DMR Stereo BS/MS Simplex in Mono Single Slot Only Configuration.\n");
}
else if (optarg[0] == 'm')
diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c
index 7de3ffb..a3dccd8 100644
--- a/src/dsd_ncurses.c
+++ b/src/dsd_ncurses.c
@@ -2275,7 +2275,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->ncurses_compact == 1)
{
printw ("------------------------------------------------------------------------------\n");
- printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW (20231015)");
+ printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW MTL (20240201)");
printw ("------------------------------------------------------------------------------\n");
}
#elif LIMAZULUTWEAKS
@@ -2314,12 +2314,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
#endif
#ifdef AERO_BUILD
if (i == 5) printw (" %s ", "Aero Build");
- if (i == 6) printw (" AW (20231015) \n");
+ if (i == 6) printw (" AW MTL (20240201) \n");
#elif ZDEV_BUILD
- if (i == 5) printw (" %s ", "AW ");
+ if (i == 5) printw (" %s ", "AW MTL");
if (i == 6) printw (" %s \n", GIT_TAG);
#else
- if (i == 5) printw (" %s ", "AW ");
+ if (i == 5) printw (" %s ", "AW MTL");
if (i == 6) printw (" %s \n", GIT_TAG);
#endif
else printw ("\n");

View File

@ -0,0 +1,425 @@
diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c
index bfa05af..e68588f 100644
--- a/src/dmr_csbk.c
+++ b/src/dmr_csbk.c
@@ -453,6 +453,25 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
//rigctl
if (opts->use_rigctl == 1)
{
+ if (state->currentslot == 0)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ }
+ else if (state->currentslot == 1)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ }
+
//Guess I forgot to add this condition here
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
@@ -487,6 +506,26 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
else if (opts->audio_in_type == 3)
{
#ifdef USE_RTLSDR
+
+ if (state->currentslot == 0)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ }
+ else if (state->currentslot == 1)
+ {
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ }
+
//Guess I forgot to add this condition here
uint32_t tempf = (uint32_t)state->p25_cc_freq;
if (opts->rtlsdr_center_freq != tempf)
diff --git a/src/dmr_flco.c b/src/dmr_flco.c
index 2811027..656693c 100644
--- a/src/dmr_flco.c
+++ b/src/dmr_flco.c
@@ -10,6 +10,38 @@
*-----------------------------------------------------------------------------*/
#include "dsd.h"
+//I really just need to make ONE consolidated date and time function that works correctly
+char * getDateFLC(void) {
+ #ifdef AERO_BUILD
+ char datename[80];
+ #else
+ char datename[99];
+ #endif
+ char * curr2;
+ struct tm * to;
+ time_t t;
+ t = time(NULL);
+ to = localtime( & t);
+ strftime(datename, sizeof(datename), "%Y%m%d", to);
+ curr2 = strtok(datename, " ");
+ return curr2;
+}
+
+//fix from YorgosTheodorakis fork -- https://github.com/YorgosTheodorakis/dsd-fme/commit/7884ee555521a887d388152b3b1f11f20433a94b
+char * getTimeFLC(void) //get pretty hhmmss timestamp
+{
+ char * curr = (char *) malloc(9);
+ time_t t = time(NULL);
+ struct tm * ptm = localtime(& t);
+ sprintf(
+ curr,
+ "%02d%02d%02d",
+ ptm->tm_hour,
+ ptm->tm_min,
+ ptm->tm_sec
+ );
+ return curr;
+}
//combined flco handler (vlc, tlc, emb), minus the superfluous structs and strings
void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t CRCCorrect, uint32_t IrrecoverableErrors, uint8_t type)
@@ -304,6 +336,14 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
state->dmr_so = so;
state->lasttg = target;
state->lastsrc = source;
+ char * timestr;
+ timestr = getTimeFLC();
+ //open wav file here if not already opened
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f == NULL)
+ {
+ sprintf (opts->wav_out_file, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateFLC(), timestr, state->dmr_color_code, target, source);
+ openWavOutFileL (opts, state);
+ }
}
if (state->currentslot == 1)
{
@@ -311,6 +351,14 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
state->dmr_soR = so;
state->lasttgR = target;
state->lastsrcR = source;
+ char * timestr;
+ timestr = getTimeFLC();
+ //open wav file here if not already opened
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR == NULL)
+ {
+ sprintf (opts->wav_out_fileR, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateFLC(), timestr, state->dmr_color_code, target, source);
+ openWavOutFileR (opts, state);
+ }
}
//update cc amd vc sync time for trunking purposes (particularly Con+)
@@ -337,6 +385,12 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//reset gain
if (opts->floating_point == 1)
state->aout_gain = opts->audio_gain;
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
}
if (state->currentslot == 1)
{
@@ -350,6 +404,12 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//reset gain
if (opts->floating_point == 1)
state->aout_gainR = opts->audio_gain;
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
}
}
diff --git a/src/dsd_file.c b/src/dsd_file.c
index 67607e5..dae7862 100644
--- a/src/dsd_file.c
+++ b/src/dsd_file.c
@@ -563,6 +563,19 @@ void closeWavOutFile (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_f);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_file);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_file, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_file, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileF %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
+
}
void closeWavOutFileL (dsd_opts * opts, dsd_state * state)
@@ -570,6 +583,19 @@ void closeWavOutFileL (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_f);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_file);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_file, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_file, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileL %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
+
}
void closeWavOutFileR (dsd_opts * opts, dsd_state * state)
@@ -577,6 +603,18 @@ void closeWavOutFileR (dsd_opts * opts, dsd_state * state)
UNUSED(state);
sf_close(opts->wav_out_fR);
+ char shell[2065], newfilename[1032];
+ int result;
+ sprintf (newfilename, "%s.wav", opts->wav_out_fileR);
+#ifdef AERO_BUILD
+ result = rename (opts->wav_out_fileR, newfilename);
+ UNUSED(shell);
+#else
+ sprintf (shell, "mv '%s' '%s'", opts->wav_out_fileR, newfilename);
+ result = system (shell);
+#endif
+ // fprintf (stderr, "\n Close WAV FileR %s; Result: %d \n", newfilename, result);
+ UNUSED(result);
}
void closeWavOutFileRaw (dsd_opts * opts, dsd_state * state)
diff --git a/src/dsd_main.c b/src/dsd_main.c
index eb27948..67c4de7 100644
--- a/src/dsd_main.c
+++ b/src/dsd_main.c
@@ -107,6 +107,19 @@ void
noCarrier (dsd_opts * opts, dsd_state * state)
{
+ //close any perCall wav files that are open
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_f != NULL)
+ {
+ closeWavOutFileL (opts, state);
+ opts->wav_out_f = NULL;
+ }
+ if (opts->dmr_stereo_wav == 1 && opts->wav_out_fR != NULL)
+ {
+ closeWavOutFileR (opts, state);
+ opts->wav_out_fR = NULL;
+ }
+ //end perCall wav file close
+
#ifdef AERO_BUILD
//TODO: Investigate why getSymbol needs to be run first in this context...truly confused here
if(opts->frame_m17 == 1) //&& opts->audio_in_type == 5
@@ -1568,9 +1581,9 @@ main (int argc, char **argv)
}
#ifdef AERO_BUILD
- fprintf (stderr, "Build Version: AW (20231015) \n");
+ fprintf (stderr, "Build Version: AW (20231214) G Build\n");
#else
- fprintf (stderr, "Build Version: AW %s \n", GIT_TAG);
+ fprintf (stderr, "Build Version: AW %s G Build\n", GIT_TAG);
#endif
fprintf (stderr,"MBElib Version: %s\n", versionstr);
diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c
index cc3a928..46820cb 100644
--- a/src/dsd_mbe.c
+++ b/src/dsd_mbe.c
@@ -1197,7 +1197,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
if (state->dmr_encL == 0 || opts->dmr_mute_encL == 0)
{
//write wav to per call on left channel Slot 1
- writeSynthesizedVoice (opts, state);
+ if (opts->wav_out_f != NULL)
+ writeSynthesizedVoice (opts, state);
}
}
@@ -1207,7 +1208,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
if (state->dmr_encR == 0 || opts->dmr_mute_encR == 0)
{
//write wav to per call on right channel Slot 2
- writeSynthesizedVoiceR (opts, state);
+ if (opts->wav_out_fR != NULL)
+ writeSynthesizedVoiceR (opts, state);
}
}
diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c
index 7de3ffb..faa379e 100644
--- a/src/dsd_ncurses.c
+++ b/src/dsd_ncurses.c
@@ -999,7 +999,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
if (choicec == 12)
{
//flesh out all closewavs and sprint "" wav filenames
- closeWavOutFile (opts, state);
+ // closeWavOutFile (opts, state);
closeWavOutFileL (opts, state);
closeWavOutFileR (opts, state);
//closeWavOutFileRaw (opts, state);
@@ -2063,6 +2063,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->dmr_stereo_wav == 1 && src != 0 ) //&& tgn != 0, some TG can be 0 on NXDN
{
//close old first, assign name based on time and radio, open wav file
+ if (opts->wav_out_f != NULL)
closeWavOutFileL (opts, state);
sprintf (opts->wav_out_file, "./%s/%s %s NXDN - RAN %d - TGT %d - SRC %d.wav", opts->wav_out_dir, getDateN(), timestr, rn, tgn, src);
openWavOutFileL (opts, state); //testing for now, will want to move to per call later
@@ -2105,13 +2106,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[9][5] = time(NULL);
//open wav file if enabled and both rd and tg are not 0
- if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
- {
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileL (opts, state);
- sprintf (opts->wav_out_file, "./%s/%s %s MS - CC %d - TG %d - RD %d.wav", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
- openWavOutFileL (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_f != NULL)
+ // closeWavOutFileL (opts, state);
+ // sprintf (opts->wav_out_file, "./%s/%s %s MS - CC %d - TG %d - RD %d.wav", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
+ // openWavOutFileL (opts, state); //testing for now, will want to move to per call later
+ // }
if (opts->call_alert == 1 && rd != 0 && tg != 0)
{
@@ -2126,7 +2128,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
//DMR BS Slot 1 - matrix 0-4
- if ( call_matrix[4][2] != rd && (lls == 11 || lls == 12 || lls == 10 || lls == 13 || lls == 35 || lls == 36) )
+ if ( call_matrix[4][2] != rd && (lls == 11 || lls == 12 || lls == 10 || lls == 13 ) ) //|| lls == 35 || lls == 36
{
for (short int k = 0; k < 4; k++)
@@ -2147,14 +2149,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[4][5] = time(NULL);
//open wav file if enabled and both rd and tg are not 0
- if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
- {
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileL (opts, state);
-
- sprintf (opts->wav_out_file, "./%s/%s %s CC %d - TG %d - RD %d.wav", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
- openWavOutFileL (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rd != 0 && tg != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_f != NULL)
+ // closeWavOutFileL (opts, state);
+ // sprintf (opts->wav_out_file, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateN(), timestr, dcc, tg, rd);
+ // openWavOutFileL (opts, state); //testing for now, will want to move to per call later
+ // }
if (opts->call_alert == 1 && rd != 0 && tg != 0)
{
@@ -2190,20 +2192,21 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
call_matrix[9][5] = time(NULL);
//open wav file if enabled and both rdR and tgR are not 0
- if (opts->dmr_stereo_wav == 1 && rdR != 0 && tgR != 0)
- {
- //close old first, assign name based on time and radio, open wav file
- closeWavOutFileR (opts, state);
- sprintf (opts->wav_out_fileR, "./%s/%s %s CC %d - TG %d - RD %d.wav", opts->wav_out_dir, getDateN(), timestr, dcc, tgR, rdR);
- openWavOutFileR (opts, state); //testing for now, will want to move to per call later
- }
+ // if (opts->dmr_stereo_wav == 1 && rdR != 0 && tgR != 0)
+ // {
+ // //close old first, assign name based on time and radio, open wav file
+ // if (opts->wav_out_fR != NULL)
+ // closeWavOutFileR (opts, state);
+ // sprintf (opts->wav_out_fileR, "./%s/%s %s CC %d - TG %d - RD %d", opts->wav_out_dir, getDateN(), timestr, dcc, tgR, rdR);
+ // openWavOutFileR (opts, state); //testing for now, will want to move to per call later
+ // }
- if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
- {
- //fprintf (stderr, "BEEP 1 BS RIGHT\n");
- beeper (opts, state, 1);
- state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
- }
+ // if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
+ // {
+ // //fprintf (stderr, "BEEP 1 BS RIGHT\n");
+ // beeper (opts, state, 1);
+ // state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
+ // }
memset(state->dmr_alias_block_segment[1], 0, sizeof(state->dmr_alias_block_segment[1]));
sprintf (state->dmr_embedded_gps[1], "%s", "");
@@ -2275,7 +2278,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->ncurses_compact == 1)
{
printw ("------------------------------------------------------------------------------\n");
- printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW (20231015)");
+ printw ("| Digital Speech Decoder: Florida Man Edition - Aero %s \n", "AW (20231214)");
printw ("------------------------------------------------------------------------------\n");
}
#elif LIMAZULUTWEAKS
@@ -2313,13 +2316,13 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2");
#endif
#ifdef AERO_BUILD
- if (i == 5) printw (" %s ", "Aero Build");
- if (i == 6) printw (" AW (20231015) \n");
+ if (i == 5) printw (" %s ", "G Build");
+ if (i == 6) printw (" AW (20231214) \n");
#elif ZDEV_BUILD
- if (i == 5) printw (" %s ", "AW ");
+ if (i == 5) printw (" %s ", "AW G Build");
if (i == 6) printw (" %s \n", GIT_TAG);
#else
- if (i == 5) printw (" %s ", "AW ");
+ if (i == 5) printw (" %s ", "AW G Build");
if (i == 6) printw (" %s \n", GIT_TAG);
#endif
else printw ("\n");
@@ -3916,7 +3919,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (c == 112) //'p' key - stop all per call wav files
{
//hope this one doesn't cause random crashing or garbage writing
- closeWavOutFile (opts, state);
+ // closeWavOutFile (opts, state);
closeWavOutFileL (opts, state);
closeWavOutFileR (opts, state);
sprintf (opts->wav_out_file, "%s", "");

View File

@ -313,11 +313,11 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
fprintf (stderr,"%s ", getTime());
//simplifying things
char polarity[3];
// char polarity[3];
char light[18];
sprintf (light, "%s", " [SLOT1] slot2 ");
fprintf (stderr,"Sync: %sDMR %s", polarity, light);
fprintf (stderr,"Sync: DMR %s", light);
fprintf (stderr, "%s", KCYN);
fprintf (stderr, "| Frame Sync Err: %d", vc1);
fprintf (stderr, "%s", KNRM);
@ -334,11 +334,11 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
fprintf (stderr,"%s ", getTime());
//simplifying things
char polarity[3];
// char polarity[3];
char light[18];
sprintf (light, "%s", " slot1 [SLOT2] ");
fprintf (stderr,"Sync: %sDMR %s", polarity, light);
fprintf (stderr,"Sync: DMR %s", light);
fprintf (stderr, "%s", KCYN);
fprintf (stderr, "| Frame Sync Err: %d", vc2);
fprintf (stderr, "%s", KNRM);

View File

@ -380,90 +380,150 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
//NOTE: Do not zero out lasttg/lastsrc in TLC FLCO when using p_clear, otherwise,
//it will affect the conditions below and fail to trigger on tg_hold
//test misc conditions to trigger a clear and immediately return to CC
//test misc conditions to trigger a clear and immediately return to CC, or remain on current VC;
int clear = 0;
int pslot = state->currentslot; //this slot
int oslot = (state->currentslot ^ 1) & 1; //opposite slot
pslot++; oslot++; //set to 1 and 2 and not 0 and 1
//if no voice activity or data call (when enabled) within trunk_hangtime seconds
if ( ((time(NULL) - state->last_vc_sync_time) > opts->trunk_hangtime) && opts->trunk_tune_data_calls == 0) clear = 1;
//if the other slot is IDLE or TLC condition -- May consider disabling this one
// if (state->currentslot == 0 && (state->dmrburstR == 9 && state->dmrburstR == 7)) clear = 1;
// if (state->currentslot == 0 && (state->dmrburstL == 9 && state->dmrburstL == 7)) clear = 1;
//if no voice in the opposite slot currently or data call (when enabled) -- might can disable data call condition here
if (state->currentslot == 0 && state->dmrburstR != 16) clear = 2; //&& opts->trunk_tune_data_calls == 0
if (state->currentslot == 1 && state->dmrburstL != 16) clear = 3; //&& opts->trunk_tune_data_calls == 0
//if no voice header, pi header, or voice sync in the opposite slot currently
if (state->currentslot == 0 && (state->dmrburstR != 16 && state->dmrburstR != 0 && state->dmrburstR != 1)) clear = 2;
if (state->currentslot == 1 && (state->dmrburstL != 16 && state->dmrburstL != 0 && state->dmrburstL != 1)) clear = 3;
//if we have a tg hold in place that matches traffic that was just on this slot (this will override other calls in the opposite slot)
if (state->currentslot == 0 && state->tg_hold == state->lasttg && state->tg_hold != 0) clear = 4;
if (state->currentslot == 1 && state->tg_hold == state->lasttgR && state->tg_hold != 0) clear = 5;
//if tuning and decoding data is desired, then do a secondary check here for data headers and blocks in the opposite slot
if (opts->trunk_tune_data_calls == 1)
{
//if no data header or data block sync in the opposite slot currently
if (state->currentslot == 0 && (state->dmrburstR == 6 || state->dmrburstR == 7 || state->dmrburstR == 8 || state->dmrburstR == 10)) clear = 21;
if (state->currentslot == 1 && (state->dmrburstL == 6 || state->dmrburstL == 7 || state->dmrburstL == 8 || state->dmrburstL == 10)) clear = 22;
}
//initial line break
fprintf (stderr, "\n");
fprintf (stderr, " Clear (P_CLEAR) %d", clear);
fprintf (stderr, " Clear (P_CLEAR) ");
#ifdef PCLEAR_TUNE_AWAY
//check to see if this is a dummy csbk sent from link control to signal return to tscc
if (clear && csbk_fid == 255) fprintf (stderr, " No Encrypted Call Trunking; Return to CC; ");
if (!clear && csbk_fid == 255) fprintf (stderr, " No Encrypted Call Trunking; Other Slot Busy; ");
if (clear)
if (opts->p25_trunk == 1)
{
if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && opts->p25_is_tuned == 1)
//check the p_clear logic and report status
if (clear && csbk_fid == 255) fprintf (stderr, " Slot %d No Encrypted Call Trunking; Slot %d Free; Return to CC; ", pslot, oslot);
else if (!clear && csbk_fid == 255) fprintf (stderr, " Slot %d No Encrypted Call Trunking; Slot %d Busy; Remain on VC;", pslot, oslot);
else if (!clear) fprintf (stderr, " Slot %d Clear; Slot %d Busy; Remain on VC;", pslot, oslot);
else if (clear == 1) fprintf (stderr, " Slot %d Clear; Slot %d Idle; Return to CC;", pslot, oslot);
else if (clear == 2 || clear == 3) fprintf (stderr, " Slot %d Clear; Slot %d Free; Return to CC;", pslot, oslot);
else if (clear == 4 || clear == 5) fprintf (stderr, " Slot %d Clear w/ TG Hold %d; Slot %d Activity Override; Return to CC; ", pslot, state->tg_hold, oslot);
//NOTE: Below clears are just conditions for reporting, and not clear to tune away, so they are set back to zero
else if (clear == 21 || clear == 22)
{
//display/le bug fix when p_clear activated
// if (state->currentslot == 0)
// {
// state->payload_mi = 0;
// state->payload_algid = 0;
// state->payload_keyid = 0;
// state->dmr_so = 0;
// }
// if (state->currentslot == 1)
// {
// state->payload_miR = 0;
// state->payload_algidR = 0;
// state->payload_keyidR = 0;
// state->dmr_soR = 0;
// }
//rigctl
if (opts->use_rigctl == 1)
{
//Guess I forgot to add this condition here
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
//reset some strings
sprintf (state->call_string[state->currentslot], "%s", " "); //21 spaces
sprintf (state->active_channel[state->currentslot], "%s", "");
state->last_vc_sync_time = 0;
state->last_cc_sync_time = time(NULL);
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
}
//rtl
else if (opts->audio_in_type == 3)
{
#ifdef USE_RTLSDR
//Guess I forgot to add this condition here
uint32_t tempf = (uint32_t)state->p25_cc_freq;
if (opts->rtlsdr_center_freq != tempf)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
//reset some strings
sprintf (state->call_string[state->currentslot], "%s", " "); //21 spaces
sprintf (state->active_channel[state->currentslot], "%s", "");
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
if (opts->rtlsdr_center_freq != tempf)
rtl_dev_tune (opts, state->p25_cc_freq);
#endif
}
fprintf (stderr, " Slot %d Clear; Slot %d Data; Remain on DC;", pslot, oslot);
clear = 0; //flag as 0 so we won't tune away until data call is completed
}
}
#endif
if (clear)
{
if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && opts->p25_is_tuned == 1)
{
//display/le/buzzer bug fix when p_clear activated (unsure why this was disabled)
//clear only the current slot initially, then clear both if tuning to a different freq
if (state->currentslot == 0)
{
state->payload_mi = 0;
state->payload_algid = 0;
state->payload_keyid = 0;
state->dmr_so = 0;
}
if (state->currentslot == 1)
{
state->payload_miR = 0;
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->dmr_soR = 0;
}
//rigctl
if (opts->use_rigctl == 1)
{
//Guess I forgot to add this condition here
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
//clear both if tuning away to another frequency
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
{
state->payload_mi = 0;
state->payload_algid = 0;
state->payload_keyid = 0;
state->dmr_so = 0;
state->payload_miR = 0;
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->dmr_soR = 0;
}
//reset some strings
sprintf (state->call_string[state->currentslot], "%s", " "); //21 spaces
sprintf (state->active_channel[state->currentslot], "%s", "");
state->last_vc_sync_time = 0;
state->last_cc_sync_time = time(NULL);
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
if (GetCurrentFreq(opts->rigctl_sockfd) != state->p25_cc_freq)
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
}
//rtl
else if (opts->audio_in_type == 3)
{
#ifdef USE_RTLSDR
//Guess I forgot to add this condition here
uint32_t tempf = (uint32_t)state->p25_cc_freq;
if (opts->rtlsdr_center_freq != tempf)
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away from current frequency
//clear both if tuning away to another frequency
if (opts->rtlsdr_center_freq != tempf)
{
state->payload_mi = 0;
state->payload_algid = 0;
state->payload_keyid = 0;
state->dmr_so = 0;
state->payload_miR = 0;
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->dmr_soR = 0;
}
//reset some strings
sprintf (state->call_string[state->currentslot], "%s", " "); //21 spaces
sprintf (state->active_channel[state->currentslot], "%s", "");
state->last_cc_sync_time = time(NULL);
state->last_vc_sync_time = 0;
opts->p25_is_tuned = 0;
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
if (opts->rtlsdr_center_freq != tempf)
rtl_dev_tune (opts, state->p25_cc_freq);
#endif
}
}
}
} //end if trunking is enabled
#else
UNUSED (clear); UNUSED(pslot); UNUSED(oslot);
#endif //end if PCLEAR_TUNE_AWAY is enabled in code
}
//(P_PROTECT)
@ -493,6 +553,21 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
//check the source and/or target for special gateway identifiers
dmr_gateway_identifier (source, target);
//change this slot burst type to VLC so the revamped p_clear doesn't tune away
if (opts->p25_trunk == 1)
{
if (gi && opts->trunk_tune_group_calls == 1)
{
if (state->currentslot == 0) state->dmrburstL = 1;
else state->dmrburstR = 1;
}
if (!gi && opts->trunk_tune_private_calls == 1)
{
if (state->currentslot == 0) state->dmrburstL = 1;
else state->dmrburstR = 1;
}
}
}
if (csbk_o == 40) //0x28

View File

@ -354,6 +354,19 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
memset (state->active_channel, 0, sizeof(state->active_channel));
state->last_cc_sync_time = time(NULL);
state->is_con_plus = 0; //con+ flag off
//display/le/buzzer bug fix when con+ cc return (bug not observed here,
//but could happen like it does on TIII with mixed enc and clear calls w/ ENC LO is activated)
state->payload_mi = 0;
state->payload_algid = 0;
state->payload_keyid = 0;
state->dmr_so = 0;
state->payload_miR = 0;
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->dmr_soR = 0;
}
}

View File

@ -445,18 +445,18 @@ void dmr_flco (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[], uint32_t C
//if group doesn't exist, or isn't locked out, then do so now.
if (lo == 0)
{
{ //changing from DE to B to fit the rest of the lockout logic ("Buzzer Fix")
state->group_array[state->group_tally].groupNumber = target;
sprintf (state->group_array[state->group_tally].groupMode, "%s", "DE");
sprintf (state->group_array[state->group_tally].groupMode, "%s", "B");
sprintf (state->group_array[state->group_tally].groupName, "%s", "ENC LO");
sprintf (gm, "%s", "DE");
sprintf (gm, "%s", "B");
sprintf (gn, "%s", "ENC LO");
state->group_tally++;
}
//Craft a fake CSBK pdu send it to run as a p_clear to return to CC if available
uint8_t dummy[12]; uint8_t* dbits; memset (dummy, 0, sizeof(dummy)); dummy[0] = 46; dummy[1] = 255;
if ( (strcmp(gm, "DE") == 0) && (strcmp(gn, "ENC LO") == 0) ) //&& (opts->trunk_tune_data_calls == 0)
if ( (strcmp(gm, "B") == 0) && (strcmp(gn, "ENC LO") == 0) ) //&& (opts->trunk_tune_data_calls == 0)
dmr_cspdu (opts, state, dbits, dummy, 1, 0);
}

View File

@ -252,7 +252,7 @@ void dmr_sbrc (dsd_opts * opts, dsd_state * state, uint8_t power)
crc_extracted = crc_extracted | sbrc_return[i+4];
}
crc_extracted = crc_extracted ^ 0x7A;
crc_computed = crc7((uint8_t *) sbrc_return, 7);
crc_computed = crc7((uint8_t *) sbrc_return, 4); //#187 fix
if (crc_extracted == crc_computed) crc7_okay = 1;
}
else //if (txi == 1) //if TXI -- but TXI systems also carry the non-crc protected ENC identifiers
@ -332,7 +332,18 @@ void dmr_sbrc (dsd_opts * opts, dsd_state * state, uint8_t power)
else if (crc7_okay == 1)
{
//do something with the reverse channel information
//decode the reverse channel information ETSI TS 102 361-4 V1.12.1 (2023-07) p 103 Table 6.32: MS Reverse Channel (RC) Command Information Elements
if (opts->payload == 0) fprintf (stderr, "\n");
fprintf (stderr, "%s", KCYN);
sbrc_hex = sbrc_hex >> 7; //set value to its 4-bit form
if (sbrc_hex == 0) fprintf (stderr, " RC: Increase Power By One Step;");
else if (sbrc_hex == 1) fprintf (stderr, " RC: Decrease Power By One Step;");
else if (sbrc_hex == 2) fprintf (stderr, " RC: Set Power To Highest;");
else if (sbrc_hex == 3) fprintf (stderr, " RC: Set Power To Lowest;");
else if (sbrc_hex == 4) fprintf (stderr, " RC: Cease Transmission Command;");
else if (sbrc_hex == 5) fprintf (stderr, " RC: Cease Transmission Request;");
else fprintf (stderr, " RC: Reserved %02X;", sbrc_hex);
fprintf (stderr, "%s", KNRM);
}
//if the call is interruptable (TXI) and the crc3 is okay and TXI Opcode

View File

@ -17,6 +17,13 @@ void dmr_pi (dsd_opts * opts, dsd_state * state, uint8_t PI_BYTE[], uint32_t CRC
if((IrrecoverableErrors == 0))
{
//update cc amd vc sync time for trunking purposes (particularly Con+)
if (opts->p25_is_tuned == 1)
{
state->last_vc_sync_time = time(NULL);
state->last_cc_sync_time = time(NULL);
}
if (state->currentslot == 0)
{
state->payload_algid = PI_BYTE[0];

View File

@ -817,9 +817,9 @@ void playSynthesizedVoiceSS (dsd_opts * opts, dsd_state * state)
state->audio_out_idx = 0;
state->audio_out_idxR = 0;
//set float temp buffer to baseline
memset (state->s_l, 1, sizeof(state->s_l));
memset (state->s_r, 1, sizeof(state->s_r));
//set short temp buffer to baseline
memset (state->s_l, 0, sizeof(state->s_l));
memset (state->s_r, 0, sizeof(state->s_r));
if (state->audio_out_idx2 >= 800000)
{
@ -855,9 +855,9 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
short stereo_samp2[320]; //8k 2-channel stereo interleave mix
short stereo_samp3[320]; //8k 2-channel stereo interleave mix
memset (stereo_samp1, 1, sizeof(stereo_samp1));
memset (stereo_samp2, 1, sizeof(stereo_samp2));
memset (stereo_samp3, 1, sizeof(stereo_samp3));
memset (stereo_samp1, 0, sizeof(stereo_samp1));
memset (stereo_samp2, 0, sizeof(stereo_samp2));
memset (stereo_samp3, 0, sizeof(stereo_samp3));
//dmr enc checkdown for whether or not to fill the stereo sample or not for playback or writing
encL = encR = 0;
@ -1007,9 +1007,9 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
state->audio_out_idx = 0;
state->audio_out_idxR = 0;
//set float temp buffer to baseline
memset (state->s_l4, 1, sizeof(state->s_l4));
memset (state->s_r4, 1, sizeof(state->s_r4));
//set short temp buffer to baseline
memset (state->s_l4, 0, sizeof(state->s_l4));
memset (state->s_r4, 0, sizeof(state->s_r4));
if (state->audio_out_idx2 >= 800000)
{
@ -1048,12 +1048,12 @@ void playSynthesizedVoiceSS4 (dsd_opts * opts, dsd_state * state)
short empty[320]; //this is used to see if we want to play a single 2v or double 2v or not
memset (stereo_samp1, 1, sizeof(stereo_samp1));
memset (stereo_samp2, 1, sizeof(stereo_samp2));
memset (stereo_samp3, 1, sizeof(stereo_samp3));
memset (stereo_samp4, 1, sizeof(stereo_samp4));
memset (stereo_samp1, 0, sizeof(stereo_samp1));
memset (stereo_samp2, 0, sizeof(stereo_samp2));
memset (stereo_samp3, 0, sizeof(stereo_samp3));
memset (stereo_samp4, 0, sizeof(stereo_samp4));
memset (empty, 1, sizeof(empty));
memset (empty, 0, sizeof(empty));
//p25p2 enc checkdown for whether or not to fill the stereo sample or not for playback or writing
@ -1214,9 +1214,9 @@ void playSynthesizedVoiceSS4 (dsd_opts * opts, dsd_state * state)
state->audio_out_idx = 0;
state->audio_out_idxR = 0;
//set float temp buffer to baseline
memset (state->s_l4, 1, sizeof(state->s_l4));
memset (state->s_r4, 1, sizeof(state->s_r4));
//set short temp buffer to baseline
memset (state->s_l4, 0, sizeof(state->s_l4));
memset (state->s_r4, 0, sizeof(state->s_r4));
if (state->audio_out_idx2 >= 800000)
{

View File

@ -527,15 +527,15 @@ if(opts->frame_m17 == 1) //&& opts->audio_in_type == 5
memset (state->f_r4, 0.0f, sizeof(state->f_r4));
//zero out the short sample storage buffers
memset (state->s_l, 1, sizeof(state->s_l));
memset (state->s_r, 1, sizeof(state->s_r));
memset (state->s_l4, 1, sizeof(state->s_l4));
memset (state->s_r4, 1, sizeof(state->s_r4));
memset (state->s_l, 0, sizeof(state->s_l));
memset (state->s_r, 0, sizeof(state->s_r));
memset (state->s_l4, 0, sizeof(state->s_l4));
memset (state->s_r4, 0, sizeof(state->s_r4));
memset (state->s_lu, 1, sizeof(state->s_lu));
memset (state->s_ru, 1, sizeof(state->s_ru));
memset (state->s_l4u, 1, sizeof(state->s_l4u));
memset (state->s_r4u, 1, sizeof(state->s_r4u));
memset (state->s_lu, 0, sizeof(state->s_lu));
memset (state->s_ru, 0, sizeof(state->s_ru));
memset (state->s_l4u, 0, sizeof(state->s_l4u));
memset (state->s_r4u, 0, sizeof(state->s_r4u));
} //nocarrier
@ -792,15 +792,15 @@ initState (dsd_state * state)
memset (state->f_r4, 0.0f, sizeof(state->f_r4));
//zero out the short sample storage buffers
memset (state->s_l, 1, sizeof(state->s_l));
memset (state->s_r, 1, sizeof(state->s_r));
memset (state->s_l4, 1, sizeof(state->s_l4));
memset (state->s_r4, 1, sizeof(state->s_r4));
memset (state->s_l, 0, sizeof(state->s_l));
memset (state->s_r, 0, sizeof(state->s_r));
memset (state->s_l4, 0, sizeof(state->s_l4));
memset (state->s_r4, 0, sizeof(state->s_r4));
memset (state->s_lu, 1, sizeof(state->s_lu));
memset (state->s_ru, 1, sizeof(state->s_ru));
memset (state->s_l4u, 1, sizeof(state->s_l4u));
memset (state->s_r4u, 1, sizeof(state->s_r4u));
memset (state->s_lu, 0, sizeof(state->s_lu));
memset (state->s_ru, 0, sizeof(state->s_ru));
memset (state->s_l4u, 0, sizeof(state->s_l4u));
memset (state->s_r4u, 0, sizeof(state->s_r4u));
state->audio_out_buf = malloc (sizeof (short) * 1000000);
state->audio_out_bufR = malloc (sizeof (short) * 1000000);