diff --git a/FM.cpp b/FM.cpp index d3fa0ab..8d31e37 100644 --- a/FM.cpp +++ b/FM.cpp @@ -29,6 +29,7 @@ m_timeoutTone(), m_state(FS_LISTENING), m_callsignAtStart(false), m_callsignAtEnd(false), +m_callsignAtLatch(false), m_callsignTimer(), m_timeoutTimer(), m_holdoffTimer(), @@ -140,10 +141,11 @@ void CFM::reset() m_timeoutTone.stop(); } -uint8_t CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd) +uint8_t CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch) { m_callsignAtStart = callsignAtStart; m_callsignAtEnd = callsignAtEnd; + m_callsignAtLatch = callsignAtLatch; uint16_t holdoffTime = holdoff * 60U; uint16_t callsignTime = time * 60U; @@ -246,6 +248,8 @@ void CFM::listeningState(bool validSignal) DEBUG1("State to KERCHUNK"); m_state = FS_KERCHUNK; m_kerchunkTimer.start(); + if (m_callsignAtStart && !m_callsignAtLatch) + sendCallsign(); } else { DEBUG1("State to RELAYING"); m_state = FS_RELAYING; @@ -269,6 +273,10 @@ void CFM::kerchunkState(bool validSignal) DEBUG1("State to RELAYING"); m_state = FS_RELAYING; m_kerchunkTimer.stop(); + if (m_callsignAtStart && m_callsignAtLatch) { + sendCallsign(); + m_callsignTimer.start(); + } } } else { DEBUG1("State to LISTENING"); diff --git a/FM.h b/FM.h index 9bf821c..7e2e79f 100644 --- a/FM.h +++ b/FM.h @@ -53,7 +53,7 @@ public: void reset(); - uint8_t setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd); + uint8_t setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); uint8_t setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level); uint8_t setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel); @@ -66,6 +66,7 @@ private: FM_STATE m_state; bool m_callsignAtStart; bool m_callsignAtEnd; + bool m_callsignAtLatch; CFMTimer m_callsignTimer; CFMTimer m_timeoutTimer; CFMTimer m_holdoffTimer; diff --git a/SerialPort.cpp b/SerialPort.cpp index 2922b57..190e105 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -376,6 +376,7 @@ uint8_t CSerialPort::setFMParams1(const uint8_t* data, uint8_t length) bool callAtStart = (data[6U] & 0x01U) == 0x01U; bool callAtEnd = (data[6U] & 0x02U) == 0x02U; + bool callAtLatch = (data[6U] & 0x04U) == 0x04U; char callsign[50U]; uint8_t n = 0U; @@ -383,7 +384,7 @@ uint8_t CSerialPort::setFMParams1(const uint8_t* data, uint8_t length) callsign[n] = data[i]; callsign[n] = '\0'; - return fm.setCallsign(callsign, speed, frequency, time, holdoff, highLevel, lowLevel, callAtStart, callAtEnd); + return fm.setCallsign(callsign, speed, frequency, time, holdoff, highLevel, lowLevel, callAtStart, callAtEnd, callAtLatch); } uint8_t CSerialPort::setFMParams2(const uint8_t* data, uint8_t length)