mirror of https://github.com/lwvmobile/dsd-fme.git
Merge branch 'p25_moto_alias_setup' into aw_dev
This commit is contained in:
commit
61673222db
|
|
@ -1256,6 +1256,9 @@ void dmr_gateway_identifier (uint32_t source, uint32_t target); //translate spec
|
|||
//Embedded Alias and GPS reports
|
||||
void dmr_embedded_alias_header (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]);
|
||||
void dmr_embedded_alias_blocks (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]);
|
||||
void apx_embedded_alias_test (dsd_opts * opts, dsd_state * state);
|
||||
void apx_embedded_alias_header (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t lc_bits[]);
|
||||
void apx_embedded_alias_blocks (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t lc_bits[]);
|
||||
void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]);
|
||||
void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]);
|
||||
void lip_protocol_decoder (dsd_opts * opts, dsd_state * state, uint8_t * input);
|
||||
|
|
|
|||
177
src/dsd_gps.c
177
src/dsd_gps.c
|
|
@ -763,4 +763,181 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
|||
}
|
||||
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
}
|
||||
|
||||
uint8_t alias_scramble[256] = {
|
||||
0xA8, 0xDF, 0x9E, 0x04, 0xF5, 0xF9, 0xEE, 0x1B, 0xAC, 0x3E, 0xE2, 0xAD, 0x71, 0xFC, 0x38, 0x03,
|
||||
0x59, 0xCE, 0xED, 0x82, 0xE1, 0xBD, 0x28, 0x86, 0x39, 0x78, 0x1C, 0xB7, 0xBA, 0xA3, 0x41, 0xD0,
|
||||
0x6D, 0x1F, 0x2F, 0xBB, 0x3D, 0x02, 0x3A, 0x20, 0x5F, 0x42, 0xC7, 0xA2, 0x70, 0x6E, 0x21, 0x7E,
|
||||
0x22, 0x90, 0xDB, 0xC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x5A, 0x3F, 0x50, 0xF1, 0x4B, 0xCD, 0x00, 0x95, 0xE7, 0x96, 0x9A, 0xA0, 0x0E, 0xC5, 0xBE
|
||||
};
|
||||
|
||||
//relocate this later on
|
||||
void apx_embedded_alias_test (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
uint64_t temp_a = 0x15900FE9060100B0; uint64_t temp_b = 0x5A; //72 bits, so break into segments
|
||||
uint8_t lcw[72]; memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179001BBEE001C70; temp_b = 0x13;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179002B9CB7D5F2D; temp_b = 0x48;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179003B23695F7ED; temp_b = 0x49;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179004B9EA998F87; temp_b = 0x48;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179005BE6DAB167F; temp_b = 0xAC;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
|
||||
temp_a = 0x179006B15EC2C622; temp_b = 0x2E;
|
||||
memset (lcw, 0, sizeof(lcw));
|
||||
for (uint64_t i = 0; i < 64; i++)
|
||||
lcw[i] = (temp_a >> (63-i)) & 1;
|
||||
for (uint64_t i = 0; i < 8; i++)
|
||||
lcw[i+64] = (temp_b >> (7-i)) & 1;
|
||||
p25_lcw(opts, state, lcw, 0);
|
||||
}
|
||||
|
||||
void apx_embedded_alias_header (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t lc_bits[])
|
||||
{
|
||||
UNUSED(opts);
|
||||
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&lc_bits[32], 8); //len in blocks of associated talker alias
|
||||
fprintf (stderr, " Block Len: %d;", ta_len);
|
||||
|
||||
//use dmr_pdu_sf for storage, store entire header (will be used to verify complete reception of full alias)
|
||||
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot])); //reset storage for header and blocks
|
||||
memcpy(state->dmr_pdu_sf[slot], lc_bits, 72*sizeof(uint8_t));
|
||||
|
||||
}
|
||||
|
||||
void apx_embedded_alias_blocks (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t lc_bits[])
|
||||
{
|
||||
UNUSED(opts);
|
||||
uint8_t bn = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 8); //current block number
|
||||
uint8_t sn = (uint8_t)ConvertBitIntoBytes(&lc_bits[24], 4); //is a static value on all block sequences
|
||||
uint8_t ta_len = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][32], 8); //len in blocks pulled from stored header
|
||||
uint16_t header = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0], 16); //header check, should be 0x1590
|
||||
if (ta_len == 0 || header != 0x1590) //checkdown, make sure we have an up to date header for this with a good len value
|
||||
{
|
||||
fprintf (stderr, " Missing Header");
|
||||
fprintf (stderr, " BN: %d/??;", bn);
|
||||
fprintf (stderr, " SN: %X;", sn);
|
||||
fprintf (stderr, " Partial: ");
|
||||
for (uint8_t i = 7; i < 18; i++)
|
||||
fprintf (stderr, "%0X", (uint8_t)ConvertBitIntoBytes(&lc_bits[0+(i*4)], 4));
|
||||
|
||||
//clear out now stale storage
|
||||
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot]));
|
||||
}
|
||||
|
||||
else //good len and header stored
|
||||
{
|
||||
|
||||
//sanity check, bn cannot equal zero (this shouldn't happen, but bad decode could occur)
|
||||
if (bn == 0) bn = 1;
|
||||
|
||||
fprintf (stderr, " SN: %X;", sn);
|
||||
fprintf (stderr, " BN: %d/%d;", bn, ta_len);
|
||||
|
||||
//use dmr_pdu_sf for storage, store data relevant portion at ptr of (bn-1) * 44 + 72 offset for header
|
||||
memcpy(state->dmr_pdu_sf[slot]+(((bn-1)*44)+72), lc_bits+28, 44*sizeof(uint8_t));
|
||||
|
||||
if (ta_len == bn) //this is the last block, proceed to decoding
|
||||
{
|
||||
|
||||
//debug, let's look at byte, bit counts and see if we can find this in the completed dump
|
||||
// fprintf (stderr, " Bits: %X; Bytes: %X; Mod: %d; ", bn*44, (bn*44)/8, (bn*44)%8); //the portion with 0100 is 8 off from 0108 (hex) bits
|
||||
|
||||
//debug, dump completed data set
|
||||
// fprintf (stderr, "\n Full: ");
|
||||
// for (uint8_t i = 0; i < ((bn*11)+18); i++) //double check on other bn values
|
||||
// fprintf (stderr, "%X", (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0+(i*4)], 4));
|
||||
// fprintf (stderr, "\n");
|
||||
|
||||
//extract fully qualified SUID
|
||||
uint32_t wacn = (uint32_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][72], 20);
|
||||
uint32_t sys = (uint32_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][92], 12);
|
||||
uint32_t rid = (uint32_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][104], 24);
|
||||
|
||||
//print fully qualified SUID
|
||||
fprintf (stderr, "\n WACN: %05X; SYS: %03X; RID: %d;", wacn, sys, rid);
|
||||
|
||||
//extract CRC
|
||||
uint16_t crc_ext = (uint16_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(72+(bn*44)-16)], 16);
|
||||
|
||||
//compute CRC
|
||||
uint16_t crc_cmp = ComputeCrcCCITT16d(&state->dmr_pdu_sf[slot][72], (bn*44)-16);
|
||||
|
||||
//print comparison
|
||||
fprintf (stderr, " CRC EXT: %04X CMP: %04X;", crc_ext, crc_cmp);
|
||||
if (crc_ext != crc_cmp)
|
||||
fprintf (stderr, " Error;");
|
||||
else fprintf (stderr, " Okay;");
|
||||
|
||||
//debug, dump just the encoded alias portion
|
||||
fprintf (stderr, "\n Encoded: ");
|
||||
for (int16_t i = 32; i < ((bn*11)+18-4); i++) //double check on other bn values
|
||||
{
|
||||
// if ((i != 32) && ((i % 2) == 0))
|
||||
// fprintf (stderr, " ");
|
||||
fprintf (stderr, "%X", (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][0+(i*4)], 4));
|
||||
}
|
||||
|
||||
//start decoding the alias
|
||||
if (crc_ext == crc_cmp)
|
||||
{
|
||||
//TODO: Figure this out
|
||||
// int16_t ptr = 128; //starting point of encoded data from test vectors
|
||||
}
|
||||
|
||||
//clear out now stale storage
|
||||
memset (state->dmr_pdu_sf[slot], 0, sizeof (state->dmr_pdu_sf[slot]));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1534,11 +1534,8 @@ if (opts->audio_out_type == 0)
|
|||
openPulseOutput(opts);
|
||||
}
|
||||
|
||||
// #ifdef AERO_BUILD //NOTE: Blame seems to be synctest8 not being initialized (will continue to test)
|
||||
// //TODO: More Random Cygwin Related M17 Bugs to sort out
|
||||
// if(opts->frame_m17 == 1)
|
||||
// for (int i = 0; i < 960; i++) getSymbol(opts, state, 1); //I think this is actually just framesync being a pain
|
||||
// #endif
|
||||
//test P25 moto alias by loading in test vectors captured from a system and dumped on forum (see dsd_gps.c)
|
||||
// apx_embedded_alias_test(opts, state); //enable this to run test
|
||||
|
||||
while (!exitflag)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir
|
|||
{
|
||||
uint32_t tgt = (uint32_t)ConvertBitIntoBytes(&LCW_bits[48], 24); //can be individual, or all units (0xFFFFFF)
|
||||
fprintf (stderr, " Call Termination; TGT: %d;", tgt);
|
||||
memset (state->dmr_pdu_sf[0], 0, sizeof (state->dmr_pdu_sf[0])); //reset storage for any talker alias (or other items)
|
||||
if (opts->p25_trunk == 1 && state->p25_cc_freq != 0 && opts->p25_is_tuned == 1)
|
||||
{
|
||||
|
||||
|
|
@ -455,6 +456,19 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir
|
|||
fprintf (stderr, " MFID90 (Moto) Talker EOT; SRC: %d;", src);
|
||||
}
|
||||
|
||||
//look for these in logs
|
||||
else if (lc_mfid == 0x90 && lc_opcode == 0x15)
|
||||
{
|
||||
fprintf (stderr, " MFID90 (Moto) Talker Alias Header");
|
||||
apx_embedded_alias_header (opts, state, 0, LCW_bits);
|
||||
}
|
||||
|
||||
else if (lc_mfid == 0x90 && lc_opcode == 0x17)
|
||||
{
|
||||
fprintf (stderr, " MFID90 (Moto) Talker Alias Block");
|
||||
apx_embedded_alias_blocks (opts, state, 0, LCW_bits);
|
||||
}
|
||||
|
||||
//observed format value on Harris SNDCP data channel (Phase 2 CC to Phase 1 MPDU channel)
|
||||
else if (lc_mfid == 0xA4 && lc_format == 0x0A)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue