diff --git a/src/dmr_block.c b/src/dmr_block.c index 6b41f9a..cbd4d7c 100644 --- a/src/dmr_block.c +++ b/src/dmr_block.c @@ -632,9 +632,11 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (udt_uab == 2) end = 25; if (udt_uab == 3) end = 38; if (udt_uab == 4) end = 52; - end -= udt_padnib/7; //is this correct? + end -= udt_padnib/2; fprintf (stderr, "ISO7 Text: " ); - strcat (udt_string, "ISO7 Text: "); + strcat (udt_string, "ISO7 Text; "); + // fprintf (stderr, " pad: %d; end: %d;", udt_padnib, end); //debug + sprintf (state->event_history_s[slot].Event_History_Items[0].text_message, "%s", " "); for (i = 0; i < end; i++) //max 368/7 = 52 character max? { iso7c = (uint8_t)ConvertBitIntoBytes(&cs_bits[(i*7)+96], 7); @@ -642,7 +644,7 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (iso7c >= 0x20 && iso7c <= 0x7E) //Standard ASCII Set { fprintf (stderr, "%c", iso7c); - strcat (udt_string, i7c); + strcat (state->event_history_s[slot].Event_History_Items[0].text_message, i7c); } else fprintf (stderr, " "); } @@ -650,12 +652,14 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, else if (udt_format2 == 0x04) //ISO8 format { fprintf (stderr, "ISO8 Text: " ); - strcat (udt_string, "ISO8 Text: "); + strcat (udt_string, "ISO8 Text; "); + sprintf (state->event_history_s[slot].Event_History_Items[0].text_message, "%s", " "); if (udt_uab == 1) end = 10; if (udt_uab == 2) end = 22; if (udt_uab == 3) end = 34; if (udt_uab == 4) end = 46; - end -= udt_padnib/8; //is this correct? + end -= udt_padnib/2; + // fprintf (stderr, " pad: %d; end: %d;", udt_padnib, end); //debug for (i = 0; i < end; i++) { iso8c = (uint8_t)ConvertBitIntoBytes(&cs_bits[(i*8)+96], 8); @@ -663,7 +667,7 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (iso8c >= 0x20 && iso8c <= 0x7E) //Standard ASCII Set { fprintf (stderr, "%c", iso8c); - strcat (udt_string, i8c); + strcat (state->event_history_s[slot].Event_History_Items[0].text_message, i8c); } // else if (iso8c >= 0x81 && iso8c <= 0xFE) //Extended ASCII Set @@ -677,9 +681,11 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (udt_uab == 2) end = 11; if (udt_uab == 3) end = 17; if (udt_uab == 4) end = 23; - end -= udt_padnib/4; //example, 4 blocks sets 23 - (20nibs/4bits) = 18 chars, may need to check this again + end -= udt_padnib/2; fprintf (stderr, "UTF16 Text: " ); - strcat (udt_string, "UTF16 Text: "); + // fprintf (stderr, " pad: %d; end: %d;", udt_padnib, end); //debug + strcat (udt_string, "UTF16 Text; "); + sprintf (state->event_history_s[slot].Event_History_Items[0].text_message, "%s", " "); for (i = 0; i < end; i++) //368/16 = 23 character max? { utf16c = (uint16_t)ConvertBitIntoBytes(&cs_bits[(i*16)+96], 16); @@ -687,7 +693,9 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (utf16c >= 0x20 && utf16c != 0x7F) //avoid control chars { fprintf (stderr, "%lc", utf16c); //will using lc work here? May depend on console locale settings? - strcat (udt_string, u16); + // strcat (udt_string, u16); + if (utf16c >= 0x20 && utf16c < 0x7F) + strcat (state->event_history_s[slot].Event_History_Items[0].text_message, u16); } else fprintf (stderr, " "); @@ -711,10 +719,10 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+16], 16)); fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+32], 16)); fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+48], 16)); - fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+56], 16)); - fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+72], 16)); - fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+88], 16)); - fprintf (stderr, "%04X", (uint16_t)ConvertBitIntoBytes(&cs_bits[96+104], 16)); + fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+64], 16)); + fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+80], 16)); + fprintf (stderr, "%04X:",(uint16_t)ConvertBitIntoBytes(&cs_bits[96+96], 16)); + fprintf (stderr, "%04X", (uint16_t)ConvertBitIntoBytes(&cs_bits[96+112], 16)); strcat (udt_string, "IP6; "); } } @@ -724,10 +732,11 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (udt_uab == 2) end = 9; if (udt_uab == 3) end = 15; if (udt_uab == 4) end = 21; - end -= udt_padnib/4; //is this correct? - fprintf (stderr, "Address: %d", (uint32_t)ConvertBitIntoBytes(&cs_bits[96+8], 24)); - fprintf (stderr, "Text: " ); - strcat (udt_string, "UTF16 Text: "); + end -= udt_padnib/2; + fprintf (stderr, "Address: %d; ", (uint32_t)ConvertBitIntoBytes(&cs_bits[96+8], 24)); + fprintf (stderr, "UTF16 Text: " ); + strcat (udt_string, "UTF16 Text; "); + sprintf (state->event_history_s[slot].Event_History_Items[0].text_message, "%s", " "); for (i = 0; i < end; i++) //368/16 = 21 character max { utf16c = (uint16_t)ConvertBitIntoBytes(&cs_bits[(i*16)+96], 16); @@ -735,7 +744,9 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, if (utf16c >= 0x20 && utf16c != 0x7F) //avoid control chars { fprintf (stderr, "%lc", utf16c); - strcat (udt_string, u16); + // strcat (udt_string, u16); + if (utf16c >= 0x20 && utf16c < 0x7F) + strcat (state->event_history_s[slot].Event_History_Items[0].text_message, u16); } else fprintf (stderr, " "); @@ -782,7 +793,29 @@ void dmr_udt_decoder (dsd_opts * opts, dsd_state * state, uint8_t * block_bytes, } fprintf (stderr, "%s", KNRM); + if (slot == 0) + { + state->lastsrc = udt_source; + state->lasttg = udt_target; + } + else + { + state->lastsrcR = udt_source; + state->lasttgR = udt_target; + } watchdog_event_datacall (opts, state, udt_source, udt_target, udt_string, slot); + if (slot == 0) + { + state->lastsrc = 0; + state->lasttg = 0; + } + else + { + state->lastsrcR = 0; + state->lasttgR = 0; + } + watchdog_event_history(opts, state, slot); + watchdog_event_current(opts, state, slot); } //assemble the blocks as they come in, shuffle them into the unified dmr_pdu_sf diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index 9be7fa5..e62eb41 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -977,9 +977,17 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 UNUSED(svc_flag); UNUSED(als_flag); + char ahoy_str[200]; memset(ahoy_str, 0, sizeof(ahoy_str)); + sprintf (ahoy_str, "AHOY TGT: %d; SRC: %d; ", ahoy_target, ahoy_source); + if (ahoy_gi == 0) fprintf (stderr, "Private "); else fprintf (stderr, "Group "); + if (ahoy_gi == 0) + strcat (ahoy_str, "Private; "); + else strcat (ahoy_str, "Group; "); + state->gi[state->currentslot] = ahoy_gi ^ 1; + //need to put SVC OPT decoding in here, maybe just copy and paste from FLC? fprintf (stderr, "FID: %02X SVC: %02X ", csbk_fid, svc_opt); @@ -999,9 +1007,47 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 fprintf (stderr, "Target: %d; Source: %d; ", ahoy_target, ahoy_source); + if (svc_kind == 0 || svc_kind == 1) strcat (ahoy_str, "Voice Call; "); + else if (svc_kind == 2 || svc_kind == 3) strcat (ahoy_str, "Packet Data Call; "); + else if (svc_kind == 4 || svc_kind == 5) strcat (ahoy_str, "UDT Short Data Call; "); + else if (svc_kind == 6) strcat (ahoy_str, "UDT Short Data Polling Service; "); + else if (svc_kind == 7) strcat (ahoy_str, "Status Transport Service; "); + else if (svc_kind == 8) strcat (ahoy_str, "Call Diversion Service; "); + else if (svc_kind == 9) strcat (ahoy_str, "Call Answer Service; "); + else if (svc_kind == 10) strcat (ahoy_str, "Full Duplex Voice Call; "); + else if (svc_kind == 11) strcat (ahoy_str, "Full Duplex Packet Data Call; "); + else if (svc_kind == 12) strcat (ahoy_str, "Reserved; "); + else if (svc_kind == 13) strcat (ahoy_str, "Supplimentary Service (Stun/Revive/Kill/Auth); "); + else if (svc_kind == 14) strcat (ahoy_str, "Registration/Authentication; "); + else if (svc_kind == 15) strcat (ahoy_str, "Cancel Call Service; "); + //check the source and/or target for special gateway identifiers dmr_gateway_identifier (ahoy_source, ahoy_target); + if (state->currentslot == 0) + { + state->lastsrc = ahoy_source; + state->lasttg = ahoy_target; + } + else + { + state->lastsrcR = ahoy_source; + state->lasttgR = ahoy_target; + } + watchdog_event_datacall (opts, state, ahoy_source, ahoy_target, ahoy_str, state->currentslot); + if (state->currentslot == 0) + { + state->lastsrc = 0; + state->lasttg = 0; + } + else + { + state->lastsrcR = 0; + state->lasttgR = 0; + } + watchdog_event_history(opts, state, 0); + watchdog_event_current(opts, state, 0); + } if (csbk_o == 42) diff --git a/src/dsd_gps.c b/src/dsd_gps.c index 6e72f6d..b047d3b 100644 --- a/src/dsd_gps.c +++ b/src/dsd_gps.c @@ -194,9 +194,9 @@ void nmea_iec_61162_1 (dsd_opts * opts, dsd_state * state, uint8_t * input, uint uint8_t nmea_utc_hh = (uint8_t)ConvertBitIntoBytes(&input[66], 5); uint8_t nmea_utc_mm = (uint8_t)ConvertBitIntoBytes(&input[71], 6); //seconds and the addition of COG is the difference between short and long formats - uint8_t nmea_utc_ss3 = (uint8_t)ConvertBitIntoBytes(&input[77], 3); //seconds in 10s - uint8_t nmea_utc_ss6 = (uint8_t)ConvertBitIntoBytes(&input[77], 6); //seconds in 1s - uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[103], 9); //course over ground in degrees + uint8_t nmea_utc_ss3 = (uint8_t)ConvertBitIntoBytes(&input[77], 3) * 10; //seconds in 10s + uint8_t nmea_utc_ss6 = (uint8_t)ConvertBitIntoBytes(&input[77], 6); //seconds in 1s + uint16_t nmea_cog = (uint16_t)ConvertBitIntoBytes(&input[103], 9); //course over ground in degrees //lat and lon conversion char deg_glyph[4]; diff --git a/src/p25_lcw.c b/src/p25_lcw.c index f605901..1ddea2f 100644 --- a/src/p25_lcw.c +++ b/src/p25_lcw.c @@ -68,8 +68,10 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir state->dmr_so = lc_svcopt; //test to make sure no random issues //don't set this when zero, annoying blink occurs in ncurses - if (group != 0) state->lasttg = group; - if (source != 0) state->lastsrc = source; + if (group != 0) + state->lasttg = group; + // if (source != 0) //disable now with new event history, if same src next ptt, then it will capture all of them as individual event items + state->lastsrc = source; sprintf (state->call_string[0], " Group "); if (lc_svcopt & 0x80) strcat (state->call_string[0], " Emergency "); @@ -85,9 +87,11 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir fprintf (stderr, " - Target %d Source %d", target, source); //don't set this when zero, annoying blink occurs in ncurses - if (target != 0) state->lasttg = target; - if (source != 0) state->lastsrc = source; - state->gi[0] = 0; + if (target != 0) + state->lasttg = target; + // if (source != 0) //disable now with new event history, if same src next ptt, then it will capture all of them as individual event items + state->lastsrc = source; + state->gi[0] = 1; state->dmr_so = lc_svcopt; sprintf (state->call_string[0], " Private "); @@ -331,6 +335,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir { state->lasttg = 0; state->lastsrc = 0; + state->gi[0] = -1; state->payload_algid = 0; state->payload_keyid = 0; // state->payload_miP = 0; @@ -350,6 +355,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir #ifdef USE_RTLSDR state->lasttg = 0; state->lastsrc = 0; + state->gi[0] = -1; state->payload_algid = 0; state->payload_keyid = 0; // state->payload_miP = 0; diff --git a/src/p25p1_tdu.c b/src/p25p1_tdu.c index fbc4825..5a68715 100644 --- a/src/p25p1_tdu.c +++ b/src/p25p1_tdu.c @@ -48,4 +48,8 @@ processTDU (dsd_opts* opts, dsd_state* state) state->payload_algid = 0; state->payload_keyid = 0; + state->lasttg = 0; + state->lastsrc = 0; + state->gi[0] = -1; + }