Event History Setup: #287;

Misc Tweaks Regarding How Trunking Elements May Indirectly Interact with Event History;

DMR Alias Tweak: Allow Extra UTF8 characters (grave, diacritical leters, etc); Allow any UTF16 character that isn't an ASCII special char;

Add GI String (GROUP or PRIVATE) to wav file names, if set and known at close;

Add Encrypted PDU ALG/KID values if not decrypted/decoded;

Allow Manual RTL Input PPM Error Adjustment with { and } keys;

LRRP: Simple Request Handling; Report Handling Tweaks; Simple Handling for Unknown Formats;

Don't reset DMR Color Code on NoCarrier;
This commit is contained in:
lwvmobile
2025-05-03 15:59:45 -04:00
parent 93b297c2d5
commit d376fcc227
8 changed files with 129 additions and 31 deletions

View File

@@ -1078,21 +1078,21 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
}
}
//reset alg/keyid/mi
if (state->currentslot == 0)
{
state->payload_mi = 0;
state->payload_algid = 0;
state->payload_keyid = 0;
state->dmr_so = 0;
}
else
{
state->payload_miR = 0;
state->payload_algidR = 0;
state->payload_keyidR = 0;
state->dmr_soR = 0;
}
//reset alg/keyid/mi //TD_LC should "SHOULD" catch this
// if (state->currentslot == 0)
// {
// state->payload_mi = 0;
// state->payload_algid = 0;
// state->payload_keyid = 0;
// state->dmr_so = 0;
// }
// else
// {
// state->payload_miR = 0;
// state->payload_algidR = 0;
// state->payload_keyidR = 0;
// state->dmr_soR = 0;
// }
} //end enc check
#endif
@@ -1105,8 +1105,19 @@ void dmr_block_assembler (dsd_opts * opts, dsd_state * state, uint8_t block_byte
fprintf (stderr, "\n Slot %d - Encrypted PDU;", slot+1);
fprintf (stderr, "%s", KNRM);
uint8_t alg = 0;
uint8_t kid = 0;
if (slot == 0)
alg = state->payload_algid;
else alg = state->payload_algidR;
if (slot == 0)
kid = state->payload_keyid;
else kid = state->payload_keyidR;
char enc_str[200]; memset (enc_str, 200, sizeof(enc_str));
sprintf (enc_str, "DATA TGT: %lld; SRC: %lld; Encrypted PDU;", state->dmr_lrrp_source[slot], state->dmr_lrrp_target[slot]);
sprintf (enc_str, "DATA TGT: %lld; SRC: %lld; ENC PDU; ALG: %02X; KID: %02X;", state->dmr_lrrp_source[slot], state->dmr_lrrp_target[slot], alg, kid);
sprintf (state->dmr_lrrp_gps[slot], "%s", enc_str);
watchdog_event_datacall (opts, state, state->dmr_lrrp_source[slot], state->dmr_lrrp_target[slot], enc_str, slot);
}
else if (CRCCorrect || opts->aggressive_framesync == 0)

View File

