Skip to content

Commit

Permalink
Update the M17 sync words.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Dec 26, 2020
1 parent 1c3f6ae commit 9d85b64
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
8 changes: 4 additions & 4 deletions M17Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
data[1U] = 0x00U;

// Generate the sync
CSync::addM17HeaderSync(data + 2U);
CSync::addM17LinkSetupSync(data + 2U);

unsigned char setup[M17_LICH_LENGTH_BYTES];
m_rfLICH.getLinkSetup(setup);
Expand Down Expand Up @@ -332,7 +332,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
rfData[1U] = 0x00U;

// Generate the sync
CSync::addM17DataSync(rfData + 2U);
CSync::addM17StreamSync(rfData + 2U);

unsigned char lich[M17_LICH_FRAGMENT_LENGTH_BYTES];
m_netLICH.getFragment(lich, m_rfLICHn);
Expand Down Expand Up @@ -541,7 +541,7 @@ void CM17Control::writeNetwork()
start[1U] = 0x00U;

// Generate the sync
CSync::addM17HeaderSync(start + 2U);
CSync::addM17LinkSetupSync(start + 2U);

unsigned char setup[M17_LICH_LENGTH_BYTES];
m_netLICH.getLinkSetup(setup);
Expand All @@ -563,7 +563,7 @@ void CM17Control::writeNetwork()
data[1U] = 0x00U;

// Generate the sync
CSync::addM17DataSync(data + 2U);
CSync::addM17StreamSync(data + 2U);

m_netFrames++;

Expand Down
5 changes: 3 additions & 2 deletions M17Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const unsigned int M17_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate
const unsigned int M17_FRAME_LENGTH_BITS = 384U;
const unsigned int M17_FRAME_LENGTH_BYTES = M17_FRAME_LENGTH_BITS / 8U;

const unsigned char M17_HEADER_SYNC_BYTES[] = {0x5DU, 0xDDU};
const unsigned char M17_DATA_SYNC_BYTES[] = {0xDDU, 0xDDU};
const unsigned char M17_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U};
const unsigned char M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU};
const unsigned char M17_PACKET_SYNC_BYTES[] = {0x75U, 0xFFU};

const unsigned int M17_SYNC_LENGTH_BITS = 16U;
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;
Expand Down
15 changes: 11 additions & 4 deletions Sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,23 @@ void CSync::addNXDNSync(unsigned char* data)
data[i] = (data[i] & ~NXDN_FSW_BYTES_MASK[i]) | NXDN_FSW_BYTES[i];
}

void CSync::addM17HeaderSync(unsigned char* data)
void CSync::addM17LinkSetupSync(unsigned char* data)
{
assert(data != NULL);

::memcpy(data, M17_HEADER_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
::memcpy(data, M17_LINK_SETUP_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}

void CSync::addM17DataSync(unsigned char* data)
void CSync::addM17StreamSync(unsigned char* data)
{
assert(data != NULL);

::memcpy(data, M17_DATA_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
::memcpy(data, M17_STREAM_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}

void CSync::addM17PacketSync(unsigned char* data)
{
assert(data != NULL);

::memcpy(data, M17_PACKET_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}
5 changes: 3 additions & 2 deletions Sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class CSync

static void addNXDNSync(unsigned char* data);

static void addM17HeaderSync(unsigned char* data);
static void addM17DataSync(unsigned char* data);
static void addM17LinkSetupSync(unsigned char* data);
static void addM17StreamSync(unsigned char* data);
static void addM17PacketSync(unsigned char* data);

private:
};
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H

const char* VERSION = "20201215";
const char* VERSION = "20201226";

#endif

0 comments on commit 9d85b64

Please sign in to comment.