Skip to content

Commit

Permalink
Add M17 Codec 1600 mode on RX and remove the remains of M17 packet mode
Browse files Browse the repository at this point in the history
support.
  • Loading branch information
g4klx committed Aug 10, 2021
1 parent bfacdee commit e2e5ddf
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 107 deletions.
2 changes: 1 addition & 1 deletion DMRControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool CDMRControl::processWakeup(const unsigned char* data)
assert(data != NULL);

// Wakeups always come in on slot 1
if (data[0U] != TAG_DATA1 || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
return false;

CDMRCSBK csbk;
Expand Down
6 changes: 3 additions & 3 deletions DMRDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#if !defined(DMRDefines_H)
#define DMRDefines_H

#include "Defines.h" // For TAG_DATA1
#include "Defines.h" // For TAG_DATA

const unsigned int DMR_FRAME_LENGTH_BITS = 264U;
const unsigned int DMR_FRAME_LENGTH_BYTES = 33U;
Expand Down Expand Up @@ -54,13 +54,13 @@ const unsigned char DIRECT_SLOT2_DATA_SYNC[] = {0x0DU, 0x75U, 0x57U, 0xF5U, 0xF
const unsigned char SYNC_MASK[] = {0x0FU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xF0U};

// The PR FILL and Data Sync pattern.
const unsigned char DMR_IDLE_DATA[] = {TAG_DATA1, 0x00U,
const unsigned char DMR_IDLE_DATA[] = {TAG_DATA, 0x00U,
0x53U, 0xC2U, 0x5EU, 0xABU, 0xA8U, 0x67U, 0x1DU, 0xC7U, 0x38U, 0x3BU, 0xD9U,
0x36U, 0x00U, 0x0DU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD0U, 0x03U, 0xF6U,
0xE4U, 0x65U, 0x17U, 0x1BU, 0x48U, 0xCAU, 0x6DU, 0x4FU, 0xC6U, 0x10U, 0xB4U};

// A silence frame only
const unsigned char DMR_SILENCE_DATA[] = {TAG_DATA1, 0x00U,
const unsigned char DMR_SILENCE_DATA[] = {TAG_DATA, 0x00U,
0xB9U, 0xE8U, 0x81U, 0x52U, 0x61U, 0x73U, 0x00U, 0x2AU, 0x6BU, 0xB9U, 0xE8U,
0x81U, 0x52U, 0x60U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x73U, 0x00U,
0x2AU, 0x6BU, 0xB9U, 0xE8U, 0x81U, 0x52U, 0x61U, 0x73U, 0x00U, 0x2AU, 0x6BU};
Expand Down
36 changes: 18 additions & 18 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

m_rfTimeoutTimer.start();
Expand Down Expand Up @@ -317,7 +317,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
bptc.decode(data + 2U, payload);
bptc.encode(payload, data + 2U);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -408,7 +408,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = m_rfFrames == 0U ? TAG_EOT : TAG_DATA1;
data[0U] = m_rfFrames == 0U ? TAG_EOT : TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -478,7 +478,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -551,7 +551,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)

m_rfFrames--;

data[0U] = m_rfFrames == 0U ? TAG_EOT : TAG_DATA1;
data[0U] = m_rfFrames == 0U ? TAG_EOT : TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -592,7 +592,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_display->writeDMRRSSI(m_slotNo, m_rssi);

if (!m_rfTimeout) {
data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -758,7 +758,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
emb.getData(data + 2U);

if (!m_rfTimeout) {
data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

writeNetworkRF(data, DT_VOICE, errors);
Expand Down Expand Up @@ -836,7 +836,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
slotType.setDataType(DT_VOICE_LC_HEADER);
slotType.getData(start + 2U);

start[0U] = TAG_DATA1;
start[0U] = TAG_DATA;
start[1U] = 0x00U;

m_rfTimeoutTimer.start();
Expand Down Expand Up @@ -888,7 +888,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_rfBits += 141U;
m_rfFrames++;

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

m_lastFrameValid = false;
Expand Down Expand Up @@ -1185,7 +1185,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
slotType.setDataType(DT_VOICE_LC_HEADER);
slotType.getData(start + 2U);

start[0U] = TAG_DATA1;
start[0U] = TAG_DATA;
start[1U] = 0x00U;

if (m_duplex) {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
bptc.decode(data + 2U, payload);
bptc.encode(payload, data + 2U);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

writeQueueNet(data);
Expand Down Expand Up @@ -1312,7 +1312,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA1;
data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA;
data[1U] = 0x00U;

// Put a small delay into starting transmission
Expand Down Expand Up @@ -1382,7 +1382,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
slotType.setDataType(DT_VOICE_LC_HEADER);
slotType.getData(start + 2U);

start[0U] = TAG_DATA1;
start[0U] = TAG_DATA;
start[1U] = 0x00U;

if (m_duplex) {
Expand Down Expand Up @@ -1425,7 +1425,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
m_netErrs += m_fec.regenerateDMR(data + 2U);
m_netBits += 141U;

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

// Convert the Audio Sync to be from the BS or MS as needed
Expand Down Expand Up @@ -1580,7 +1580,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
emb.setLCSS(lcss);
emb.getData(data + 2U);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

// Initialise the lost packet data
Expand Down Expand Up @@ -1641,7 +1641,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// Convert the Data Sync to be from the BS or MS as needed
CSync::addDMRDataSync(data + 2U, m_duplex);

data[0U] = TAG_DATA1;
data[0U] = TAG_DATA;
data[1U] = 0x00U;

if (csbko == CSBKO_PRECCSBK && csbk.getDataContent()) {
Expand Down Expand Up @@ -1740,7 +1740,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)

m_netFrames--;

data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA1;
data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA;
data[1U] = 0x00U;

#if defined(DUMP_DMR)
Expand Down
6 changes: 3 additions & 3 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
}

return false;
} else if (type == TAG_DATA1) {
} else if (type == TAG_DATA) {
if (m_rfState == RS_RF_REJECTED) {
return true;
} else if (m_rfState == RS_RF_INVALID) {
Expand Down Expand Up @@ -780,13 +780,13 @@ void CDStarControl::writeNetwork()
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss, BER: %.1f%%", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));

writeEndNet();
} else if (type == TAG_DATA1) {
} else if (type == TAG_DATA) {
if (m_netState != RS_NET_AUDIO)
return;

unsigned char n = data[1U];

data[1U] = TAG_DATA1;
data[1U] = TAG_DATA;

unsigned int errors = 0U;
if (!m_netHeader.isDataPacket())
Expand Down
4 changes: 2 additions & 2 deletions DStarDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const unsigned char DSTAR_NULL_SLOW_SYNC_BYTES[] = { 0x55, 0x2D, 0x16 };
// Note that these are already scrambled, 0x66 0x66 0x66 otherwise
const unsigned char DSTAR_NULL_SLOW_DATA_BYTES[] = { 0x16, 0x29, 0xF5 };

const unsigned char DSTAR_NULL_FRAME_SYNC_BYTES[] = { TAG_DATA1, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16 };
const unsigned char DSTAR_NULL_FRAME_DATA_BYTES[] = { TAG_DATA1, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x16, 0x29, 0xF5 };
const unsigned char DSTAR_NULL_FRAME_SYNC_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16 };
const unsigned char DSTAR_NULL_FRAME_DATA_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x16, 0x29, 0xF5 };

const unsigned int DSTAR_VOICE_FRAME_LENGTH_BYTES = 9U;
const unsigned int DSTAR_DATA_FRAME_LENGTH_BYTES = 3U;
Expand Down
4 changes: 2 additions & 2 deletions DStarNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void CDStarNetwork::clock(unsigned int ms)
m_inId = 0U;
ctrl[1U] = TAG_EOT;
} else {
ctrl[1U] = TAG_DATA1;
ctrl[1U] = TAG_DATA;
}

ctrl[2U] = buffer[7] & 0x3FU;
Expand Down Expand Up @@ -299,7 +299,7 @@ unsigned int CDStarNetwork::read(unsigned char* data, unsigned int length)

switch (buffer[0U]) {
case TAG_HEADER:
case TAG_DATA1:
case TAG_DATA:
case TAG_EOT:
::memcpy(data, buffer, c);
return c;
Expand Down
9 changes: 5 additions & 4 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ const unsigned char MODE_ERROR = 100U;
const unsigned char MODE_QUIT = 110U;

const unsigned char TAG_HEADER = 0x00U;
const unsigned char TAG_DATA1 = 0x01U;
const unsigned char TAG_DATA2 = 0x02U;
const unsigned char TAG_LOST = 0x03U;
const unsigned char TAG_EOT = 0x04U;
const unsigned char TAG_DATA = 0x01U;
const unsigned char TAG_LOST = 0x02U;
const unsigned char TAG_EOT = 0x03U;

const unsigned int DSTAR_MODEM_DATA_LEN = 220U;

Expand All @@ -62,6 +61,7 @@ enum RPT_RF_STATE {
RS_RF_LISTENING,
RS_RF_LATE_ENTRY,
RS_RF_AUDIO,
RS_RF_DATA_AUDIO,
RS_RF_DATA,
RS_RF_REJECTED,
RS_RF_INVALID
Expand All @@ -70,6 +70,7 @@ enum RPT_RF_STATE {
enum RPT_NET_STATE {
RS_NET_IDLE,
RS_NET_AUDIO,
RS_NET_DATA_AUDIO,
RS_NET_DATA
};

Expand Down
2 changes: 1 addition & 1 deletion FMControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
if (data[0U] == TAG_EOT)
return m_network->writeEnd();

if (data[0U] != TAG_DATA1)
if (data[0U] != TAG_DATA)
return false;

m_incomingRFAudio.addData(data + 1U, length - 1U);
Expand Down
Loading

0 comments on commit e2e5ddf

Please sign in to comment.