Skip to content

Commit

Permalink
Extend preamble length for network CSBK preamble
Browse files Browse the repository at this point in the history
  • Loading branch information
juribeparada committed Sep 23, 2018
1 parent 9d2d4c8 commit 3e81d1e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
13 changes: 13 additions & 0 deletions DMRCSBK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ void CDMRCSBK::get(unsigned char* bytes) const
{
assert(bytes != NULL);

m_data[10U] ^= CSBK_CRC_MASK[0U];
m_data[11U] ^= CSBK_CRC_MASK[1U];

CCRC::addCCITT162(m_data, 12U);

m_data[10U] ^= CSBK_CRC_MASK[0U];
m_data[11U] ^= CSBK_CRC_MASK[1U];

CBPTC19696 bptc;
bptc.encode(m_data, bytes);
}
Expand Down Expand Up @@ -170,3 +178,8 @@ unsigned char CDMRCSBK::getCBF() const
{
return m_CBF;
}

void CDMRCSBK::setCBF(unsigned char cbf)
{
m_CBF = m_data[3U] = cbf;
}
2 changes: 2 additions & 0 deletions DMRCSBK.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class CDMRCSBK
bool getDataContent() const;
unsigned char getCBF() const;

void setCBF(unsigned char cbf);

private:
unsigned char* m_data;
CSBKO m_CSBKO;
Expand Down
24 changes: 23 additions & 1 deletion DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const unsigned char TALKER_ID_BLOCK3 = 0x08U;

const unsigned int NO_HEADERS_SIMPLEX = 8U;
const unsigned int NO_HEADERS_DUPLEX = 3U;
const unsigned int NO_PREAMBLE_CSBK = 15U;

// #define DUMP_DMR

Expand Down Expand Up @@ -1565,7 +1566,28 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
data[0U] = TAG_DATA;
data[1U] = 0x00U;

writeQueueNet(data);
if (csbko == CSBKO_PRECCSBK && csbk.getDataContent()) {
unsigned int cbf = NO_PREAMBLE_CSBK + csbk.getCBF() - 1U;
for (unsigned int i = 0U; i < NO_PREAMBLE_CSBK; i++, cbf--) {
// Change blocks to follow
csbk.setCBF(cbf);

// Regenerate the CSBK data
csbk.get(data + 2U);

// Regenerate the Slot Type
CDMRSlotType slotType;
slotType.putData(data + 2U);
slotType.setColorCode(m_colorCode);
slotType.getData(data + 2U);

// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

writeQueueNet(data);
}
} else
writeQueueNet(data);

#if defined(DUMP_DMR)
openFile();
Expand Down

0 comments on commit 3e81d1e

Please sign in to comment.