Skip to content

Commit

Permalink
Ignore M17 packet data, for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Mar 29, 2021
1 parent 389bd3b commit 8dc54ed
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 95 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_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
if (data[0U] != TAG_DATA1 || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
return false;

CDMRCSBK csbk;
Expand Down
8 changes: 4 additions & 4 deletions DMRDefines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2021 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 All @@ -19,7 +19,7 @@
#if !defined(DMRDefines_H)
#define DMRDefines_H

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

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_DATA, 0x00U,
const unsigned char DMR_IDLE_DATA[] = {TAG_DATA1, 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_DATA, 0x00U,
const unsigned char DMR_SILENCE_DATA[] = {TAG_DATA1, 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 @@ -255,7 +255,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_DATA;
data[0U] = TAG_DATA1;
data[1U] = 0x00U;

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

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

if (m_duplex)
Expand Down Expand Up @@ -404,7 +404,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_DATA;
data[0U] = m_rfFrames == 0U ? TAG_EOT : TAG_DATA1;
data[1U] = 0x00U;

if (m_duplex)
Expand Down Expand Up @@ -472,7 +472,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_DATA;
data[0U] = TAG_DATA1;
data[1U] = 0x00U;

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

m_rfFrames--;

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

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

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

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

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

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

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

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

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

if (m_duplex)
Expand Down Expand Up @@ -1088,7 +1088,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_DATA;
data[0U] = TAG_DATA1;
data[1U] = 0x00U;

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

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

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

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

writeQueueNet(data);
Expand Down Expand Up @@ -1304,7 +1304,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_DATA;
data[0U] = m_netFrames == 0U ? TAG_EOT : TAG_DATA1;
data[1U] = 0x00U;

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

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

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

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

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

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

// Initialise the lost packet data
Expand Down Expand Up @@ -1633,7 +1633,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_DATA;
data[0U] = TAG_DATA1;
data[1U] = 0x00U;

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

m_netFrames--;

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

#if defined(DUMP_DMR)
Expand Down
8 changes: 4 additions & 4 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2019 Jonathan Naylor, G4KLX
* Copyright (C) 2015-2019,2021 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 @@ -429,7 +429,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
}

return false;
} else if (type == TAG_DATA) {
} else if (type == TAG_DATA1) {
if (m_rfState == RS_RF_REJECTED) {
return false;
} else if (m_rfState == RS_RF_INVALID) {
Expand Down Expand Up @@ -779,13 +779,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_DATA) {
} else if (type == TAG_DATA1) {
if (m_netState != RS_NET_AUDIO)
return;

unsigned char n = data[1U];

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

unsigned int errors = 0U;
if (!m_netHeader.isDataPacket())
Expand Down
6 changes: 3 additions & 3 deletions DStarDefines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018,2019 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2019,2021 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 @@ -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_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 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 int DSTAR_VOICE_FRAME_LENGTH_BYTES = 9U;
const unsigned int DSTAR_DATA_FRAME_LENGTH_BYTES = 3U;
Expand Down
6 changes: 3 additions & 3 deletions DStarNetwork.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2019,2020,2021 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 @@ -263,7 +263,7 @@ void CDStarNetwork::clock(unsigned int ms)
m_inId = 0U;
ctrl[1U] = TAG_EOT;
} else {
ctrl[1U] = TAG_DATA;
ctrl[1U] = TAG_DATA1;
}

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_DATA:
case TAG_DATA1:
case TAG_EOT:
::memcpy(data, buffer, c);
return c;
Expand Down
7 changes: 4 additions & 3 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ const unsigned char MODE_ERROR = 100U;
const unsigned char MODE_QUIT = 110U;

const unsigned char TAG_HEADER = 0x00U;
const unsigned char TAG_DATA = 0x01U;
const unsigned char TAG_LOST = 0x02U;
const unsigned char TAG_EOT = 0x03U;
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 int DSTAR_MODEM_DATA_LEN = 220U;

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->writeEOT();

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

m_incomingRFAudio.addData(data + 1U, length - 1U);
Expand Down
20 changes: 15 additions & 5 deletions M17Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
return false;
}

// Ignore packet data
if (type == TAG_DATA2) {
m_rfState = RS_RF_LISTENING;
return false;
}

// Have we got RSSI bytes on the end?
if (len == (M17_FRAME_LENGTH_BYTES + 4U)) {
uint16_t raw = 0U;
Expand Down Expand Up @@ -200,12 +206,12 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
}
}

if (m_rfState == RS_RF_LISTENING && data[0U] == TAG_DATA) {
if (m_rfState == RS_RF_LISTENING && data[0U] == TAG_DATA1) {
m_rfState = RS_RF_LATE_ENTRY;
m_rfLSF.reset();
}

if (m_rfState == RS_RF_LATE_ENTRY && data[0U] == TAG_DATA) {
if (m_rfState == RS_RF_LATE_ENTRY && data[0U] == TAG_DATA1) {
bool valid1, valid2, valid3, valid4;
unsigned int lich1 = CGolay24128::decode24128(data + 2U + M17_SYNC_LENGTH_BYTES + 0U, valid1);
unsigned int lich2 = CGolay24128::decode24128(data + 2U + M17_SYNC_LENGTH_BYTES + 3U, valid2);
Expand Down Expand Up @@ -247,7 +253,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
}
}

if (m_rfState == RS_RF_AUDIO && data[0U] == TAG_DATA) {
if (m_rfState == RS_RF_AUDIO && data[0U] == TAG_DATA1) {
#if defined(DUMP_M17)
writeFile(data + 2U);
#endif
Expand All @@ -271,7 +277,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)

unsigned char rfData[2U + M17_FRAME_LENGTH_BYTES];

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

// Generate the sync
Expand Down Expand Up @@ -487,7 +493,7 @@ void CM17Control::writeNetwork()
if (m_netState == RS_NET_AUDIO) {
unsigned char data[M17_FRAME_LENGTH_BYTES + 2U];

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

// Generate the sync
Expand Down Expand Up @@ -547,6 +553,10 @@ void CM17Control::writeNetwork()

bool CM17Control::processRFHeader(bool lateEntry)
{
unsigned char packetStream = m_rfLSF.getPacketStream();
if (packetStream == M17_PACKET_TYPE)
return false;

unsigned char can = m_rfLSF.getCAN();
if (can != m_can)
return false;
Expand Down
Loading

0 comments on commit 8dc54ed

Please sign in to comment.