Update to send and receive the new EOF marker.

This commit is contained in:
Jonathan Naylor 2021-08-25 21:11:09 +01:00
parent 7275f65e44
commit 63a8e61a45
8 changed files with 163 additions and 5 deletions

View file

@ -67,6 +67,7 @@ const uint8_t MMDVM_M17_LINK_SETUP = 0x45U;
const uint8_t MMDVM_M17_STREAM = 0x46U;
const uint8_t MMDVM_M17_PACKET = 0x47U;
const uint8_t MMDVM_M17_LOST = 0x48U;
const uint8_t MMDVM_M17_EOT = 0x49U;
const uint8_t MMDVM_POCSAG_DATA = 0x50U;
@ -1305,7 +1306,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
case MMDVM_M17_LINK_SETUP:
if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeData(buffer, length);
err = m17TX.writeHeader(buffer, length);
}
if (err == 0U) {
if (m_modemState == STATE_IDLE)
@ -1319,7 +1320,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
case MMDVM_M17_STREAM:
if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeData(buffer, length);
err = m17TX.writeStream(buffer, length);
}
if (err == 0U) {
if (m_modemState == STATE_IDLE)
@ -1329,6 +1330,20 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
sendNAK(type, err);
}
break;
case MMDVM_M17_EOT:
if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeEOT();
}
if (err == 0U) {
if (m_modemState == STATE_IDLE)
setMode(STATE_M17);
} else {
DEBUG2("Received invalid M17 EOT", err);
sendNAK(type, err);
}
break;
#endif
#if defined(MODE_POCSAG)
@ -1726,6 +1741,23 @@ void CSerialPort::writeM17Stream(const uint8_t* data, uint8_t length)
writeInt(1U, reply, count);
}
void CSerialPort::writeM17EOT()
{
if (m_modemState != STATE_M17 && m_modemState != STATE_IDLE)
return;
if (!m_m17Enable)
return;
uint8_t reply[3U];
reply[0U] = MMDVM_FRAME_START;
reply[1U] = 3U;
reply[2U] = MMDVM_M17_EOT;
writeInt(1U, reply, 3);
}
void CSerialPort::writeM17Lost()
{
if (m_modemState != STATE_M17 && m_modemState != STATE_IDLE)