More work with decoding and regenerating P25.

This commit is contained in:
Jonathan Naylor
2016-09-13 18:27:50 +01:00
parent 30467a749c
commit 0dc1f1bdad
22 changed files with 442 additions and 156 deletions

View File

@@ -18,15 +18,11 @@
#include "P25NID.h"
#include "P25Defines.h"
#include "P25Utils.h"
#include <cstdio>
#include <cassert>
const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };
#define WRITE_BIT(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
#define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CP25NID::CP25NID() :
m_duid(0U),
m_nac(0U)
@@ -43,14 +39,7 @@ void CP25NID::process(unsigned char* data)
unsigned char nid[P25_NID_LENGTH_BYTES];
unsigned int n = 0U;
for (unsigned int offset = 48U; offset < 114U; offset++) {
if (offset != P25_SS0_START && offset != P25_SS1_START) {
bool b = READ_BIT(data, offset);
WRITE_BIT(nid, n, b);
n++;
}
}
CP25Utils::decode(data, nid, 48U, 114U);
// XXX Process FEC here
@@ -59,14 +48,7 @@ void CP25NID::process(unsigned char* data)
m_nac = (nid[0U] << 4) & 0xFF0U;
m_nac |= (nid[1U] >> 4) & 0x00FU;
n = 0U;
for (unsigned int offset = 48U; offset < 114U; offset++) {
if (offset != P25_SS0_START && offset != P25_SS1_START) {
bool b = READ_BIT(nid, n);
WRITE_BIT(data, offset, b);
n++;
}
}
CP25Utils::encode(nid, data, 48U, 114U);
}
unsigned char CP25NID::getDUID() const