From df6d7a6609e6c0856ca8910e61106fcb54ec992e Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Sun, 21 Aug 2022 23:45:00 -0400 Subject: [PATCH 1/8] DMR Additions --Easier to use key entry for privacy modes ---Serpen'tera' 10 mode now available --Slightly improved dmr dibit buffering/inverted dibit buffering --Tweaks to console and ncurses output regarding FID, SVC, and privacy key values --fix for RTL optional support (think I have all the ifdef covered now) --TGT, SRC, FID, SVC, now set on Voice LC Header (not sure why I wasn't before) --other misc tweaks that I can't recall --- include/dsd.h | 9 ++- src/dmr_bs.c | 47 ++++++++--- src/dmr_data.c | 12 +-- src/dmr_ms.c | 42 ++++++++-- src/dmr_process_voice.c | 68 +++++++++++++++- src/dmr_sync.c | 175 +++++++++++++++++++++++++++++----------- src/dsd_dibit.c | 7 ++ src/dsd_frame_sync.c | 12 +-- src/dsd_main.c | 37 ++++++++- src/dsd_mbe.c | 67 ++++++++++++++- src/dsd_ncurses.c | 95 +++++++++++++++------- 11 files changed, 457 insertions(+), 114 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index 4e93fb2..5812b62 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -563,6 +563,11 @@ typedef struct unsigned int dmrburstL; unsigned int dmrburstR; unsigned long long int R; + unsigned long long int H; + unsigned long long int HYTL; + unsigned long long int HYTR; + int DMRvcL; + int DMRvcR; // int block_count; short int dmr_encL; short int dmr_encR; @@ -887,11 +892,13 @@ void dstar_header_decode(dsd_state * state, int radioheaderbuffer[660]); #ifdef __cplusplus extern "C" { #endif + +#ifdef USE_RTLSDR void open_rtlsdr_stream(dsd_opts *opts); void cleanup_rtlsdr_stream(); void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state); void rtlsdr_sighandler(); - +#endif //TRELLIS void CDMRTrellisTribitsToBits(const unsigned char* tribits, unsigned char* payload); unsigned int CDMRTrellisCheckCode(const unsigned char* points, unsigned char* tribits); diff --git a/src/dmr_bs.c b/src/dmr_bs.c index f68d95e..e771112 100644 --- a/src/dmr_bs.c +++ b/src/dmr_bs.c @@ -368,23 +368,35 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR [SLOT1] slot2 | | DMRSTEREO | VC%d ",vc1); - if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } else { fprintf (stderr,"Sync: -DMR [SLOT1] slot2 | | DMRSTEREO | VC%d ",vc1); - if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } } @@ -395,23 +407,35 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR slot1 [SLOT2] | | DMRSTEREO | VC%d ",vc2); - if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } else { fprintf (stderr,"Sync: -DMR slot1 [SLOT2] | | DMRSTEREO | VC%d ",vc2); - if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } } @@ -435,10 +459,10 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (internalslot == 0 && vc1 == 6) { - + state->DMRvcL = 0; if (state->payload_algid >= 0x21) { - //running this as state->payload_mi > 0 apparently causes some problem, don't know why + if (state->payload_mi != 0 && state->payload_algid >= 0x21) { LFSR(state); @@ -449,12 +473,12 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (internalslot == 1 && vc2 == 6) { - + state->DMRvcR = 0; if (state->payload_algidR >= 0x21) { if (state->payload_miR != 0 && state->payload_algidR == 0x21) { - LFSR(state); //re-enable this one after testing Late Entry MI + LFSR(state); } fprintf (stderr, "\n"); } @@ -565,8 +589,8 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) //payload buffer //CACH + First Half Payload + Sync = 12 + 54 + 24 - dibit_p = state->dibit_buf_p - 90; //this seems to work okay for both - //dibit_p = state->dmr_payload_p - 90; + //dibit_p = state->dibit_buf_p - 90; //this seems to work okay for both + dibit_p = state->dmr_payload_p - 90; for (i = 0; i < 90; i++) //90 { dibit = *dibit_p; @@ -710,6 +734,9 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) fprintf (stderr, "\n"); } + state->DMRvcL = 0; + state->DMRvcR = 0; + processMbeFrame (opts, state, NULL, ambe_fr, NULL); processMbeFrame (opts, state, NULL, ambe_fr2, NULL); processMbeFrame (opts, state, NULL, ambe_fr3, NULL); diff --git a/src/dmr_data.c b/src/dmr_data.c index 2c6b709..ea80c19 100644 --- a/src/dmr_data.c +++ b/src/dmr_data.c @@ -51,15 +51,15 @@ processDMRdata (dsd_opts * opts, dsd_state * state) ccAscii[4] = 0; bursttype[4] = 0; - dibit_p = state->dibit_buf_p - 90; + //dibit_p = state->dibit_buf_p - 90; //using the estimate_symbol method for the dmr_payload_p buffer causes sync //issues with P25, so only do it when frame_p25p1 == 0, or -fr option //temp fix to only use dmr_payload_p buffer when no inversion expected, otherwise use dibit_buf - if (opts->frame_p25p1 == 0 && opts->inverted_dmr == 0) //opts->frame_p25p1 == 0 && opts->inverted_dmr == 0 - { - dibit_p = state->dmr_payload_p - 90; - } - + // if (opts->frame_p25p1 == 0 && opts->inverted_dmr == 0) //opts->frame_p25p1 == 0 && opts->inverted_dmr == 0 + // { + // dibit_p = state->dmr_payload_p - 90; + // } + dibit_p = state->dmr_payload_p - 90; // CACH, why aren't we running any FEC on this? for (i = 0; i < 12; i++) { diff --git a/src/dmr_ms.c b/src/dmr_ms.c index 10e93c8..c4b83cb 100644 --- a/src/dmr_ms.c +++ b/src/dmr_ms.c @@ -366,24 +366,36 @@ void dmrMS (dsd_opts * opts, dsd_state * state) if (internalslot == 0 && opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc1); - if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } if (internalslot == 0 && opts->inverted_dmr == 1) { fprintf (stderr,"Sync: -DMR MS MODE | Color Code=%02d | DMRSTEREO | VC%d ", state->color_code, vc1); - if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } @@ -400,10 +412,9 @@ void dmrMS (dsd_opts * opts, dsd_state * state) processMbeFrame (opts, state, NULL, ambe_fr2, NULL); processMbeFrame (opts, state, NULL, ambe_fr3, NULL); - //need to seperate the algs here so we don't run LFSR on 22 and so on if (vc1 == 6 && state->payload_algid >= 21) { - //state->currentslot = 0; + state->DMRvcL = 0; if (state->payload_mi != 0 && state->payload_algid >= 0x21) { LFSR(state); @@ -614,29 +625,44 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR MS MODE | Frame Sync | DMRSTEREO | VC1 "); - if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || - (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) ) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x68) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } else { fprintf (stderr,"Sync: -DMR MS MODE | Frame Sync | DMRSTEREO | VC1 "); - if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || - (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) ) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); } + if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x68) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); + } fprintf (stderr, "\n"); } state->dmr_ms_mode = 1; + state->DMRvcL = 0; processMbeFrame (opts, state, NULL, ambe_fr, NULL); processMbeFrame (opts, state, NULL, ambe_fr2, NULL); diff --git a/src/dmr_process_voice.c b/src/dmr_process_voice.c index e69d4ec..ca3c577 100644 --- a/src/dmr_process_voice.c +++ b/src/dmr_process_voice.c @@ -72,7 +72,7 @@ int BP[256] = { }; -if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) +if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); @@ -93,7 +93,7 @@ if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->pa } } -if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) +if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); @@ -114,6 +114,70 @@ if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->p } } +if (state->currentslot == 0 && state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) +{ + + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " HYT %010llX", state->H); + fprintf (stderr, "%s", KNRM); + k = state->H; + + unsigned long long int msb = 0; + + k = k << 8; + k = k | ((k >> 40) & 0xFF); + + for(Frame = 0; Frame < 6; Frame++) + { + for(i = 0; i < 3; i++) + { + for(j = 0; j < 48; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= x; + } + + k = k << 1; + msb = (k >> 32) & 0xFFFF; + k = (k << 8) & 0xFFFFFFFF0000; + k = k | msb; + + } + } +} + +if (state->currentslot == 1 && state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) +{ + + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " HYT %010llX", state->H); + fprintf (stderr, "%s", KNRM); + k = state->H; + + unsigned long long int msb = 0; + + k = k << 8; + k = k | ((k >> 40) & 0xFF); + + for(Frame = 0; Frame < 6; Frame++) + { + for(i = 0; i < 3; i++) + { + for(j = 0; j < 48; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= x; + } + + k = k << 1; + msb = (k >> 32) & 0xFFFF; + k = (k << 8) & 0xFFFFFFFF0000; + k = k | msb; + + } + } +} + if (state->currentslot == 0) { diff --git a/src/dmr_sync.c b/src/dmr_sync.c index abab941..2d78fb9 100644 --- a/src/dmr_sync.c +++ b/src/dmr_sync.c @@ -1918,7 +1918,7 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 DmrDataBit[j + 6] = (DmrDataByte[i] >> 1) & 0x01; DmrDataBit[j + 7] = (DmrDataByte[i] >> 0) & 0x01; } - //fprintf (stderr, "\nDDB = 0x%X \n", DmrDataBit); + /* Store the Protect Flag (PF) bit */ TSVoiceSupFrame->FullLC.ProtectFlag = (unsigned int)(DmrDataBit[0]); @@ -1930,7 +1930,6 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 /* Store the Feature set ID (FID) */ TSVoiceSupFrame->FullLC.FeatureSetID = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[8], 8); - //state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; /* Store the Service Options */ TSVoiceSupFrame->FullLC.ServiceOptions = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[16], 8); @@ -1940,7 +1939,6 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 /* Store the Source address */ TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[48], 24); - //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; if((IrrecoverableErrors == 0) && CRCCorrect) { @@ -1948,24 +1946,36 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 TSVoiceSupFrame->FullLC.DataValidity = 1; if (state->currentslot == 0) { + state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; + state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; } if (state->currentslot == 1) { + state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; + state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; } } else if(IrrecoverableErrors == 0) { - //FEC okay? Set SVCop code anyways - TSVoiceSupFrame->FullLC.DataValidity = 0; //shouldn't matter in this context + //FEC okay. Set all variables anyways. + TSVoiceSupFrame->FullLC.DataValidity = 0; if (state->currentslot == 0) { + state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; + state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; } if (state->currentslot == 1) { + state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; + state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; } } else @@ -1973,19 +1983,12 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 /* CRC checking error, so consider the Full LC data as invalid */ TSVoiceSupFrame->FullLC.DataValidity = 0; } - //Full, amateur callsigns and labels not on this, - if (opts->payload == 1) - { - //fprintf (stderr, "\nFull VoiceLC Payload "); - for (i = 0; i < 12; i++) - { - //fprintf (stderr, "[%02X]", DmrDataByte[i]); - } - } + /* Print the destination ID (TG) and the source ID */ fprintf (stderr, "%s \n", KGRN); - fprintf (stderr, " Slot %d ", state->currentslot+1); - fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf (stderr, " SLOT %d ", state->currentslot+1); + fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions); if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency "); if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40) @@ -2186,16 +2189,26 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19 { state->payload_algid = 0; state->payload_keyid = 0; - //state->payload_mfid = 0; state->payload_mi = 0; + // state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + //state->dmr_fid = 0; + //state->dmr_so = 0; //leave disabled so will persist to aid in muting or unmuting when required + state->lastsrc = 0; + state->lasttg = 0; } if (state->currentslot == 1) { state->payload_algidR = 0; state->payload_keyidR = 0; - //state->payload_mfid = 0; state->payload_miR = 0; + // state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + //state->dmr_fidR = 0; + //state->dmr_soR = 0; + state->lastsrcR = 0; + state->lasttgR = 0; } @@ -2203,31 +2216,33 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19 if((IrrecoverableErrors == 0) && CRCCorrect) //amateur DMR seems to only set radio ID up here I think, figure out best way to set without messing up other DMR types { fprintf (stderr, "%s \n", KRED); - fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf (stderr, " SLOT %d ", state->currentslot+1); + fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions); fprintf (stderr, "%s ", KNRM); - //fprintf(stderr, "(CRC OK ) "); + if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. { if (state->currentslot == 0) { - state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; - state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + // state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + //zero out src and tgt here as well, or will that cause issues with ncurses terminal and per call? } if (state->currentslot == 1) { - state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; - state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + // state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + //zero out src and tgt here as well, or will that cause issues with ncurses terminal and per call? } } } else if(IrrecoverableErrors == 0) { fprintf (stderr, "%s \n", KRED); - fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf (stderr, " SLOT %d ", state->currentslot+1); + fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions); fprintf(stderr, "RAS (FEC OK/CRC ERR)"); //tlc fprintf (stderr, "%s ", KNRM); if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode == 0) //other opcodes may convey callsigns, names, etc. @@ -2235,13 +2250,13 @@ void ProcessDmrTerminaisonLC(dsd_opts * opts, dsd_state * state, uint8_t info[19 { if (state->currentslot == 0) { - state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; - state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; + // state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; } if (state->currentslot == 1) { - state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; - state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; + // state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; + // state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; } } } @@ -2306,11 +2321,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) uint8_t CRCComputed; uint32_t CRCCorrect = 0; - /* Remove warning compiler */ - //UNUSED_VARIABLE(opts); - - /* Check the current time slot */ - if(state->currentslot == 0) { TSVoiceSupFrame = &state->TS1SuperFrame; @@ -2320,7 +2330,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) TSVoiceSupFrame = &state->TS2SuperFrame; } - /* First step : Reconstitute the BPTC 16x8 matrix */ Burst = 1; /* Burst B to E contains embedded signaling data */ k = 0; @@ -2395,7 +2404,6 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) /* Store the Source address */ TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&LC_DataBit[48], 24); - //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; /* Check the CRC values */ if((IrrecoverableErrors == 0))// && CRCCorrect) @@ -2440,7 +2448,7 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) { fprintf(stderr, "\n"); } - fprintf (stderr, " SLOT %d", state->currentslot+1); + fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " Embedded Alias Header and Blocks: [%s%s%s%s%s]", state->dmr_callsign[state->currentslot][0], state->dmr_callsign[state->currentslot][1], state->dmr_callsign[state->currentslot][2], state->dmr_callsign[state->currentslot][3], state->dmr_callsign[state->currentslot][4] ); @@ -2467,7 +2475,7 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) { fprintf(stderr, "\n"); } - fprintf (stderr, " SLOT %d", state->currentslot+1); + fprintf (stderr, " SLOT %d", state->currentslot+1); fprintf (stderr, " Embedded GPS: [%s]", state->dmr_callsign[state->currentslot][5] ); fprintf (stderr, "%s ", KNRM); } @@ -2483,11 +2491,45 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) { fprintf(stderr, "\n"); } - fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf (stderr, " SLOT %d ", state->currentslot+1); + fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions); fprintf (stderr, "%s ", KNRM); - //fprintf(stderr, "(CRC OK ) "); + + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40) + { + fprintf (stderr, "%s ", KRED); + fprintf(stderr, "Encrypted "); + //fprintf (stderr, "%s ", KNRM); + } + else + { + fprintf (stderr, "%s ", KGRN); + fprintf(stderr, "Clear/Unencrypted "); + //fprintf (stderr, "%s ", KNRM); + } + + /* Check the "Reserved" bits */ + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) + { + /* Experimentally determined with DSD+, when the "Reserved" bit field + * is equal to 0x2, this is a TXI call */ + if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) == 0x20) fprintf(stderr, "TXI "); + else fprintf(stderr, "Reserved=%d ", (TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) >> 4); + } + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x08) fprintf(stderr, "Broadcast "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x04) fprintf(stderr, "OVCM "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) + { + if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x01) fprintf(stderr, "Priority 1 "); + else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x02) fprintf(stderr, "Priority 2 "); + else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x03) fprintf(stderr, "Priority 3 "); + else fprintf(stderr, "No Priority "); /* We should never go here */ + } + fprintf(stderr, "Call "); + fprintf (stderr, "%s ", KNRM); + if (state->currentslot == 0) { state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; @@ -2516,12 +2558,47 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) { fprintf(stderr, "\n"); } - fprintf (stderr, " SLOT %d", state->currentslot+1); - fprintf(stderr, " TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); - //fprintf(stderr, "FID=0x%02X ", TSVoiceSupFrame->FullLC.FeatureSetID); + fprintf (stderr, " SLOT %d ", state->currentslot+1); + fprintf(stderr, "TGT=%u SRC=%u ", TSVoiceSupFrame->FullLC.GroupAddress, TSVoiceSupFrame->FullLC.SourceAddress); + fprintf(stderr, "FID=0x%02X SVC=0x%02X", TSVoiceSupFrame->FullLC.FeatureSetID, TSVoiceSupFrame->FullLC.ServiceOptions); fprintf (stderr, "%s ", KRED); fprintf(stderr, "RAS (FEC OK/CRC ERR) "); fprintf (stderr, "%s ", KNRM); + + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x80) fprintf(stderr, "Emergency "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x40) + { + fprintf (stderr, "%s ", KRED); + fprintf(stderr, "Encrypted "); + //fprintf (stderr, "%s ", KNRM); + } + else + { + fprintf (stderr, "%s ", KGRN); + fprintf(stderr, "Clear/Unencrypted "); + //fprintf (stderr, "%s ", KNRM); + } + + /* Check the "Reserved" bits */ + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) + { + /* Experimentally determined with DSD+, when the "Reserved" bit field + * is equal to 0x2, this is a TXI call */ + if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) == 0x20) fprintf(stderr, "TXI "); + else fprintf(stderr, "Reserved=%d ", (TSVoiceSupFrame->FullLC.ServiceOptions & 0x30) >> 4); + } + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x08) fprintf(stderr, "Broadcast "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x04) fprintf(stderr, "OVCM "); + if(TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) + { + if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x01) fprintf(stderr, "Priority 1 "); + else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x02) fprintf(stderr, "Priority 2 "); + else if((TSVoiceSupFrame->FullLC.ServiceOptions & 0x03) == 0x03) fprintf(stderr, "Priority 3 "); + else fprintf(stderr, "No Priority "); /* We should never go here */ + } + fprintf(stderr, "Call "); + fprintf (stderr, "%s ", KNRM); + if (state->currentslot == 0) { state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; diff --git a/src/dsd_dibit.c b/src/dsd_dibit.c index bd4b261..f6e2b82 100644 --- a/src/dsd_dibit.c +++ b/src/dsd_dibit.c @@ -318,6 +318,13 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol) // store non-inverted values in dibit_buf *state->dibit_buf_p = invert_dibit(dibit); state->dibit_buf_p++; + + //dmr buffer + *state->dmr_payload_p = invert_dibit(dibit); //invert, or no? + // *state->dmr_payload_p = dibit; //invert, or no? + state->dmr_payload_p++; + //dmr buffer end + return dibit; } else diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 1d018dc..c4497e8 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -295,14 +295,14 @@ getFrameSync (dsd_opts * opts, dsd_state * state) state->dmr_payload_p = state->dmr_payload_buf + 200; } - int valid; + // int valid; //running estimate_symbol causes an issue with P25 syncing properly - if (opts->frame_p25p1 != 1) - { - valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit); - } + // if (opts->frame_p25p1 != 1) + // { + // valid = estimate_symbol(state->rf_mod, &(state->p25_heuristics), state->last_dibit, symbol, &dibit); + // } - if (opts->frame_dmr == 1 && valid == 0) //opts->dmr_stereo + if (1 == 1) //opts->dmr_stereo //opts->frame_dmr == 1 && valid == 0 { if (symbol > state->center) { diff --git a/src/dsd_main.c b/src/dsd_main.c index 5b2ebf9..643f549 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -144,6 +144,16 @@ noCarrier (dsd_opts * opts, dsd_state * state) state->payload_keyid = 0; state->payload_keyidR = 0; + state->dmr_fid = 0; + state->dmr_so = 0; + state->dmr_fidR = 0; + state->dmr_soR = 0; + + state->HYTL = 0; + state->HYTR = 0; + state->DMRvcL = 0; + state->DMRvcR = 0; + state->payload_miN = 0; state->p25vc = 0; state->payload_miP = 0; @@ -469,6 +479,7 @@ initState (dsd_state * state) state->K = 0; state->R = 0; + state->H = 0; state->dmr_stereo = 0; state->dmrburstL = 17; //initialize at higher value than possible @@ -479,6 +490,11 @@ initState (dsd_state * state) state->dmr_fidR = 0; state->dmr_ms_mode = 0; + state->HYTL = 0; + state->HYTR = 0; + state->DMRvcL = 0; + state->DMRvcR = 0; + state->p25vc = 0; state->payload_miP = 0; @@ -616,6 +632,10 @@ usage () printf (" Use if skipping occurs, but may cause wonky audio due to loss of good sync\n"); printf (" -Z Log MBE/Frame Payloads to console\n"); printf ("\n"); + printf (" -K Manually Enter DMRA BP Key (Decimal Value of Key Number)\n"); + printf ("\n"); + printf (" -H Manually Enter **tera 10 BP Key (40-Bit/10-Char Hex Value)\n"); + printf ("\n"); exit (0); } @@ -854,7 +874,7 @@ main (int argc, char **argv) exitflag = 0; signal (SIGINT, sigfun); - while ((c = getopt (argc, argv, "haep:P:qstv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:NQWrlZTF")) != -1) + while ((c = getopt (argc, argv, "haep:P:qstv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:NQWrlZTF")) != -1) { opterr = 0; switch (c) @@ -933,6 +953,21 @@ main (int argc, char **argv) } break; + case 'H': + sscanf (optarg, "%llX", &state.H); + if (state.H > 0xFFFFFFFFFF) + { + state.H = 0xFFFFFFFFFF; + } + opts.dmr_mute_encL = 0; + opts.dmr_mute_encR = 0; + if (state.H == 0) + { + opts.dmr_mute_encL = 1; + opts.dmr_mute_encR = 1; + } + break; + case 'G': //Set rtl device gain sscanf (optarg, "%d", &opts.rtl_gain_value); //multiple value by ten to make it consitent with the way rtl_fm really works break; diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index 0824586..2ba4391 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -228,8 +228,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a mbe_demodulateAmbe3600x2450Data (ambe_fr); state->errs2 += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); - // - if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) // + if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { k = BP[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); @@ -240,6 +239,36 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a } } + if (state->currentslot == 0 && state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) + { + unsigned long long int msb = 0; + if (state->DMRvcL == 0) + { + state->HYTL = state->H; + k = state->H; + + k = k << 8; + k = k | ((k >> 40) & 0xFF); + state->HYTL = k; + } + + k = state->HYTL; + for(short int j = 0; j < 48; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + ambe_d[j] ^= x; + } + + k = k << 1; + msb = (k >> 32) & 0xFFFF; //new MSB + k = (k << 8) & 0xFFFFFFFF0000; + k = k | msb; + + state->HYTL = k; + state->DMRvcL++; + + } + mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); @@ -260,8 +289,8 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a mbe_demodulateAmbe3600x2450Data (ambe_fr); state->errs2R += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); - //BP Handling, Slot 2 - if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) // + + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) { k = BP[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); @@ -272,6 +301,36 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a } } + if (state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) + { + unsigned long long int msb = 0; + if (state->DMRvcR == 0) + { + state->HYTR = state->H; + k = state->H; + + k = k << 8; + k = k | ((k >> 40) & 0xFF); + state->HYTR = k; + } + + k = state->HYTR; + for(short int j = 0; j < 48; j++) + { + x = ( ((k << j) & 0x800000000000) >> 47 ); + ambe_d[j] ^= x; + } + + k = k << 1; + msb = (k >> 32) & 0xFFFF; + k = (k << 8) & 0xFFFFFFFF0000; + k = k | msb; + + state->HYTR = k; + state->DMRvcR++; + + } + mbe_processAmbe2450Dataf (state->audio_out_temp_bufR, &state->errsR, &state->errs2R, state->err_strR, ambe_d, state->cur_mp2, state->prev_mp2, state->prev_mp_enhanced2, opts->uvquality); diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index c98801f..70998bd 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -206,7 +206,7 @@ char *choices[] = { "Decode NXDN96", "Decode X2-TDMA*", "Toggle Signal Inversion", - " ", //spacer + "Basic Key Entry", //spacer "Reset Call History", "Enable Payloads to Console", "Disable Payloads to Console", @@ -312,13 +312,6 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) closePulseInput(opts); } - if (opts->audio_in_type == 3) - { - //function hangs, figure out why I can't release/stop the dongle - //cleanup_rtlsdr_stream(); //close down the rtl dongle - //rtlsdr_sighandler(); - } - state->payload_keyid = 0; state->payload_keyidR = 0; @@ -809,27 +802,59 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) { state->payload_keyid = 0; state->payload_keyidR = 0; - state->K = 0; - - entry_win = newwin(6, WIDTH+6, starty+10, startx+10); + // state->K = 0; + // state->H = 0; + short int option = 0; + entry_win = newwin(9, WIDTH+6, starty+10, startx+10); box (entry_win, 0, 0); - mvwprintw(entry_win, 2, 2, " "); - mvwprintw(entry_win, 3, 3, " "); + mvwprintw(entry_win, 2, 2, "Key Type Selection"); + mvwprintw(entry_win, 3, 2, " "); + mvwprintw(entry_win, 4, 2, "1 - DMRA BP "); + mvwprintw(entry_win, 5, 2, "2 - Tera BP "); + mvwprintw(entry_win, 6, 3, " "); echo(); refresh(); - wscanw(entry_win, "%d", &state->K); + wscanw(entry_win, "%d", &option); noecho(); opts->dmr_mute_encL = 0; opts->dmr_mute_encR = 0; - if (state->K > 255) + if (option == 1) { - state->K = 255; + entry_win = newwin(6, WIDTH+6, starty+10, startx+10); + box (entry_win, 0, 0); + mvwprintw(entry_win, 2, 2, "DMRA BP Key Number (DEC):"); + mvwprintw(entry_win, 3, 3, " "); + echo(); + refresh(); + wscanw(entry_win, "%lld", &state->K); + noecho(); + if (state->K > 255) + { + state->K = 255; + } } - if (state->K == 0) + if (option == 2) + { + entry_win = newwin(6, WIDTH+6, starty+10, startx+10); + box (entry_win, 0, 0); + mvwprintw(entry_win, 2, 2, "**Tera 10 Key Value (HEX):"); + mvwprintw(entry_win, 3, 3, " "); + echo(); + refresh(); + wscanw(entry_win, "%llX", &state->H); + noecho(); + if (state->H > 0xFFFFFFFFFF) + { + state->H = 0xFFFFFFFFFF; + } + } + + if (state->K == 0 && state->H == 0) { opts->dmr_mute_encL = 1; opts->dmr_mute_encR = 1; } + break; } @@ -1367,7 +1392,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } - if (state->dmrburstR == 16 && state->lastsrcR > 0) //state->currentslot == 1 && + if (state->dmrburstR == 16 && state->lasttgR > 0) //state->currentslot == 1 && { tgR = state->lasttgR; @@ -1766,7 +1791,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (state->payload_algid == 0xAA) { attron(COLOR_PAIR(1)); - printw(" ADP/RC4"); + printw(" RC4"); attron(COLOR_PAIR(3)); } if (state->payload_algid == 0x81) @@ -1810,7 +1835,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw ("\n"); //printw ("| | "); //10 spaces printw ("| V XTRA | "); //10 spaces - //Burger King + if(state->dmrburstL == 16 && state->payload_algid == 0 && (state->dmr_so & 0xCF) == 0x40) //4F or CF mask? & 0xCF currently { attron(COLOR_PAIR(5)); @@ -1818,14 +1843,24 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) attroff(COLOR_PAIR(5)); attron(COLOR_PAIR(3)); } - //Point - if(state->dmrburstL == 16 && state->payload_algid == 0 && state->K > 0 && (state->dmr_so & 0xCF) == 0x40) + + if(state->dmrburstL == 16 && state->payload_algid == 0 && state->K > 0 && state->dmr_fid == 0x10 && (state->dmr_so & 0xCF) == 0x40) { attron(COLOR_PAIR(1)); - printw ("BPK [%3lld] ", state->K); + //printw ("BPK [%3lld] ", state->K); + printw ("DMRA BP Key [%3lld] ", state->K); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } + + if(state->dmrburstL == 16 && state->payload_algid == 0 && state->H > 0 && state->dmr_fid == 0x68 && ((state->dmr_so & 0xCF) == 0x40) ) + { + attron(COLOR_PAIR(1)); + printw ("**Tera BP Key [%010llX] ", state->H); + attroff(COLOR_PAIR(1)); + attron(COLOR_PAIR(3)); + } + //ALG, KeyID, MI //was key_id if(state->dmrburstL == 16 && state->payload_algid > 0 && (state->dmr_so & 0xCF) == 0x40) { @@ -1911,7 +1946,6 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) //printw ("| | "); //12 spaces printw ("| V XTRA | "); //10 spaces - //Burger King 2 if(state->dmrburstR == 16 && state->payload_algidR == 0 && (state->dmr_soR & 0xCF) == 0x40) //4F or CF mask? { attron(COLOR_PAIR(5)); @@ -1919,11 +1953,18 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) attroff(COLOR_PAIR(5)); attron(COLOR_PAIR(3)); } - //Point 2 - if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->K > 0 && (state->dmr_soR & 0xCF) == 0x40) + + if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->K > 0 && ((state->dmr_soR & 0xCF) == 0x40) && state->dmr_fidR == 0x10) { attron(COLOR_PAIR(1)); - printw ("BPK [%3lld] ", state->K); + printw ("DMRA BP Key [%3lld] ", state->K); + attroff(COLOR_PAIR(1)); + attron(COLOR_PAIR(3)); + } + if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->H > 0 && ((state->dmr_soR & 0xCF) == 0x40) && state->dmr_fidR == 0x68) + { + attron(COLOR_PAIR(1)); + printw ("**Tera BP Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } From 092da7b6d002121f10ba52c05ae6070df56975ed Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Sun, 21 Aug 2022 23:55:16 -0400 Subject: [PATCH 2/8] Nomenclature Fix Nomenclature Fix --- src/dmr_process_voice.c | 4 ++-- src/dsd_ncurses.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dmr_process_voice.c b/src/dmr_process_voice.c index ca3c577..86810d1 100644 --- a/src/dmr_process_voice.c +++ b/src/dmr_process_voice.c @@ -118,7 +118,7 @@ if (state->currentslot == 0 && state->H > 0 && state->dmr_so & 0x40 && state->pa { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " HYT %010llX", state->H); + fprintf(stderr, " T10 %010llX", state->H); fprintf (stderr, "%s", KNRM); k = state->H; @@ -150,7 +150,7 @@ if (state->currentslot == 1 && state->H > 0 && state->dmr_soR & 0x40 && state->p { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " HYT %010llX", state->H); + fprintf(stderr, " T10 %010llX", state->H); fprintf (stderr, "%s", KNRM); k = state->H; diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 70998bd..2509279 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -206,7 +206,7 @@ char *choices[] = { "Decode NXDN96", "Decode X2-TDMA*", "Toggle Signal Inversion", - "Basic Key Entry", //spacer + "Privacy Key Entry", //spacer "Reset Call History", "Enable Payloads to Console", "Disable Payloads to Console", From 2ec4250e5b0b4c57b890f8aaf75ee5fe3810fddd Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 00:56:01 -0400 Subject: [PATCH 3/8] Disable setting state src and tgt on VLC Header Disable setting state src and tgt on VLC Header --bugfix for ncurses terminal specifically to prevent the Voice LC Header setting the src and tgt ids; --some TIII systems seem to have different values for that than what is in the TLC and Voice Burst. --console printout can still show erroneous VLC header radio src ids that don't match the TLC or Voice Burst. --- src/dmr_sync.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/dmr_sync.c b/src/dmr_sync.c index 2d78fb9..ad579a6 100644 --- a/src/dmr_sync.c +++ b/src/dmr_sync.c @@ -1618,7 +1618,7 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t uint8_t nb4 = DmrDataByte[5] & 0x3F; //extract(csbk, 42, 48); uint8_t nb5 = DmrDataByte[6] & 0x3F; //extract(csbk, 50, 56); fprintf (stderr, "\nMotoTRBO Capacity Plus Neighbors"); - //fprintf(stderr, " NB1(%02x), NB2(%02x), NB3(%02x), NB4(%02x), NB5(%02x)", nb1, nb2, nb3, nb4, nb5); + fprintf(stderr, " NB1(%02x), NB2(%02x), NB3(%02x), NB4(%02x), NB5(%02x)", nb1, nb2, nb3, nb4, nb5); sprintf(state->dmr_branding, " MotoTRBO Capacity Plus "); } @@ -1842,6 +1842,9 @@ void ProcessDmrPIHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], u } +//need to look into differences with Cap+ and other systems affecting the expected radio src id values +//find a way to differentiate the system types so we get good radio id decodes all the time +//svc op 0x60 for cap+?? if so, then should we use a mask? void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20]) { uint32_t i, j, k; @@ -1861,7 +1864,7 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 { TSVoiceSupFrame = &state->TS1SuperFrame; } - else + if(state->currentslot == 1) { TSVoiceSupFrame = &state->TS2SuperFrame; } @@ -1948,15 +1951,15 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 { state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; - state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; - state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; + //state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; + //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; //disabled for now, Cap+ and other systems cause issues with these values } if (state->currentslot == 1) { state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; - state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; - state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; + //state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; + //state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; } } else if(IrrecoverableErrors == 0) @@ -1967,15 +1970,15 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19 { state->dmr_fid = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_so = TSVoiceSupFrame->FullLC.ServiceOptions; - state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; - state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; + //state->lasttg = TSVoiceSupFrame->FullLC.GroupAddress; + //state->lastsrc = TSVoiceSupFrame->FullLC.SourceAddress; } if (state->currentslot == 1) { state->dmr_fidR = TSVoiceSupFrame->FullLC.FeatureSetID; state->dmr_soR = TSVoiceSupFrame->FullLC.ServiceOptions; - state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; - state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; + //state->lasttgR = TSVoiceSupFrame->FullLC.GroupAddress; + //state->lastsrcR = TSVoiceSupFrame->FullLC.SourceAddress; } } else @@ -2359,14 +2362,12 @@ void ProcessVoiceBurstSync(dsd_opts * opts, dsd_state * state) for(i = 0; i < 10; i++) { LC_DataBytes[i] = 0; - for(j = 0; j < 8; j++) - //for(j = 0; j < 10; j++) + for(j = 0; j < 10; j++) //why did I change this? { LC_DataBytes[i] = LC_DataBytes[i] << 1; LC_DataBytes[i] = LC_DataBytes[i] | (LC_DataBit[k] & 0x01); k++; if(k >= 76) break; - //if(k >= 80) break; } } From eb9152fb4e0b1ff7149d2555283205b5c449194a Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 01:49:56 -0400 Subject: [PATCH 4/8] More Nomenclature Fixes --maybe I can finally settle on this naming scheme --- src/dsd_main.c | 2 +- src/dsd_ncurses.c | 10 +++++----- src/dsd_symbol.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dsd_main.c b/src/dsd_main.c index 643f549..af829b8 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -634,7 +634,7 @@ usage () printf ("\n"); printf (" -K Manually Enter DMRA BP Key (Decimal Value of Key Number)\n"); printf ("\n"); - printf (" -H Manually Enter **tera 10 BP Key (40-Bit/10-Char Hex Value)\n"); + printf (" -H Manually Enter Terra 10 BP Key (40-Bit/10-Char Hex Value)\n"); printf ("\n"); exit (0); } diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 2509279..8102daf 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -809,8 +809,8 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) box (entry_win, 0, 0); mvwprintw(entry_win, 2, 2, "Key Type Selection"); mvwprintw(entry_win, 3, 2, " "); - mvwprintw(entry_win, 4, 2, "1 - DMRA BP "); - mvwprintw(entry_win, 5, 2, "2 - Tera BP "); + mvwprintw(entry_win, 4, 2, "1 - DMRA BP "); + mvwprintw(entry_win, 5, 2, "2 - Terra BP "); mvwprintw(entry_win, 6, 3, " "); echo(); refresh(); @@ -837,7 +837,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) { entry_win = newwin(6, WIDTH+6, starty+10, startx+10); box (entry_win, 0, 0); - mvwprintw(entry_win, 2, 2, "**Tera 10 Key Value (HEX):"); + mvwprintw(entry_win, 2, 2, "**Terra 10 Key Value (HEX):"); mvwprintw(entry_win, 3, 3, " "); echo(); refresh(); @@ -1856,7 +1856,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && state->H > 0 && state->dmr_fid == 0x68 && ((state->dmr_so & 0xCF) == 0x40) ) { attron(COLOR_PAIR(1)); - printw ("**Tera BP Key [%010llX] ", state->H); + printw ("**Terra BP Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } @@ -1964,7 +1964,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->H > 0 && ((state->dmr_soR & 0xCF) == 0x40) && state->dmr_fidR == 0x68) { attron(COLOR_PAIR(1)); - printw ("**Tera BP Key [%010llX] ", state->H); + printw ("**Terra BP Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } diff --git a/src/dsd_symbol.c b/src/dsd_symbol.c index 39016ba..1c6d85c 100644 --- a/src/dsd_symbol.c +++ b/src/dsd_symbol.c @@ -358,7 +358,7 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) //use fopen and read in a symbol, check op25 for clues if(opts->symbolfile == NULL) { - fprintf(stderr, "Error Opening File %s\n", opts->symbolfile); + fprintf(stderr, "Error Opening File %s\n", opts->audio_in_dev); //double check this return(-1); } From b7bb59dbba2f57b8052da0223405c040f69357e1 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 02:34:29 -0400 Subject: [PATCH 5/8] Additional Console Print Fixes Additional Console Print Fixes --missed a few places where we needed to have info printing --- src/dmr_bs.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/dmr_bs.c b/src/dmr_bs.c index e771112..8a7a85d 100644 --- a/src/dmr_bs.c +++ b/src/dmr_bs.c @@ -710,26 +710,40 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) if (opts->inverted_dmr == 0) { fprintf (stderr,"Sync: +DMR | Frame Sync | DMRSTEREO | VC1 "); - if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || - (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); - //state->currentslot = 0; //slot now set from cach data from buffer + + } + if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); } fprintf (stderr, "\n"); } else { fprintf (stderr,"Sync: -DMR | Frame Sync | DMRSTEREO | VC1 "); - if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0) || - (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0) ) + if ( (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ) { fprintf (stderr, "%s", KYEL); fprintf(stderr, " BPK %lld", state->K); fprintf (stderr, "%s", KNRM); - //state->currentslot = 0; //slot now set from cach data from buffer + + } + if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || + (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) ) + { + fprintf (stderr, "%s", KYEL); + fprintf(stderr, " T10 %010llX", state->H); + fprintf (stderr, "%s", KNRM); } fprintf (stderr, "\n"); } From 7199848f1635f9c4f25b5bb8bdcd291e04c6e17e Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 16:55:00 -0400 Subject: [PATCH 6/8] OCD Line Spacing and Nomenclature OCD Line Spacing and Nomenclature --fixed a few alignment issues to my liking --final on nomenclature for privacy modes --- src/dmr_bs.c | 14 +++++++------- src/dmr_ms.c | 8 ++++---- src/dmr_process_voice.c | 10 +++++----- src/dsd_frame_sync.c | 2 +- src/dsd_main.c | 4 ++-- src/dsd_mbe.c | 6 +++--- src/dsd_ncurses.c | 21 ++++++++++----------- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/dmr_bs.c b/src/dmr_bs.c index 8a7a85d..1e001b3 100644 --- a/src/dmr_bs.c +++ b/src/dmr_bs.c @@ -371,7 +371,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) @@ -388,7 +388,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) @@ -410,7 +410,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) @@ -427,7 +427,7 @@ void dmrBS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) @@ -714,7 +714,7 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } @@ -734,9 +734,9 @@ void dmrBSBootstrap (dsd_opts * opts, dsd_state * state) (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) ) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); - + } if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x68) ) diff --git a/src/dmr_ms.c b/src/dmr_ms.c index c4b83cb..b2f67e8 100644 --- a/src/dmr_ms.c +++ b/src/dmr_ms.c @@ -369,7 +369,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) @@ -387,7 +387,7 @@ void dmrMS (dsd_opts * opts, dsd_state * state) if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) @@ -629,7 +629,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) ) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || @@ -648,7 +648,7 @@ void dmrMSBootstrap (dsd_opts * opts, dsd_state * state) (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) ) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); } if ( (state->H > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x68) || diff --git a/src/dmr_process_voice.c b/src/dmr_process_voice.c index 86810d1..b3fc351 100644 --- a/src/dmr_process_voice.c +++ b/src/dmr_process_voice.c @@ -36,7 +36,7 @@ void ProcessDMR (dsd_opts * opts, dsd_state * state) TSVoiceSupFrameL = &state->TS1SuperFrame; TSVoiceSupFrameR = &state->TS2SuperFrame; -int BP[256] = { +int Pr[256] = { 0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903, 0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306, 0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B, @@ -75,9 +75,9 @@ int BP[256] = { if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); - k = BP[state->K]; + k = Pr[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); for(Frame = 0; Frame < 6; Frame++) @@ -96,9 +96,9 @@ if (state->currentslot == 0 && state->K > 0 && state->dmr_so & 0x40 && state->pa if (state->currentslot == 1 && state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { fprintf (stderr, "%s", KYEL); - fprintf(stderr, " BPK %lld", state->K); + fprintf(stderr, " PrK %lld", state->K); fprintf (stderr, "%s", KNRM); - k = BP[state->K]; + k = Pr[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); for(Frame = 0; Frame < 6; Frame++) diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index c4497e8..dfe2ab3 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -1197,7 +1197,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) } if (opts->errorbars == 1) { - printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation); + printFrameSync (opts, state, "+NXDN96 ", synctest_pos + 1, modulation); } } state->lastsynctype = 8; diff --git a/src/dsd_main.c b/src/dsd_main.c index af829b8..9b681ca 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -632,9 +632,9 @@ usage () printf (" Use if skipping occurs, but may cause wonky audio due to loss of good sync\n"); printf (" -Z Log MBE/Frame Payloads to console\n"); printf ("\n"); - printf (" -K Manually Enter DMRA BP Key (Decimal Value of Key Number)\n"); + printf (" -K Manually Enter DMRA Privacy Key (Decimal Value of Key Number)\n"); printf ("\n"); - printf (" -H Manually Enter Terra 10 BP Key (40-Bit/10-Char Hex Value)\n"); + printf (" -H Manually Enter 'Tera 10 Privacy Key (40-Bit/10-Char Hex Value)\n"); printf ("\n"); exit (0); } diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index 2ba4391..f97cff3 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -77,7 +77,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a { // - int BP[256] = { + int Pr[256] = { 0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903, 0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306, 0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B, @@ -230,7 +230,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0 && state->dmr_fid == 0x10) { - k = BP[state->K]; + k = Pr[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); for (short int j = 0; j < 48; j++) //49 { @@ -292,7 +292,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) { - k = BP[state->K]; + k = Pr[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k ); for (short int j = 0; j < 48; j++) { diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 8102daf..a8b2d5c 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -809,8 +809,8 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) box (entry_win, 0, 0); mvwprintw(entry_win, 2, 2, "Key Type Selection"); mvwprintw(entry_win, 3, 2, " "); - mvwprintw(entry_win, 4, 2, "1 - DMRA BP "); - mvwprintw(entry_win, 5, 2, "2 - Terra BP "); + mvwprintw(entry_win, 4, 2, "1 - DMRA Privacy "); + mvwprintw(entry_win, 5, 2, "2 - 'Tera Privacy "); mvwprintw(entry_win, 6, 3, " "); echo(); refresh(); @@ -822,7 +822,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) { entry_win = newwin(6, WIDTH+6, starty+10, startx+10); box (entry_win, 0, 0); - mvwprintw(entry_win, 2, 2, "DMRA BP Key Number (DEC):"); + mvwprintw(entry_win, 2, 2, "DMRA Privacy Key Number (DEC):"); mvwprintw(entry_win, 3, 3, " "); echo(); refresh(); @@ -837,7 +837,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) { entry_win = newwin(6, WIDTH+6, starty+10, startx+10); box (entry_win, 0, 0); - mvwprintw(entry_win, 2, 2, "**Terra 10 Key Value (HEX):"); + mvwprintw(entry_win, 2, 2, "'Tera 10 Key Value (HEX):"); mvwprintw(entry_win, 3, 3, " "); echo(); refresh(); @@ -1839,7 +1839,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && (state->dmr_so & 0xCF) == 0x40) //4F or CF mask? & 0xCF currently { attron(COLOR_PAIR(5)); - printw (" **BP** "); + printw (" **Pr** "); attroff(COLOR_PAIR(5)); attron(COLOR_PAIR(3)); } @@ -1847,8 +1847,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && state->K > 0 && state->dmr_fid == 0x10 && (state->dmr_so & 0xCF) == 0x40) { attron(COLOR_PAIR(1)); - //printw ("BPK [%3lld] ", state->K); - printw ("DMRA BP Key [%3lld] ", state->K); + printw ("DMRA P Key [%3lld] ", state->K); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } @@ -1856,7 +1855,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && state->H > 0 && state->dmr_fid == 0x68 && ((state->dmr_so & 0xCF) == 0x40) ) { attron(COLOR_PAIR(1)); - printw ("**Terra BP Key [%010llX] ", state->H); + printw ("**'Tera P Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } @@ -1949,7 +1948,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstR == 16 && state->payload_algidR == 0 && (state->dmr_soR & 0xCF) == 0x40) //4F or CF mask? { attron(COLOR_PAIR(5)); - printw (" **BP** "); + printw (" **Pr** "); attroff(COLOR_PAIR(5)); attron(COLOR_PAIR(3)); } @@ -1957,14 +1956,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->K > 0 && ((state->dmr_soR & 0xCF) == 0x40) && state->dmr_fidR == 0x10) { attron(COLOR_PAIR(1)); - printw ("DMRA BP Key [%3lld] ", state->K); + printw ("DMRA Pr Key [%3lld] ", state->K); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } if(state->dmrburstR == 16 && state->payload_algidR == 0 && state->H > 0 && ((state->dmr_soR & 0xCF) == 0x40) && state->dmr_fidR == 0x68) { attron(COLOR_PAIR(1)); - printw ("**Terra BP Key [%010llX] ", state->H); + printw ("**'Tera Pr Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } From 88b3145cfde96d6a70fe58d1c59a0089826418f8 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 16:57:44 -0400 Subject: [PATCH 7/8] OCD Nomenclature #3 --final final on nomenclature, P to Pr --- src/dsd_ncurses.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index a8b2d5c..2c3cf4b 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -1847,7 +1847,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && state->K > 0 && state->dmr_fid == 0x10 && (state->dmr_so & 0xCF) == 0x40) { attron(COLOR_PAIR(1)); - printw ("DMRA P Key [%3lld] ", state->K); + printw ("DMRA Pr Key [%3lld] ", state->K); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } @@ -1855,7 +1855,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if(state->dmrburstL == 16 && state->payload_algid == 0 && state->H > 0 && state->dmr_fid == 0x68 && ((state->dmr_so & 0xCF) == 0x40) ) { attron(COLOR_PAIR(1)); - printw ("**'Tera P Key [%010llX] ", state->H); + printw ("**'Tera Pr Key [%010llX] ", state->H); attroff(COLOR_PAIR(1)); attron(COLOR_PAIR(3)); } From a682d9e882d3b4e4c171746601ca2d2305c6e29c Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Mon, 22 Aug 2022 17:57:05 -0400 Subject: [PATCH 8/8] DMR Stereo Slot 2 Fix DMR Stereo Slot 2 Fix --DMRA Privacy Key not applied correctly in Slot 2 Stereo Mode --- src/dsd_mbe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index f97cff3..9f516b8 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -290,7 +290,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a state->errs2R += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); - if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fid == 0x10) + if (state->K > 0 && state->dmr_soR & 0x40 && state->payload_keyidR == 0 && state->dmr_fidR == 0x10) { k = Pr[state->K]; k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );