Skip to content

Commit

Permalink
Add beginnings of P25 data handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 3, 2018
1 parent 8423f3f commit 97e51ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion P25Control.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -150,6 +150,9 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
case P25_DUID_LDU1:
duid = P25_DUID_LDU2;
break;
case P25_DUID_PDU:
duid = P25_DUID_PDU;
break;
default:
break;
}
Expand Down Expand Up @@ -358,6 +361,9 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
writeQueueRF(data, P25_TERM_FRAME_LENGTH_BYTES + 2U);
}
}
} else if (duid == P25_DUID_PDU) {
LogMessage("P25, PDU received");
CUtils::dump("P25, PDU data", data + 2U, P25_LDU_FRAME_LENGTH_BYTES);
}

return false;
Expand Down
22 changes: 20 additions & 2 deletions P25NID.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -32,7 +32,8 @@ m_hdr(NULL),
m_ldu1(NULL),
m_ldu2(NULL),
m_termlc(NULL),
m_term(NULL)
m_term(NULL),
m_pdu(NULL)
{
CBCH bch;

Expand Down Expand Up @@ -70,6 +71,13 @@ m_term(NULL)
m_term[1U] |= P25_DUID_TERM;
bch.encode(m_term);
m_term[7U] &= 0xFEU; // Clear the parity bit

m_pdu = new unsigned char[P25_NID_LENGTH_BYTES];
m_pdu[0U] = (nac >> 4) & 0xFFU;
m_pdu[1U] = (nac << 4) & 0xF0U;
m_pdu[1U] |= P25_DUID_PDU;
bch.encode(m_pdu);
m_pdu[7U] &= 0xFEU; // Clear the parity bit
}

CP25NID::~CP25NID()
Expand All @@ -79,6 +87,7 @@ CP25NID::~CP25NID()
delete[] m_ldu2;
delete[] m_termlc;
delete[] m_term;
delete[] m_pdu;
}

bool CP25NID::decode(const unsigned char* data)
Expand Down Expand Up @@ -118,6 +127,12 @@ bool CP25NID::decode(const unsigned char* data)
return true;
}

errs = CP25Utils::compare(nid, m_pdu, P25_NID_LENGTH_BYTES);
if (errs < MAX_NID_ERRS) {
m_duid = P25_DUID_PDU;
return true;
}

return false;
}

Expand All @@ -141,6 +156,9 @@ void CP25NID::encode(unsigned char* data, unsigned char duid) const
case P25_DUID_TERM_LC:
CP25Utils::encode(m_termlc, data, 48U, 114U);
break;
case P25_DUID_PDU:
CP25Utils::encode(m_pdu, data, 48U, 114U);
break;
default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion P25NID.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,6 +37,7 @@ class CP25NID {
unsigned char* m_ldu2;
unsigned char* m_termlc;
unsigned char* m_term;
unsigned char* m_pdu;
};

#endif

0 comments on commit 97e51ca

Please sign in to comment.