Check the guard byte on fast data as well as the mini header.

This commit is contained in:
Jonathan Naylor 2019-01-29 22:32:24 +00:00
parent 9cc2bfaaec
commit 317bda0177
2 changed files with 8 additions and 8 deletions

View file

@ -343,8 +343,9 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
// Check for the fast data signature
if (m_rfState == RS_RF_AUDIO && (m_rfN % 2U) == 1U) {
unsigned char slowDataType = (data[DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U] ^ DSTAR_SCRAMBLER_BYTE1) & DSTAR_SLOW_DATA_TYPE_MASK;
if (slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA1 || slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA2) {
unsigned char slowDataType = (data[DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U] ^ DSTAR_SCRAMBLER_BYTES[0U]) & DSTAR_SLOW_DATA_TYPE_MASK;
unsigned char guard = data[4U + 1U] ^ DSTAR_SCRAMBLER_BYTES[4U];
if ((slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA1 || slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA2) && guard == DSTAR_FAST_DATA_GUARD_BYTE) {
LogMessage("D-Star, switching to fast data mode");
m_rfState = RS_RF_DATA;
}
@ -712,8 +713,9 @@ void CDStarControl::writeNetwork()
// Check for the fast data signature
if (m_netState == RS_NET_AUDIO && (n % 2U) == 1U) {
unsigned char slowDataType = data[DSTAR_VOICE_FRAME_LENGTH_BYTES + 2U] & DSTAR_SLOW_DATA_TYPE_MASK;
if (slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA1 || slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA2) {
unsigned char slowDataType = (data[DSTAR_VOICE_FRAME_LENGTH_BYTES + 2U] ^ DSTAR_SCRAMBLER_BYTES[0U]) & DSTAR_SLOW_DATA_TYPE_MASK;
unsigned char guard = data[4U + 2U] ^ DSTAR_SCRAMBLER_BYTES[4U];
if ((slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA1 || slowDataType == DSTAR_SLOW_DATA_TYPE_FAST_DATA2) && guard == DSTAR_FAST_DATA_GUARD_BYTE) {
LogMessage("D-Star, switching to fast data mode");
m_netState = RS_NET_DATA;
}

View file

@ -53,7 +53,7 @@ const unsigned char DSTAR_SLOW_DATA_TYPE_FAST_DATA2 = 0x90U;
const unsigned char DSTAR_SLOW_DATA_TYPE_SQUELCH = 0xC0U;
const unsigned char DSTAR_SLOW_DATA_LENGTH_MASK = 0x0FU;
const unsigned char DSTAR_SCRAMBLER_BYTES[] = {0x70U, 0x4FU, 0x93U};
const unsigned char DSTAR_SCRAMBLER_BYTES[] = { 0x70U, 0x4FU, 0x93U, 0x40U, 0x64U, 0x74U, 0x6DU, 0x30U, 0x2BU };
const unsigned char DSTAR_DATA_MASK = 0x80U;
const unsigned char DSTAR_REPEATER_MASK = 0x40U;
@ -67,9 +67,7 @@ const unsigned char DSTAR_ACK_FLAG = 0x03U;
const unsigned char DSTAR_NO_RESPONSE = 0x02U;
const unsigned char DSTAR_RELAY_UNAVAILABLE = 0x01U;
const unsigned char DSTAR_SCRAMBLER_BYTE1 = 0x70U;
const unsigned char DSTAR_SCRAMBLER_BYTE2 = 0x4FU;
const unsigned char DSTAR_SCRAMBLER_BYTE3 = 0x93U;
const unsigned char DSTAR_FAST_DATA_GUARD_BYTE = 0x02U;
const unsigned char DSTAR_SYNC_BYTES[] = {0x55U, 0x2DU, 0x16U};