@@ -522,6 +522,9 @@ void dmr_lrrp (dsd_opts * opts, dsd_state * state, uint16_t len, uint32_t source
uint16_t message_len = 0;
uint8_t slot = state->currentslot;
uint8_t lrrp_confidence = 0; //variable to increment based on number of tokens found, the more, the higher the confidence level
uint8_t lrrp_type = DMR_PDU[0];
uint8_t is_request = 0;
uint8_t is_response = 0;
//source/dest and ports (this is grabbed in the IP decoding phase)
if (source != 0) lrrp_confidence++;
@@ -569,12 +572,29 @@ void dmr_lrrp (dsd_opts * opts, dsd_state * state, uint16_t len, uint32_t source
{
uint8_t token = DMR_PDU[i];
switch(token){
case 0x0D: //message len indicator
case 0x0F: //Triggered Location Stop Request
case 0x05: //Immediate Location Request
case 0x09: //Triggered Location Start Request
case 0x14: //Protocol Version Request
if (i == 0) //see if this is the first octet, otherwise, can't verify this is going to work
{
message_len = DMR_PDU[i+1];
i = len; //go to end
lrrp_confidence++;
is_request = 1;
}
break;
case 0x07: //Immediate Location Response
case 0x0B: //Triggered Location Start Response
case 0x0D: //Triggered Location
case 0x11: //Triggered Location Stop Response
case 0x15: //Protocol Version Response
if (i == 0) //see if this is the first octet, otherwise, can't verify this is going to work
{
message_len = DMR_PDU[i+1];
i += 3; //next byte is len, then next two are usually 0x22 0xXX or 0x23 0xXX
lrrp_confidence++;
is_response = 1;
}
break;
@@ -781,15 +801,38 @@ void dmr_lrrp (dsd_opts * opts, dsd_state * state, uint16_t len, uint32_t source
sprintf (velstr, "%s", "");
sprintf (degstr, "%s", "");
if (lat) sprintf (lrrpstr, "LRRP SRC: %0d; (%lf, %lf)", source, lat_fin, lon_fin);
else sprintf (lrrpstr, "LRRP SRC: %0d; Unknown Format; ", source);
else if (is_request) sprintf (lrrpstr, "LRRP SRC: %0d; Request from TGT: %d;", source, dest);
else if (is_response) sprintf (lrrpstr, "LRRP SRC: %0d; Response to TGT: %d;", source, dest);
else sprintf (lrrpstr, "LRRP SRC: %0d; Unknown Format %02X; TGT: %d;; ", lrrp_type, source, dest);
if (vel_set) sprintf (velstr, " %.4lf km/h", velocity * 3.6);
if (deg_set) sprintf (degstr, " %d%s ", degrees, deg_glyph);
sprintf (state->dmr_lrrp_gps[slot], "%s%s%s", lrrpstr, velstr, degstr);
if (!lat)
fprintf (stderr, "\n %s", state->dmr_lrrp_gps[slot]);
}
else
{
char lrrpstr[100];
sprintf (lrrpstr, "%s", "");
sprintf (lrrpstr, "LRRP SRC: %0d; Unknown Format %02X; TGT: %d;", lrrp_type, source, dest);
sprintf (state->dmr_lrrp_gps[slot], "%s", lrrpstr);
fprintf (stderr, "\n %s", state->dmr_lrrp_gps[slot]);
}
}
else
{
char lrrpstr[100];
sprintf (lrrpstr, "%s", "");
sprintf (lrrpstr, "LRRP SRC: %0d; Unknown Format %02X; TGT: %d;", lrrp_type, source, dest);
sprintf (state->dmr_lrrp_gps[slot], "%s", lrrpstr);
fprintf (stderr, "\n %s", state->dmr_lrrp_gps[slot]);
}
fprintf (stderr, "%s", KNRM);
}

View File

@@ -765,7 +765,8 @@ void dmr_talker_alias_lc_decode (dsd_opts * opts, dsd_state * state, uint8_t slo
{
uint8_t character = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*8)], 8);
char ch[2]; ch[0] = character; ch[1] = 0;
if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set
// if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set
if (character >= 0x20 && character != 0x7F) //allow some extended UTF discritical characters as well
{
fprintf (stderr, "%c", character);
strcat (alias_string, ch);
@@ -783,7 +784,8 @@ void dmr_talker_alias_lc_decode (dsd_opts * opts, dsd_state * state, uint8_t slo
{
uint16_t character = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*16)], 16);
char ch[2]; ch[0] = character & 0xFF; ch[1] = 0;
if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set //may see what happens if this is disabled
// if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set //may see what happens if this is disabled
if (character >= 0x20 && character != 0x7F) //will want to next, but should be okay (unless RAS or CRC Bypass)
{
fprintf (stderr, "%lc", character);
strcat (alias_string, ch);

View File

@@ -494,15 +494,21 @@ SNDFILE * close_and_rename_wav_file(SNDFILE * wav_file, char * wav_out_filename,
uint32_t source_id = event_struct->Event_History_Items[0].source_id;
uint32_t target_id = event_struct->Event_History_Items[0].target_id;
int8_t gi = event_struct->Event_History_Items[0].gi;
char sys_str[200]; memset (sys_str, 0, sizeof(sys_str));
char src_str[200]; memset (src_str, 0, sizeof(src_str));
char tgt_str[200]; memset (tgt_str, 0, sizeof(tgt_str));
char gi_str[10]; memset (gi_str, 0, sizeof(gi_str));
sprintf (sys_str, "%s", event_struct->Event_History_Items[0].sysid_string);
sprintf (src_str, "%s", event_struct->Event_History_Items[0].src_str);
sprintf (tgt_str, "%s", event_struct->Event_History_Items[0].tgt_str);
sprintf (gi_str, "%s", "");
if (gi == 0) sprintf (gi_str, "%s", "GROUP");
else if (gi == 1) sprintf (gi_str, "%s", "PRIVATE");
uint8_t is_string = 0;
char emp_str[200]; memset (emp_str, 0, sizeof(emp_str));
sprintf (emp_str, "%s", "BUMBLEBEETUNA");
@@ -515,9 +521,9 @@ SNDFILE * close_and_rename_wav_file(SNDFILE * wav_file, char * wav_out_filename,
//check for String based TGT and SRC values (M17, YSF, DSTAR)
if (is_string == 1)
sprintf (new_filename, "%s/%s_%s_%05d_%s_TGT_%s_SRC_%s.wav", dir, datestr, timestr, random_number, sys_str, tgt_str, src_str);
sprintf (new_filename, "%s/%s_%s_%05d_%s_%s_TGT_%s_SRC_%s.wav", dir, datestr, timestr, random_number, sys_str, gi_str, tgt_str, src_str);
else //is a numerical value
sprintf (new_filename, "%s/%s_%s_%05d_%s_TGT_%d_SRC_%d.wav", dir, datestr, timestr, random_number, sys_str, target_id, source_id);
sprintf (new_filename, "%s/%s_%s_%05d_%s_%s_TGT_%d_SRC_%d.wav", dir, datestr, timestr, random_number, sys_str, gi_str, target_id, source_id);
if (timestr != NULL)
{

View File

@@ -270,7 +270,7 @@
state->dmr_rest_channel = -1;
//DMR Color Code
state->dmr_color_code = 16;
// state->dmr_color_code = 16; //disabled
//zero out nxdn site/srv/cch info if not trunking
state->nxdn_location_site_code = 0;

View File

@@ -2147,7 +2147,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
else
printw (" G: %idB;", opts->rtl_gain_value);
printw (" V: %iX;", opts->rtl_volume_multiplier);
printw (" PPM: %i;", opts->rtlsdr_ppm_error);
printw (" PPM: %i;", opts->rtlsdr_ppm_error); //Adjust manually now with { and }
printw (" SQ: %i;", opts->rtl_squelch_level);
printw (" RMS: %04li;", opts->rtl_rms);
printw (" BW: %i;", opts->rtl_bandwidth);
@@ -3783,7 +3783,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (c == 82) //'R', save symbol capture bin with date/time string as name
{
sprintf (opts->symbol_out_file, "%s %s.bin", datestr, timestr);
sprintf (opts->symbol_out_file, "%s_%s_dibit_capture.bin", datestr, timestr);
openSymbolOutFile (opts, state);
}
@@ -4360,6 +4360,13 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
//RTL PPM Manual Adjustment
if (c == 125)
opts->rtlsdr_ppm_error++;
if (c == 123)
opts->rtlsdr_ppm_error--;
//anything with an entry box will need the inputs and outputs stopped first
//so probably just write a function to handle c input, and when c = certain values
//needing an entry box, then stop all of those

View File

@@ -139,9 +139,10 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
break;
//VCALL, TX_REL_EXT and TX_REL
case 0x01:
case 0x07:
case 0x08:
case 0x07: //TX_REL_EXT
case 0x08: //TX_REL
sprintf (state->call_string[0], "%s", "");
case 0x01: //VCALL
NXDN_decode_VCALL(opts, state, ElementsContent);
break;
@@ -149,6 +150,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
case 0x11:
NXDN_decode_VCALL(opts, state, ElementsContent);
memset (state->nxdn_alias_block_segment, 0, sizeof(state->nxdn_alias_block_segment));
sprintf (state->call_string[0], "%s", "");
// #ifdef LIMAZULUTWEAKS
// ; //do nothing -- testing errors on CAC messages when returning quickly from RTCH
@@ -647,6 +649,16 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
state->nxdn_last_tg = DestinationID;
sprintf (state->nxdn_call_type, "%s", NXDN_Call_Type_To_Str(CallType));
if (CallType == 3)
{
state->gi[0] = 1; //Private Call
//unassign these, sometimes, when trunking, these may be reversed by the time listened,
//and this will plant an extra private call in the event_history
state->nxdn_last_rid = 0;
state->nxdn_last_tg = 0;
}
else state->gi[0] = 0; //Group Call
//Call String for Per Call WAV File
sprintf (state->call_string[0], "%s", NXDN_Call_Type_To_Str(CallType));
if (CCOption & 0x80) strcat (state->call_string[0], " Emergency");
@@ -685,6 +697,16 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
state->nxdn_last_tg = DestinationID;
sprintf (state->nxdn_call_type, "%s", NXDN_Call_Type_To_Str(CallType));
if (CallType == 3)
{
state->gi[0] = 1; //Private Call
//unassign these, sometimes, when trunking, these may be reversed by the time listened,
//and this will plant an extra private call in the event_history
state->nxdn_last_rid = 0;
state->nxdn_last_tg = 0;
}
else state->gi[0] = 0; //Group Call
//Call String for Per Call WAV File
sprintf (state->call_string[0], "%s", NXDN_Call_Type_To_Str(CallType));
if (CCOption & 0x80) strcat (state->call_string[0], " Emergency");

View File

@@ -712,8 +712,8 @@ int verbose_gain_set(rtlsdr_dev_t *dev, int gain)
int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error)
{
int r;
if (ppm_error == 0) {
return 0;}
// if (ppm_error == 0) {
// return 0;}
r = rtlsdr_set_freq_correction(dev, ppm_error);
if (r < 0) {
fprintf (stderr, "WARNING: Failed to set ppm error.\n");
@@ -1142,7 +1142,14 @@ void cleanup_rtlsdr_stream()
//find way to modify this function to allow hopping (tuning) while squelched and send 0 sample?
int get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state)
{
UNUSED2(opts, state);
UNUSED(state);
//if PPM Error is Manually Changed, Change it here now
if (opts->rtlsdr_ppm_error != dongle.ppm_error)
{
dongle.ppm_error = opts->rtlsdr_ppm_error;
verbose_ppm_set(dongle.dev, dongle.ppm_error);
}
while (output.queue.empty())
{