Flesh out the data header.

This commit is contained in:
Jonathan Naylor 2016-02-25 17:31:43 +00:00
parent f29f48503e
commit 7822758043
3 changed files with 99 additions and 11 deletions

View file

@ -29,10 +29,14 @@
CDMRDataHeader::CDMRDataHeader() : CDMRDataHeader::CDMRDataHeader() :
m_data(NULL), m_data(NULL),
m_gi(false), m_GI(false),
m_A(false),
m_srcId(0U), m_srcId(0U),
m_dstId(0U), m_dstId(0U),
m_blocks(0U) m_blocks(0U),
m_F(false),
m_S(false),
m_Ns(0U)
{ {
m_data = new unsigned char[12U]; m_data = new unsigned char[12U];
} }
@ -60,14 +64,61 @@ bool CDMRDataHeader::put(const unsigned char* bytes)
m_data[10U] ^= DATA_HEADER_CRC_MASK[0U]; m_data[10U] ^= DATA_HEADER_CRC_MASK[0U];
m_data[11U] ^= DATA_HEADER_CRC_MASK[1U]; m_data[11U] ^= DATA_HEADER_CRC_MASK[1U];
m_gi = (m_data[0U] & 0x80U) == 0x80U; m_GI = (m_data[0U] & 0x80U) == 0x80U;
m_A = (m_data[0U] & 0x40U) == 0x40U;
unsigned char dpf = m_data[0U] & 0x0FU;
if (dpf == DPF_PROPRIETARY)
return true;
m_dstId = m_data[2U] << 16 | m_data[3U] << 8 | m_data[4U]; m_dstId = m_data[2U] << 16 | m_data[3U] << 8 | m_data[4U];
m_srcId = m_data[5U] << 16 | m_data[6U] << 8 | m_data[7U]; m_srcId = m_data[5U] << 16 | m_data[6U] << 8 | m_data[7U];
// XXX check these, add logging like CSBK?
switch (dpf) {
case DPF_UNCONFIRMED_DATA:
CUtils::dump("Unconfirmed Data Header", m_data, 12U);
m_F = (m_data[8U] & 0x80U) == 0x80U;
m_blocks = m_data[8U] & 0x7FU; m_blocks = m_data[8U] & 0x7FU;
break;
CUtils::dump("Data Header", m_data, 12U); case DPF_CONFIRMED_DATA:
CUtils::dump("Confirmed Data Header", m_data, 12U);
m_F = (m_data[8U] & 0x80U) == 0x80U;
m_blocks = m_data[8U] & 0x7FU;
m_S = (m_data[9U] & 0x80U) == 0x80U;
m_Ns = (m_data[9U] >> 4) & 0x07U;
break;
case DPF_RESPONSE:
CUtils::dump("Response Data Header", m_data, 12U);
m_blocks = m_data[8U] & 0x7FU;
break;
case DPF_PROPRIETARY:
CUtils::dump("Proprietary Data Header", m_data, 12U);
break;
case DPF_DEFINED_RAW:
CUtils::dump("Raw or Status/Precoded Short Data Header", m_data, 12U);
m_F = (m_data[8U] & 0x01U) == 0x01U;
m_S = (m_data[8U] & 0x02U) == 0x02U;
break;
case DPF_DEFINED_SHORT:
CUtils::dump("Defined Short Data Header", m_data, 12U);
m_F = (m_data[8U] & 0x01U) == 0x01U;
m_S = (m_data[8U] & 0x02U) == 0x02U;
break;
case DPF_UDT:
CUtils::dump("Unified Data Transport Header", m_data, 12U);
break;
default:
CUtils::dump("Unknown Data Header", m_data, 12U);
break;
}
return true; return true;
} }
@ -82,7 +133,12 @@ void CDMRDataHeader::get(unsigned char* bytes) const
bool CDMRDataHeader::getGI() const bool CDMRDataHeader::getGI() const
{ {
return m_gi; return m_GI;
}
bool CDMRDataHeader::getA() const
{
return m_A;
} }
unsigned int CDMRDataHeader::getSrcId() const unsigned int CDMRDataHeader::getSrcId() const
@ -99,3 +155,18 @@ unsigned int CDMRDataHeader::getBlocks() const
{ {
return m_blocks; return m_blocks;
} }
bool CDMRDataHeader::getF() const
{
return m_F;
}
bool CDMRDataHeader::getS() const
{
return m_S;
}
unsigned char CDMRDataHeader::getNs() const
{
return m_Ns;
}

View file

@ -30,18 +30,27 @@ public:
void get(unsigned char* bytes) const; void get(unsigned char* bytes) const;
bool getGI() const; bool getGI() const;
bool getA() const;
unsigned int getSrcId() const; unsigned int getSrcId() const;
unsigned int getDstId() const; unsigned int getDstId() const;
unsigned int getBlocks() const; unsigned int getBlocks() const;
bool getF() const;
bool getS() const;
unsigned char getNs() const;
private: private:
unsigned char* m_data; unsigned char* m_data;
bool m_gi; bool m_GI;
bool m_A;
unsigned int m_srcId; unsigned int m_srcId;
unsigned int m_dstId; unsigned int m_dstId;
unsigned int m_blocks; unsigned int m_blocks;
bool m_F;
bool m_S;
unsigned char m_Ns;
}; };
#endif #endif

View file

@ -100,6 +100,14 @@ const unsigned char DMR_SYNC_AUDIO = 0x20U;
const unsigned char DMR_SLOT1 = 0x00U; const unsigned char DMR_SLOT1 = 0x00U;
const unsigned char DMR_SLOT2 = 0x80U; const unsigned char DMR_SLOT2 = 0x80U;
const unsigned char DPF_UDT = 0x00U;
const unsigned char DPF_RESPONSE = 0x01U;
const unsigned char DPF_UNCONFIRMED_DATA = 0x02U;
const unsigned char DPF_CONFIRMED_DATA = 0x03U;
const unsigned char DPF_DEFINED_SHORT = 0x0DU;
const unsigned char DPF_DEFINED_RAW = 0x0EU;
const unsigned char DPF_PROPRIETARY = 0x0FU;
const unsigned char FID_ETSI = 0U; const unsigned char FID_ETSI = 0U;
const unsigned char FID_DMRA = 16U; const unsigned char FID_DMRA = 16U;