mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 09:17:20 -05:00
P25 PDU Tweaks;
This commit is contained in:
@@ -18,7 +18,7 @@ typedef std::vector<bool> bit_vector;
|
||||
/* deinterleave and trellis1_2 decoding, count_bits, and find_min*/
|
||||
/* buf is assumed to be a buffer of 12 bytes */
|
||||
|
||||
typedef std::vector<bool> bit_vector;
|
||||
//typedef std::vector<bool> bit_vector;
|
||||
|
||||
//ugly copy and paste below
|
||||
static int count_bits(unsigned int n) {
|
||||
|
||||
@@ -79,8 +79,22 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
||||
//fprintf (stderr, "BAD CRC16");
|
||||
}
|
||||
|
||||
//shuffle corrected bits back into tsbk_byte
|
||||
k = 0;
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
int byte = 0;
|
||||
for (x = 0; x < 8; x++)
|
||||
{
|
||||
byte = byte << 1;
|
||||
byte = byte | tsbk_decoded_bits[k];
|
||||
k++;
|
||||
}
|
||||
tsbk_byte[i] = byte;
|
||||
}
|
||||
|
||||
//convert tsbk_byte to PDU and send to vPDU handler...may or may not be entirely compatible,
|
||||
PDU[0] = 07; //P25p1 TSBK Duid 0x07
|
||||
PDU[0] = 0x07; //P25p1 TSBK Duid 0x07
|
||||
PDU[1] = tsbk_byte[0];
|
||||
PDU[2] = tsbk_byte[2];
|
||||
PDU[3] = tsbk_byte[3];
|
||||
@@ -96,7 +110,7 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
||||
PDU[1] = PDU[1] ^ 0x40; //flip bit to make it compatible with MAC_PDUs, i.e. 3D to 7D
|
||||
|
||||
//Don't run NET_STS out of this, or will set wrong NAC/CC
|
||||
if (err == 0 && ec == 0 && PDU[1] != 0x7B && PDU[1] != 0xFB)
|
||||
if (err == 0 && ec == 0 && PDU[1] != 0x7B && PDU[1] != 0xFB && PDU[1] != 0x49 && PDU[1] != 0x45) //0x49 is telephone grant, 0x46 Unit to Unit Channel Answer Request
|
||||
{
|
||||
fprintf (stderr, "%s",KMAG);
|
||||
process_MAC_VPDU(opts, state, 0, PDU);
|
||||
@@ -122,7 +136,6 @@ void processTSBK(dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
fprintf (stderr, "%s",KCYN);
|
||||
fprintf (stderr, "\n P25 PDU Payload ");
|
||||
fprintf (stderr, " BD = %d CRC = %d \n ", ec, err);
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
fprintf (stderr, "[%02X]", tsbk_byte[i]);
|
||||
|
||||
@@ -132,7 +132,36 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||
//Synchronization Broadcast (SYNC_BCST)
|
||||
if (MAC[1+len_a] == 0x70)
|
||||
{
|
||||
fprintf (stderr, "\n Synchronization Broadcast (SYNC_BCST)");
|
||||
fprintf (stderr, "\n Synchronization Broadcast \n");
|
||||
int ist = (MAC[3+len_a] >> 2) & 0x1; //IST bit tells us if time is realiable, synced to external source
|
||||
int ltoff = (MAC[4+len_a] & 0x3F);
|
||||
int year = MAC[5+len_a] >> 1;
|
||||
int month = ((MAC[5+len_a] & 0x1) << 3) | (MAC[6+len_a] >> 5);
|
||||
int day = (MAC[6+len_a] & 0x1F);
|
||||
int hour = MAC[7+len_a] >> 3;
|
||||
int min = ((MAC[7+len_a] & 0x7) << 3) | (MAC[8+len_a] >> 5);
|
||||
int slots = ((MAC[8+len_a] & 0x1F) << 8) | MAC[9+len_a];
|
||||
int sign = (ltoff & 0b100000) >> 5;
|
||||
float offhour = 0;
|
||||
//calculate local time (on system) by looking at offset and subtracting 30 minutes increments, or divide by 2 for hourly
|
||||
if (sign == 1)
|
||||
{
|
||||
offhour = -( (ltoff & 0b11111 ) / 2);
|
||||
}
|
||||
else offhour = ( (ltoff & 0b11111 ) / 2);
|
||||
|
||||
int seconds = slots / 135; //very rough estimation, but may be close enough for grins
|
||||
if (seconds > 60) seconds = 60; //sanity check for rounding error
|
||||
fprintf (stderr, " Date: 20%02d.%02d.%02d Time: %02d:%02d:%02d UTC\n",
|
||||
year, month, day, hour, min, seconds);
|
||||
fprintf (stderr, " Local Time Offset: %.01f Hours;", offhour);
|
||||
//if ist bit is set, then time on system may be considered invalid (i.e., no external time sync)
|
||||
if (ist == 1)
|
||||
{
|
||||
fprintf (stderr, " Invalid System Time ");
|
||||
}
|
||||
else fprintf (stderr, " Valid System Time ");
|
||||
|
||||
}
|
||||
|
||||
//identifier update VHF/UHF
|
||||
|
||||
Reference in New Issue
Block a user