More NXDN/IDAS Tweaks and Fixes; #115 and #118

This commit is contained in:
lwvmobile 2023-04-25 15:37:44 -04:00
parent 0908baa47c
commit acd2b0b134
4 changed files with 97 additions and 29 deletions

View File

@ -97,9 +97,9 @@ char * SyncTypes[44] = {
"NXDN",
"YSF", //30
"YSF",
"DMR MS VOICE",
"DMR MS DATA",
"DMR RC DATA",
"DMR", //DMR MS VOICE
"DMR", //DMR MS DATA
"DMR", //DMR RC DATA
"P25P2",
"P25P2",
"EDACS/PV", //37
@ -1686,6 +1686,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
void
ncursesPrinter (dsd_opts * opts, dsd_state * state)
{
uint8_t idas = 0;
int level = 0;
int c = 0;
@ -2245,6 +2246,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//NXDN
if (lls == 28 || lls == 29)
{
if (strcmp (state->nxdn_location_category, "Type-D") == 0) idas = 1;
if (opts->p25_trunk == 1)
{
@ -2252,32 +2254,36 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw ("| ");
if (opts->p25_is_tuned == 0)
{
printw ("Monitoring Control Channel");
if (idas == 0) printw ("Monitoring RCCH Channel"); //Control Channel
if (idas == 1) printw ("Monitoring RTCH2 Channel"); //Idas RTCH2 Channel
if (state->p25_cc_freq != 0)
{
printw (" - CC Freq: [%.06lf] Mhz ", (double)state->p25_cc_freq/1000000);
printw (" - Frequency: [%.06lf] Mhz ", (double)state->p25_cc_freq/1000000);
}
}
else if (opts->p25_is_tuned == 1)
{
printw ("Monitoring Voice Channel");
if (idas == 0) printw ("Monitoring RTCH Channel"); //Traffic Channel
if (idas == 1) printw ("Monitoring RTCH2 Channel"); //Idas RTCH2
if (state->p25_vc_freq[0] != 0)
{
printw (" - VC Freq: [%.06lf] Mhz ", (double)state->p25_vc_freq[0]/1000000);
printw (" - Frequency: [%.06lf] Mhz ", (double)state->p25_vc_freq[0]/1000000);
}
}
printw ("\n");
}
printw ("| ");
printw ("NXDN - RAN: [%02d] ", rn);
if (idas == 0) printw ("NXDN - RAN: [%02d] ", rn);
if (idas == 1) printw ("IDAS - Area: [%02d] ", rn);
if (state->nxdn_location_site_code != 0)
{
printw ("Cat [%s] ", state->nxdn_location_category);
printw ("Sys Code [%d] ", state->nxdn_location_sys_code);
printw ("Site Code [%d] ", state->nxdn_location_site_code);
printw ("Cat: [%s] ", state->nxdn_location_category);
printw ("Sys Code: [%d] ", state->nxdn_location_sys_code);
printw ("Site Code: [%d] ", state->nxdn_location_site_code);
}
//if system supports Direct Frequency Assignment
@ -2310,9 +2316,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
if (state->nxdn_cipher_type == 0x1 && state->carrier == 1)
{
attron(COLOR_PAIR(2));
if (state->R == 0) attron(COLOR_PAIR(2));
printw ("Scrambler ");
attroff(COLOR_PAIR(2));
if (state->R == 0) attroff(COLOR_PAIR(2));
attron(COLOR_PAIR(3));
if (state->R != 0)
{
@ -2489,6 +2495,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw("DES-OFB");
attron(COLOR_PAIR(3));
}
if (state->payload_algid == 0x82)
{
attron(COLOR_PAIR(1));
printw("Double DES");
attron(COLOR_PAIR(3));
}
if (state->payload_algid == 0x83 || state->payload_algid == 0x23)
{
attron(COLOR_PAIR(1));
@ -2931,7 +2943,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw ("| %s ", SyncTypes[call_matrix[9-j][0]]);
if (lls == 28 || lls == 29)
{
printw ("RAN [%02lld] ", call_matrix[9-j][1]);
if (idas == 0) printw ("RAN [%02lld] ", call_matrix[9-j][1]);
if (idas == 1) printw ("Area [%02lld] ", call_matrix[9-j][1]);
printw ("TG [%5lld] ", call_matrix[9-j][4]);
printw ("RID [%5lld] ", call_matrix[9-j][2]);
}
@ -2960,7 +2973,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//DMR MS Types
if (call_matrix[9-j][0] == 32 || call_matrix[9-j][0] == 33 || call_matrix[9-j][0] == 34 )
{
//printw ("S[%d] ", call_matrix[9-j][3]);
printw ("S[%lld] ", call_matrix[9-j][3]);
printw ("TGT [%8lld] ", call_matrix[9-j][1]);
printw ("SRC [%8lld] ", call_matrix[9-j][2]);
printw ("DCC [%02lld] ", call_matrix[9-j][4]);
@ -3210,6 +3223,16 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
sprintf (state->group_array[state->group_tally].groupName, "%s", "LOCKOUT");
state->group_tally++;
//if we have an opened group file, let's write a group lock out into it to make it permanent
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,B,LOCKOUT,%02X\n", state->lasttg, state->payload_algid);
fclose (pFile);
}
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
@ -3249,6 +3272,16 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
sprintf (state->group_array[state->group_tally].groupName, "%s", "LOCKOUT");
state->group_tally++;
//if we have an opened group file, let's write a group lock out into it to make it permanent
if (opts->group_in_file[0] != 0) //file is available
{
FILE * pFile; //file pointer
//open file by name that is supplied in the ncurses terminal, or cli
pFile = fopen (opts->group_in_file, "a");
fprintf (pFile, "%d,B,LOCKOUT,%02X\n", state->lasttgR, state->payload_algidR);
fclose (pFile);
}
//extra safeguards due to sync issues with NXDN
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
@ -3332,6 +3365,19 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
opts->dmr_dmrla_is_set = 0;
opts->dmr_dmrla_n = 0;
//reset NXDN info
state->nxdn_location_site_code = 0;
state->nxdn_location_sys_code = 0;
sprintf (state->nxdn_location_category, "%s", " ");
state->nxdn_last_ran = 0;
state->nxdn_ran = 0;
state->nxdn_rcn = 0;
state->nxdn_base_freq = 0;
state->nxdn_step = 0;
state->nxdn_bw = 0;
}
//Debug/Troubleshooting Option

View File

@ -272,6 +272,10 @@ void nxdn_deperm_sacch(dsd_opts * opts, dsd_state * state, uint8_t bits[60])
// if (crc != check) fprintf (stderr, " CRC ERR - %02X %02X", check, crc);
}
//reset the sacch field -- Github Issue #118
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
}
//If part of superframe, collect the fragments and send to NXDN_SACCH_Full_decode instead

View File

@ -37,6 +37,11 @@ void NXDN_SACCH_Full_decode(dsd_opts * opts, dsd_state * state)
if (CrcCorrect == 1) NXDN_Elements_Content_decode(opts, state, CrcCorrect, SACCH);
else if (opts->aggressive_framesync == 0) NXDN_Elements_Content_decode(opts, state, 0, SACCH);
//reset the sacch field -- Github Issue #118
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
} /* End NXDN_SACCH_Full_decode() */
@ -428,7 +433,8 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
/* Print Source ID and Destination ID (Talk Group or Unit ID) */
fprintf(stderr, "Src=%u - Dst/TG=%u ", SourceUnitID & 0xFFFF, DestinationID & 0xFFFF);
// if (idas) fprintf (stderr, "- Ch: %d ", rep1);
//Channel here appears to be the prefix or home channel of the caller, not necessarily the channel the call is occuring on
// if (idas) fprintf (stderr, "- Prefix Ch: %d ", rep1);
/* Print Channel */
if (state->nxdn_rcn == 0)
@ -1089,7 +1095,8 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
/* Print Source ID and Destination ID (Talk Group or Unit ID) */
fprintf(stderr, "Src=%u - Dst/TG=%u ", SourceUnitID & 0xFFFF, DestinationID & 0xFFFF);
if (idas) fprintf (stderr, "- Ch: %d ", rep1);
//Channel here appears to be the prefix or home channel of the caller, not necessarily the channel the call is occuring on
if (idas) fprintf (stderr, "- Prefix Ch: %d ", rep1);
fprintf (stderr, "%s", KNRM);
@ -1102,6 +1109,15 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
//Don't zero key if no keyloader
if (CipherType != 0x1 && state->keyloader == 1) state->R = 0;
//NOTE: Broadcast Call appears to have values that aren't typical for VCALL,
//so not applying any settings below if CallType == 0 (BC Call)
//NOTE: Above note may be in error; its possible that the issues I was having
//was from not resetting the entire SACCH superframe after reading it, and
//the samples in question having interwoven ALIAS and VCALL, and bad settings
//coming from a missed SF Part of Frame, if not reset, we could skip a SF POF
//and still believe we have a good decode -- will need further testing #118
/* Print the "Cipher Type" */
if(CipherType != 0 && MessageType == 0x1)
{
@ -1218,9 +1234,11 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
sprintf (state->nxdn_location_category, "Type-D");
//placeholder numbers, using 99 if these aren't set by the Site ID Message (single sites)
if (state->nxdn_location_site_code == 0) state->nxdn_location_site_code = 99;
if (state->nxdn_location_sys_code == 0) state->nxdn_location_sys_code = 99;
if (state->nxdn_last_ran == -1) state->nxdn_last_ran = 99;
// if (state->nxdn_location_site_code == 0) state->nxdn_location_site_code = 99;
// if (state->nxdn_location_sys_code == 0) state->nxdn_location_sys_code = 99;
// if (state->nxdn_last_ran == -1) state->nxdn_last_ran = 99;
state->nxdn_last_ran = area;
state->last_cc_sync_time = time(NULL);

View File

@ -318,7 +318,7 @@ void nxdn_frame (dsd_opts * opts, dsd_state * state)
// RF Channel Type
if (lich_rf == 0) fprintf (stderr, "RCCH ");
else if (lich_rf == 1) fprintf (stderr, "RTCH ");
else if (lich_rf == 1) fprintf (stderr, "RDCH ");
else if (lich_rf == 2) fprintf (stderr, "RDCH ");
else
{
if (lich < 0x60) fprintf (stderr, "RTCH_C ");