Handle the P25 low speed data.

This commit is contained in:
Jonathan Naylor
2016-09-20 06:53:30 +01:00
parent c8cb7a5429
commit 34bf8f18a7
8 changed files with 105 additions and 32 deletions

View File

@@ -88,31 +88,31 @@ bool CP25NID::decode(const unsigned char* data)
unsigned char nid[P25_NID_LENGTH_BYTES];
CP25Utils::decode(data, nid, 48U, 114U);
unsigned int errs = compare(nid, m_ldu1);
unsigned int errs = CP25Utils::compare(nid, m_ldu1, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_LDU1;
return true;
}
errs = compare(nid, m_ldu2);
errs = CP25Utils::compare(nid, m_ldu2, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_LDU2;
return true;
}
errs = compare(nid, m_term);
errs = CP25Utils::compare(nid, m_term, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_TERM;
return true;
}
errs = compare(nid, m_termlc);
errs = CP25Utils::compare(nid, m_termlc, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_TERM_LC;
return true;
}
errs = compare(nid, m_hdr);
errs = CP25Utils::compare(nid, m_hdr, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_HEADER;
return true;
@@ -150,20 +150,3 @@ unsigned char CP25NID::getDUID() const
{
return m_duid;
}
unsigned int CP25NID::compare(const unsigned char* nid1, const unsigned char* nid2) const
{
assert(nid1 != NULL);
assert(nid2 != NULL);
unsigned int errs = 0U;
for (unsigned int i = 0U; i < P25_NID_LENGTH_BYTES; i++) {
unsigned char v = nid1[i] ^ nid2[i];
while (v != 0U) {
v &= v - 1U;
errs++;
}
}
return errs;
}