Call History Fix & Timestamp; Cap+ VLC Fix;

This commit is contained in:
lwvmobile 2022-11-01 03:54:10 -04:00
parent b4a0e2e9f3
commit 7ca65cf687
3 changed files with 83 additions and 109 deletions

View File

@ -1757,32 +1757,6 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t
sprintf(state->dmr_branding, " Hytera XPT "); sprintf(state->dmr_branding, " Hytera XPT ");
} }
//Testing CSBK Voice Call on Tait //CSBK Protect RID ILLEGALLY_PARKED
// if ((IrrecoverableErrors == 0) && CRCCorrect)
// {
// if (DmrDataByte[0] == 0xAF)
// {
// if (state->currentslot == 0)
// {
// state->lastsrc = (DmrDataByte[4] << 16) | (DmrDataByte[5] << 8) | (DmrDataByte[6] << 0);
// state->lasttg = (DmrDataByte[7] << 16) | (DmrDataByte[8] << 8) | (DmrDataByte[9] << 0);
// fprintf (stderr, "%s", KGRN);
// fprintf (stderr, "\n SLOT %d ", state->currentslot+1);
// fprintf(stderr, "TGT=%u SRC=%u ", state->lasttg, state->lastsrc);
// fprintf(stderr, " CSBK Voice LC??");
// }
// if (state->currentslot == 1)
// {
// state->lastsrcR = (DmrDataByte[4] << 16) | (DmrDataByte[5] << 8) | (DmrDataByte[6] << 0);
// state->lasttgR = (DmrDataByte[7] << 16) | (DmrDataByte[8] << 8) | (DmrDataByte[9] << 0);
// fprintf (stderr, "%s", KGRN);
// fprintf (stderr, "\n SLOT %d ", state->currentslot+1);
// fprintf(stderr, "TGT=%u SRC=%u ", state->lasttgR, state->lastsrcR);
// fprintf(stderr, " CSBK Voice LC??");
// }
// }
// }
//Full //Full
if (opts->payload == 1) if (opts->payload == 1)
{ {
@ -2049,9 +2023,12 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
/* Store the Source address */ /* Store the Source address */
TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[48], 24); TSVoiceSupFrame->FullLC.SourceAddress = (unsigned int)ConvertBitIntoBytes(&DmrDataBit[48], 24);
//truncate if Byte 0 isn't 0, 0x04 (or other) may signify a Cap+ System
if (DmrDataByte != 0x0) int rest_channel = -1; //set rest_channel to -1; if set to other value, then we know we have a Cap+?
//Below "Should" be a MotoTRBO Cap+ system
if (TSVoiceSupFrame->FullLC.FullLinkControlOpcode & 0x4 && TSVoiceSupFrame->FullLC.FeatureSetID == 0x10)
{ {
rest_channel = (TSVoiceSupFrame->FullLC.SourceAddress >> 16); //8 bits for Rest Channel
TSVoiceSupFrame->FullLC.SourceAddress = TSVoiceSupFrame->FullLC.SourceAddress & 0xFFFF; TSVoiceSupFrame->FullLC.SourceAddress = TSVoiceSupFrame->FullLC.SourceAddress & 0xFFFF;
} }
@ -2144,38 +2121,13 @@ void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[19
else if(IrrecoverableErrors == 0) {}//fprintf(stderr, "RAS (FEC OK/CRC ERR)"); else if(IrrecoverableErrors == 0) {}//fprintf(stderr, "RAS (FEC OK/CRC ERR)");
else {}//fprintf(stderr, "(FEC FAIL/CRC ERR)"); else {}//fprintf(stderr, "(FEC FAIL/CRC ERR)");
#ifdef PRINT_VOICE_LC_HEADER_BYTES //check Cap+ rest channel info if available
fprintf(stderr, "\n"); if (rest_channel != -1)
fprintf(stderr, "VOICE LC HEADER : ");
for(i = 0; i < 12; i++)
{ {
fprintf(stderr, "0x%02X", DmrDataByte[i]); //fprintf (stderr, "Cap+ R-Ch=%d", rest_channel);
if(i != 11) fprintf(stderr, " - ");
} }
fprintf(stderr, "\n"); //Full
fprintf(stderr, "BPTC(196,96) Reserved bit R(0)-R(2) = 0x%02X\n", BPTCReservedBits);
fprintf(stderr, "CRC extracted = 0x%04X - CRC computed = 0x%04X - ", CRCExtracted, CRCComputed);
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf(stderr, "CRCs are equal + FEC OK !\n");
}
else if(IrrecoverableErrors == 0)
{
else fprintf(stderr, "FEC correctly corrected but CRCs are incorrect\n");
}
else
{
fprintf(stderr, "ERROR !!! CRCs are different and FEC Failed !\n");
}
fprintf(stderr, "Hamming Irrecoverable Errors = %u\n", IrrecoverableErrors);
#endif /* PRINT_VOICE_LC_HEADER_BYTES */
//Full
if (opts->payload == 1) if (opts->payload == 1)
{ {
fprintf (stderr, "%s", KCYN); fprintf (stderr, "%s", KCYN);

View File

@ -434,7 +434,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
} }
} }
//if using anything but DMR Stereo, borrowing state->dmr_encL to signal enc or clear for other types //X2-TDMA? Not sure what still makes it this far to run under Framef
if (opts->dmr_stereo == 0) if (opts->dmr_stereo == 0)
{ {
mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);

View File

@ -65,41 +65,21 @@ int i = 0;
char versionstr[25]; char versionstr[25];
unsigned long long int call_matrix[33][6]; unsigned long long int call_matrix[33][6];
/*
___)__|_
.-*' '*-,
/ /| |\ \
; /_| |_\ ;
; |\ /| ;
; | ''--...--'' | ;
\ ''---.....--'' /
''*-.,_______,.-*' BOO!
*/
// char * FM_bannerN[9] = {
// " ESC or Arrow Keys For Menu ",
// " ██████╗ ██████╗██████╗  ███████╗███╗ ███╗███████╗ ",
// " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝ ",
// " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",
// " ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ",
// " ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗ ",
// " ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ",
// " ",
// " "
// };
char * FM_bannerN[9] = { char * FM_bannerN[9] = {
" ESC or Arrow Keys For Menu Happy Halloween! ___)__|_ ", " ESC or Arrow Keys For Menu ",
" ██████╗ ██████╗██████╗  ███████╗███╗ ███╗███████╗ .-*' '*-, ", " ██████╗ ██████╗██████╗  ███████╗███╗ ███╗███████╗ ",
" ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝; /_| |_\\ ;", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝ ",
" ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ; |\\ /| ;", " ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",
" ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ; | ''--...--'' | ; ", " ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ",
" ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗ \\ ''---.....--'' / ", " ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗ ",
" ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ''*-.,_______,.-*' ", " ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ",
" Happy Halloween ", " ",
" " " "
}; };
char * SyncTypes[44] = { char * SyncTypes[44] = {
"P25P1", "P25P1",
"P25P1", "P25P1",
@ -111,10 +91,10 @@ char * SyncTypes[44] = {
"DSTAR", "DSTAR",
"NXDN VOICE", "NXDN VOICE",
"NXDN VOICE", "NXDN VOICE",
"DMR DATA", //10 "DMR ", //10
"DMR DATA", "DMR ",
"DMR VOICE", "DMR ",
"DMR VOICE", "DMR ",
"PROVOICE", "PROVOICE",
"PROVOICE", "PROVOICE",
"NXDN VOICE", //DATA "NXDN VOICE", //DATA
@ -146,7 +126,7 @@ char * SyncTypes[44] = {
char * DMRBusrtTypes[32] = { char * DMRBusrtTypes[32] = {
"PI Header ", "PI Header ",
"VOICE LC HDR ", "VOICE LC ",
"TLC ", "TLC ",
"CSBK ", "CSBK ",
"MBC Header ", "MBC Header ",
@ -155,7 +135,7 @@ char * DMRBusrtTypes[32] = {
"RATE 1/2 DATA ", "RATE 1/2 DATA ",
"RATE 3/4 DATA ", "RATE 3/4 DATA ",
"Slot Idle ", "Slot Idle ",
"Rate 1 DATA ", "RATE 1 DATA ",
"ERR ", //These values for ERR may be Reserved for use in future? "ERR ", //These values for ERR may be Reserved for use in future?
"DUID ERR ", "DUID ERR ",
"R-S ERR ", "R-S ERR ",
@ -180,6 +160,11 @@ char * DMRBusrtTypes[32] = {
}; };
//there is still a bug in beeper, but the bug isn't related to call history,
//if it were, per call wav would also be affected.
//seems to do with playing a wav file,
//debug shows it should trigger even when you don't hear it
//no beep or double beep still happens randomly but debug shows only one played!?
void beeper (dsd_opts * opts, dsd_state * state, int type) void beeper (dsd_opts * opts, dsd_state * state, int type)
{ {
FILE *beep; FILE *beep;
@ -199,7 +184,8 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
if (stat(wav_name, &stat_buf) == 0) if (stat(wav_name, &stat_buf) == 0)
{ {
beep = fopen (wav_name, "ro"); beep = fopen (wav_name, "ro");
uint8_t buf[1024] = {0}; uint8_t buf[1024];
memset (buf, 0, sizeof(buf));
short blip = 0; short blip = 0;
int loop = 1; int loop = 1;
while (loop == 1) while (loop == 1)
@ -215,14 +201,17 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
if (type == 0 && opts->dmr_stereo == 1 && opts->audio_out == 1) if (type == 0 && opts->dmr_stereo == 1 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
//fprintf (stderr, "BEEP 0 24\n");
} }
if (type == 1 && opts->dmr_stereo == 1 && opts->audio_out == 1) if (type == 1 && opts->dmr_stereo == 1 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL);
//fprintf (stderr, "BEEP 1 24\n");
} }
if (opts->dmr_stereo == 0 && opts->audio_out == 1) if (opts->dmr_stereo == 0 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
//fprintf (stderr, "BEEP 0 8\n");
} }
@ -263,6 +252,30 @@ char * getTimeN(void) //get pretty hh:mm:ss timestamp
return curr; return curr;
} }
char * getDateC(time_t t) {
char datename[99]; //Ubuntu 32-bit, use 80; everything else, use 99
char * curr2;
struct tm * to;
to = localtime( & t);
strftime(datename, sizeof(datename), "%Y-%m-%d", to);
curr2 = strtok(datename, " ");
return curr2;
}
char * getTimeC(time_t t) //get pretty hh:mm:ss timestamp
{
char * curr;
char * stamp = asctime(localtime( & t));
curr = strtok(stamp, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
return curr;
}
//testing a few things, going to put this into ncursesMenu //testing a few things, going to put this into ncursesMenu
#define WIDTH 36 #define WIDTH 36
#define HEIGHT 23 #define HEIGHT 23
@ -1637,15 +1650,17 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
} }
//DMR SRC //DMR SRC
// if ( (lls == 12 || lls == 13 || lls == 10 || lls == 11 || lls == 32) ) if ( (lls == 12 || lls == 13 || lls == 10 || lls == 11 || lls == 32) )
if ( (lls == 12 || lls == 11 || lls == 32) ) //if ( (lls == 12 || lls == 11 || lls == 32) )
{ {
if (state->dmrburstL == 16 && state->lastsrc > 0) //state->currentslot == 0 && //if (state->dmrburstL == 16 && state->lastsrc > 0) //state->currentslot == 0 &&
if (state->lastsrc > 0)
{ {
rd = state->lastsrc; rd = state->lastsrc;
} }
if (state->dmrburstR == 16 && state->lastsrcR > 0) //state->currentslot == 1 && //if (state->dmrburstR == 16 && state->lastsrcR > 0) //state->currentslot == 1 &&
if (state->lastsrcR > 0)
{ {
rdR = state->lastsrcR; rdR = state->lastsrcR;
} }
@ -1653,14 +1668,17 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
} }
//DMR TG //DMR TG
if ( (lls == 12 || lls == 11 || lls == 32) ) if ( (lls == 12 || lls == 13 || lls == 10 || lls == 11 || lls == 32) )
//if ( (lls == 12 || lls == 11 || lls == 32) )
{ {
if (state->dmrburstL == 16 && state->lasttg > 0) //state->currentslot == 0 && //if (state->dmrburstL == 16 && state->lasttg > 0) //state->currentslot == 0 &&
if (state->lasttg > 0)
{ {
tg = state->lasttg; tg = state->lasttg;
} }
if (state->dmrburstR == 16 && state->lasttgR > 0) //state->currentslot == 1 && //if (state->dmrburstR == 16 && state->lasttgR > 0) //state->currentslot == 1 &&
if (state->lasttgR > 0)
{ {
tgR = state->lasttgR; tgR = state->lasttgR;
@ -1808,13 +1826,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->call_alert == 1) if (opts->call_alert == 1)
{ {
//fprintf (stderr, "BEEP 0 MS LEFT\n");
beeper (opts, state, 0); beeper (opts, state, 0);
} }
} }
//DMR BS Slot 1 - matrix 0-4 //DMR BS Slot 1 - matrix 0-4
if ( call_matrix[4][2] != rd && (lls == 11 || lls == 12 || 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++) for (short int k = 0; k < 4; k++)
@ -1846,13 +1865,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->call_alert == 1) if (opts->call_alert == 1)
{ {
//fprintf (stderr, "BEEP 0 BS LEFT\n");
beeper (opts, state, 0); beeper (opts, state, 0);
} }
} }
//DMR BS Slot 2 - matrix 5-9 //DMR BS Slot 2 - matrix 5-9
if ( call_matrix[9][2] != rdR && (lls == 11 || lls == 12 || lls == 35 || lls == 36) ) if ( call_matrix[9][2] != rdR && (lls == 11 || lls == 12 || lls == 10 || lls == 13 || lls == 35 || lls == 36) )
{ {
for (short int k = 5; k < 9; k++) for (short int k = 5; k < 9; k++)
@ -1883,6 +1903,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->call_alert == 1) if (opts->call_alert == 1)
{ {
//fprintf (stderr, "BEEP 1 BS RIGHT\n");
beeper (opts, state, 1); beeper (opts, state, 1);
} }
@ -1933,14 +1954,13 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
} }
if (opts->ncurses_compact == 0) if (opts->ncurses_compact == 0)
{ {
attron(COLOR_PAIR(1)); //6 attron(COLOR_PAIR(6)); //6
for (short int i = 0; i < 7; i++) for (short int i = 0; i < 7; i++)
{ {
printw("%s \n", FM_bannerN[i]); printw("%s \n", FM_bannerN[i]);
} }
printw (" https://github.com/lwvmobile/dsd-fme/tree/pulseaudio\n"); printw (" https://github.com/lwvmobile/dsd-fme/tree/pulseaudio\n");
//printw (" Github Build Version: %s \n", GIT_TAG); printw (" Github Build Version: %s \n", GIT_TAG);
printw (" Github Build Version: %s \n", "1313"); //probably better than the first number I thought of
attroff(COLOR_PAIR(6)); //6 attroff(COLOR_PAIR(6)); //6
// printw ("--Build Info------------------------------------------------------------------\n"); // printw ("--Build Info------------------------------------------------------------------\n");
// printw ("| https://github.com/lwvmobile/dsd-fme/tree/pulseaudio\n"); //http link // printw ("| https://github.com/lwvmobile/dsd-fme/tree/pulseaudio\n"); //http link
@ -2577,7 +2597,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw ("SRC [%8lld] ", call_matrix[9-j][2]); printw ("SRC [%8lld] ", call_matrix[9-j][2]);
printw ("DCC [%02lld] ", call_matrix[9-j][4]); printw ("DCC [%02lld] ", call_matrix[9-j][4]);
} }
printw ("%lld secs ago\n", time(NULL) - call_matrix[9-j][5]);
printw ("%s ", getDateC(call_matrix[9-j][5]) ); //You're welcome
printw ("%s \n", getTimeC(call_matrix[9-j][5]) ); //Roman
} }
} //end Call History } //end Call History
//fence bottom //fence bottom