diff --git a/include/dsd.h b/include/dsd.h index 07205cc..a6fb88c 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -783,6 +783,10 @@ typedef struct uint8_t m17_enc; //enc type uint8_t m17_enc_st; //scrambler or data subtye + //misc str storage + char str50a[50]; + char str50b[50]; + //Codec2 #ifdef USE_CODEC2 struct CODEC2 *codec2_3200; //M17 fullrate diff --git a/patch/nxdn_alias_to_groupname.patch b/patch/nxdn_alias_to_groupname.patch deleted file mode 100644 index e3fcc6c..0000000 --- a/patch/nxdn_alias_to_groupname.patch +++ /dev/null @@ -1,116 +0,0 @@ -diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c -index 501124e..e2939e4 100644 ---- a/src/dsd_ncurses.c -+++ b/src/dsd_ncurses.c -@@ -2754,6 +2754,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) - printw ("| "); - printw ("TGT: [%5d] ", tgn); - printw ("SRC: [%5d] ", src); -+ -+ #ifdef LIMAZULUTWEAKS - if (state->nxdn_alias_block_segment[0][0] > 0) - { - printw ("ALIAS: ["); -@@ -2764,23 +2766,30 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) - printw ("%s", state->nxdn_alias_block_segment[i][j]); - } - } -- printw ("]"); -+ printw ("] "); - } -+ #endif - - //Group Name Labels from CSV import - for (int k = 0; k < state->group_tally; k++) - { - if (state->group_array[k].groupNumber == tgn) - { -+ printw ("TG: "); - attron(COLOR_PAIR(4)); -- printw (" [%s]", state->group_array[k].groupName); -+ printw ("[%s]", state->group_array[k].groupName); - printw ("[%s] ", state->group_array[k].groupMode); - } - else if (state->group_array[k].groupNumber == src) - { -+ #ifdef LIMAZULUTWEAKS -+ ; //skip Alias Line -+ #else -+ printw ("ALIAS: "); -+ #endif - attron(COLOR_PAIR(4)); -- printw (" [%s]", state->group_array[k].groupName); -- printw ("[%s] ", state->group_array[k].groupMode); -+ printw ("%s", state->group_array[k].groupName); -+ // printw ("[%s] ", state->group_array[k].groupMode); - } - if (state->carrier == 1) - { -diff --git a/src/nxdn_element.c b/src/nxdn_element.c -index 8907cab..c8c9b30 100644 ---- a/src/nxdn_element.c -+++ b/src/nxdn_element.c -@@ -732,6 +732,63 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message) - - if (Alias4 > 0x19 && Alias4 < 0x7F) sprintf (state->nxdn_alias_block_segment[blocknumber-1][3], "%c", Alias4); - //else sprintf (state->nxdn_alias_block_segment[blocknumber-1][3], "%c", 0); //space -+ -+ //TEST: Assign to call history (if not already in groupName) -+ char str_a[120]; char str_b[50]; int wr = 0; int tsrc = state->nxdn_last_rid; int z = 0; -+ sprintf (str_a, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", -+ state->nxdn_alias_block_segment[0][0], state->nxdn_alias_block_segment[0][1], state->nxdn_alias_block_segment[0][2], state->nxdn_alias_block_segment[0][3], -+ state->nxdn_alias_block_segment[1][0], state->nxdn_alias_block_segment[1][1], state->nxdn_alias_block_segment[1][2], state->nxdn_alias_block_segment[1][3], -+ state->nxdn_alias_block_segment[2][0], state->nxdn_alias_block_segment[2][1], state->nxdn_alias_block_segment[2][2], state->nxdn_alias_block_segment[2][3], -+ state->nxdn_alias_block_segment[3][0], state->nxdn_alias_block_segment[3][1], state->nxdn_alias_block_segment[3][2], state->nxdn_alias_block_segment[3][3]); -+ -+ #ifdef LIMAZULUTWEAKS //disable saving the alias to call history/groupName and potentially overwriting any imported src names in the array -+ UNUSED(z); UNUSED(tsrc); UNUSED(wr); UNUSED(str_b); UNUSED(str_a); -+ #else -+ -+ //juggle strings here so we don't get compiler warnings on assignment size -+ memcpy (str_b, str_a, 48); str_b[49] = '\0'; -+ -+ if (tsrc != 0) -+ { -+ for (int x = 0; x < state->group_tally; x++) -+ { -+ if (state->group_array[x].groupNumber == tsrc) -+ { -+ wr = 1; //already in there, so no need to assign it -+ z = x; -+ break; -+ } -+ } -+ -+ //NOTE: Assigning D or DE here could still clash with ENC LO and also normal A/B/D/DE from group import -+ //among other issues, so, will need to evaluate and tweak, or stash in the eternal stash of ideas to revisit -+ -+ //if not already in there, so save it there now (find clever way to use this and also ENC LO) -+ if (wr == 0) -+ { -+ state->group_array[state->group_tally].groupNumber = tsrc; -+ if (state->nxdn_cipher_type != 0 && opts->trunk_tune_enc_calls == 0 && state->R == 0) -+ sprintf (state->group_array[state->group_tally].groupMode, "%s", "DE"); -+ else -+ sprintf (state->group_array[state->group_tally].groupMode, "%s", "D"); //could still override a blocked TG, or vice versa -+ sprintf (state->group_array[state->group_tally].groupName, "%s", str_b); -+ state->group_tally++; -+ } -+ -+ //if its in there, but doesn't match (bad/partial decode) -- the mode checks are to help limit overwriting imported src names as long as they don't use the D or DE values -+ else if ( (strcmp(str_b, state->group_array[z].groupName) != 0) && (strcmp("B", state->group_array[z].groupMode) != 0) && (strcmp("A", state->group_array[z].groupMode) != 0) ) -+ { -+ state->group_array[z].groupNumber = tsrc; -+ if (state->nxdn_cipher_type != 0 && opts->trunk_tune_enc_calls == 0 && state->R == 0) -+ sprintf (state->group_array[z].groupMode, "%s", "DE"); //having this here will allow a later lockout to occur if required -+ else -+ sprintf (state->group_array[z].groupMode, "%s", "D"); -+ sprintf (state->group_array[z].groupName, "%s", str_b); -+ } -+ } -+ -+ #endif -+ - } - - //crc errs in one repitition may occlude an otherwise good alias, so test and change if needed diff --git a/src/dsd_main.c b/src/dsd_main.c index 979f5b9..fa40667 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -501,6 +501,10 @@ if(opts->frame_m17 == 1) //&& opts->audio_in_type == 5 state->m17_enc_st = 0; memset(state->m17_meta, 0, sizeof(state->m17_meta)); + //misc str storage + sprintf (state->str50a, "%s", ""); + sprintf (state->str50b, "%s", ""); + //set float temp buffer to baseline memset (state->audio_out_temp_buf, 0.0f, sizeof(state->audio_out_temp_buf)); memset (state->audio_out_temp_bufR, 0.0f, sizeof(state->audio_out_temp_bufR)); diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 304dfc2..7202b33 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -25,7 +25,7 @@ uint32_t temp_freq = -1; //struct for checking existence of directory to write to struct stat st_wav = {0}; - +static char alias_ch[10][50]; int reset = 0; char * timestr; int tg; @@ -415,6 +415,10 @@ void ncursesOpen (dsd_opts * opts, dsd_state * state) //this is primarily used to push a quick audio blip through OSS so it will show up in the mixer immediately // if (opts->audio_out_type == 2 || opts->audio_out_type == 5) // beeper (opts, state, 0); //causes crash in Cygwin when mixed input/output + + //terminate all values + for (int i = 0; i < 10; i++) + sprintf (alias_ch[i], "%s", ""); UNUSED(opts); UNUSED(state); @@ -1654,7 +1658,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) } if (choice == 15) //reset call history (usually if janky output when switching modes) { - for (short int k = 0; k <= 9; k++) + for (short int k = 0; k < 10; k++) { call_matrix[k][0] = 0; call_matrix[k][1] = 0; @@ -1662,6 +1666,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) call_matrix[k][3] = 0; call_matrix[k][4] = 0; call_matrix[k][5] = 0; + sprintf (alias_ch[k], "%s", ""); } src = 0; rn = 0; @@ -1675,6 +1680,11 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) state->lastsrcR = 0; state->lasttg = 0; state->lasttgR = 0; + state->nxdn_last_ran = -1; + state->nxdn_last_rid = 0; + state->nxdn_last_tg = 0; + sprintf (state->str50a, "%s", ""); + sprintf (state->str50b, "%s", ""); } if (choice == 16) //toggle payload printing @@ -1904,7 +1914,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } //NXDN -- I really need to fix this better, but this is good enough for today - if (state->nxdn_last_rid != 0 && state->nxdn_last_rid != src) + if (state->nxdn_last_rid != src) { src = state->nxdn_last_rid; } @@ -2038,6 +2048,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) call_matrix[k][3] = call_matrix[k+1][3]; call_matrix[k][4] = call_matrix[k+1][4]; call_matrix[k][5] = call_matrix[k+1][5]; + sprintf (alias_ch[k], "%s", alias_ch[k+1]); } call_matrix[9][0] = lls; call_matrix[9][1] = tgn; //was rn, switch to tgn so it'll show tg in call history @@ -2045,6 +2056,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) call_matrix[9][3] = 0; call_matrix[9][4] = rn; //was tgn, switched with rn call_matrix[9][5] = time(NULL); + sprintf (alias_ch[9], "%s", ""); + sprintf (state->str50a, "%s", ""); //open wav file if enabled and both rd and tg are not 0 if (opts->dmr_stereo_wav == 1 && src != 0 ) //&& tgn != 0, some TG can be 0 on NXDN @@ -2061,6 +2074,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } } + + //TODO: Find better placement for these + if ( strcmp(state->str50a, "") != 0 ) + sprintf (alias_ch[9], "%s", state->str50a); + + //tdma only + // if ( strcmp(state->str50b, "") != 0 ) + // sprintf (alias_ch[5], "%s", state->str50a); //DMR MS if ( call_matrix[9][2] != rd && lls == 32) @@ -2757,24 +2778,15 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw ("| "); printw ("TGT: [%5d] ", tgn); printw ("SRC: [%5d] ", src); - if (state->nxdn_alias_block_segment[0][0] > 0) - { - printw ("ALIAS: ["); - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) - { - printw ("%s", state->nxdn_alias_block_segment[i][j]); - } - } - printw ("]"); - } + // if (state->nxdn_alias_block_segment[0][0] > 0) //consider disabling this + printw ("Alias: [%s]", alias_ch[9]); //Group Name Labels from CSV import for (int k = 0; k < state->group_tally; k++) { if (state->group_array[k].groupNumber == tgn) { + printw ("TG: "); attron(COLOR_PAIR(4)); printw (" [%s]", state->group_array[k].groupName); printw ("[%s] ", state->group_array[k].groupMode); @@ -2783,7 +2795,6 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) { attron(COLOR_PAIR(4)); printw (" [%s]", state->group_array[k].groupName); - printw ("[%s] ", state->group_array[k].groupMode); } if (state->carrier == 1) { @@ -3553,6 +3564,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw ("[%s] ", state->group_array[k].groupMode); } } + + //alias values here + printw ("%s", alias_ch[9-j]); + // #endif printw ("\n"); } diff --git a/src/nxdn_element.c b/src/nxdn_element.c index 8907cab..4d771b2 100644 --- a/src/nxdn_element.c +++ b/src/nxdn_element.c @@ -691,11 +691,14 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message) { UNUSED(opts); - uint8_t Alias1 = 0x20; //value of an ascii 'space' character + uint8_t Alias1 = 0x20; uint8_t Alias2 = 0x20; uint8_t Alias3 = 0x20; uint8_t Alias4 = 0x20; uint8_t blocknumber = 0; + uint8_t total = 0; + uint8_t unk1 = 0; + uint8_t unk2 = 0; uint8_t CrcCorrect = 0; //alias can also hit on a facch1 -- do we still need this checkdown? @@ -708,12 +711,23 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message) //FACCH Payload [3F][68][82][04][2 <- block number4] "[69][6F][6E][20]" <- 4 alias octets [00][7F][1C] blocknumber = (uint8_t)ConvertBitIntoBytes(&Message[32], 4) & 0x7; // & 0x7, might just be three bits, unsure + total = (uint8_t)ConvertBitIntoBytes(&Message[36], 4) & 0x7; //second value seems to be total number of blocks? or len of alias in this segment? + unk1 = (uint8_t)ConvertBitIntoBytes(&Message[8], 8); //unknown values in first two bytes after the opcode + unk2 = (uint8_t)ConvertBitIntoBytes(&Message[16], 8); //could be related to the format of these (Iso8? etc) + UNUSED4(unk1, unk2, total, blocknumber); Alias1 = (uint8_t)ConvertBitIntoBytes(&Message[40], 8); Alias2 = (uint8_t)ConvertBitIntoBytes(&Message[48], 8); Alias3 = (uint8_t)ConvertBitIntoBytes(&Message[56], 8); Alias4 = (uint8_t)ConvertBitIntoBytes(&Message[64], 8); + + char str_a[120]; char str_b[50]; + + //debug/test + // fprintf (stderr, " U1: %02X U2: %02X;", unk1, unk2); + // fprintf (stderr, " A:%d/%d; ", blocknumber, total); + //sanity check to prevent OOB array assignment - if (blocknumber > 0 && blocknumber < 4) //last 'block' may have been assigning garbage name values -- needs testing + if (blocknumber > 0 && blocknumber < 4) //last 'block' may have been assigning garbage name values -- I'm honestly not sure block'4' contains Alias data, but other data or something { //assign to index -1, since block number conveyed here is 1,2,3,4, and index values are 0,1,2,3 //only assign if within valid range of ascii characters (not including diacritical extended alphabet) @@ -722,16 +736,33 @@ void NXDN_decode_Alias(dsd_opts * opts, dsd_state * state, uint8_t * Message) //since we are zeroing out the blocks on tx_rel and other conditions, better to just set nothing to bad Alias bytes //tends to zero out otherwise already good blocks set in a previous repitition. if (Alias1 > 0x19 && Alias1 < 0x7F) sprintf (state->nxdn_alias_block_segment[blocknumber-1][0], "%c", Alias1); - //else sprintf (state->nxdn_alias_block_segment[blocknumber-1][0], "%c", 32); //space + // else sprintf (state->nxdn_alias_block_segment[blocknumber-1][0], "%c", 0x20); //space if (Alias2 > 0x19 && Alias2 < 0x7F) sprintf (state->nxdn_alias_block_segment[blocknumber-1][1], "%c", Alias2); - //else sprintf (state->nxdn_alias_block_segment[blocknumber-1][1], "%c", 0); //space + // else sprintf (state->nxdn_alias_block_segment[blocknumber-1][1], "%c", 0x20); //space if (Alias3 > 0x19 && Alias3 < 0x7F) sprintf (state->nxdn_alias_block_segment[blocknumber-1][2], "%c", Alias3); - //else sprintf (state->nxdn_alias_block_segment[blocknumber-1][2], "%c", 0); //space + // else sprintf (state->nxdn_alias_block_segment[blocknumber-1][2], "%c", 0x20); //space if (Alias4 > 0x19 && Alias4 < 0x7F) sprintf (state->nxdn_alias_block_segment[blocknumber-1][3], "%c", Alias4); - //else sprintf (state->nxdn_alias_block_segment[blocknumber-1][3], "%c", 0); //space + // else sprintf (state->nxdn_alias_block_segment[blocknumber-1][3], "%c", 0x20); //space + + sprintf (str_a, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + state->nxdn_alias_block_segment[0][0], state->nxdn_alias_block_segment[0][1], state->nxdn_alias_block_segment[0][2], state->nxdn_alias_block_segment[0][3], + state->nxdn_alias_block_segment[1][0], state->nxdn_alias_block_segment[1][1], state->nxdn_alias_block_segment[1][2], state->nxdn_alias_block_segment[1][3], + state->nxdn_alias_block_segment[2][0], state->nxdn_alias_block_segment[2][1], state->nxdn_alias_block_segment[2][2], state->nxdn_alias_block_segment[2][3], + state->nxdn_alias_block_segment[3][0], state->nxdn_alias_block_segment[3][1], state->nxdn_alias_block_segment[3][2], state->nxdn_alias_block_segment[3][3]); + + //juggle strings here so we don't get compiler warnings on assignment size + memcpy (str_b, str_a, 48); str_b[49] = '\0'; + + //one noteable issue is that on conventional, its possible to decode an alias before decong the src id + //just depends on reception and if VCALL is decoded before Alias, this will lead to alias being assigned + //to incorrect src values or placement in the ncurses terminal's call history section + + if (state->nxdn_last_rid != 0) + sprintf (state->str50a, "%s", str_b); + } //crc errs in one repitition may occlude an otherwise good alias, so test and change if needed