Add rejected state to incoming RF data.

This commit is contained in:
Jonathan Naylor 2016-07-12 07:50:01 +01:00
parent 6f848722f9
commit 9035656eeb
2 changed files with 14 additions and 6 deletions

View file

@ -117,8 +117,7 @@ bool CDStarControl::writeModem(unsigned char *data)
}
if (type == TAG_LOST) {
if (m_rfState == RS_RF_LATE_ENTRY)
m_rfState = RS_RF_LISTENING;
m_rfState = RS_RF_LISTENING;
return false;
}
@ -131,6 +130,7 @@ bool CDStarControl::writeModem(unsigned char *data)
// Is this a transmission destined for a repeater?
if (!header.isRepeater()) {
LogMessage("D-Star, non repeater RF header received from %8.8s", my1);
m_rfState = RS_RF_REJECTED;
return false;
}
@ -140,16 +140,19 @@ bool CDStarControl::writeModem(unsigned char *data)
// Is it for us?
if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) {
LogMessage("D-Star, received RF header for wrong repeater (%8.8s) from %8.8s", callsign, my1);
m_rfState = RS_RF_REJECTED;
return false;
}
if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0) {
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
m_rfState = RS_RF_REJECTED;
return false;
}
if (!m_selfOnly && std::find_if(m_blackList.begin(), m_blackList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_blackList.end()) {
LogMessage("D-Star, invalid access attempt from %8.8s", my1);
m_rfState = RS_RF_REJECTED;
return false;
}
@ -205,7 +208,9 @@ bool CDStarControl::writeModem(unsigned char *data)
LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your);
} else if (type == TAG_EOT) {
if (m_rfState == RS_RF_AUDIO) {
if (m_rfState == RS_RF_REJECTED) {
m_rfState = RS_RF_LISTENING;
} else if (m_rfState == RS_RF_AUDIO) {
if (m_net)
writeNetworkDataRF(DSTAR_END_PATTERN_BYTES, 0U, true);
@ -220,7 +225,9 @@ bool CDStarControl::writeModem(unsigned char *data)
return false;
} else if (type == TAG_DATA) {
if (m_rfState == RS_RF_LISTENING) {
if (m_rfState == RS_RF_REJECTED) {
return false;
} else if (m_rfState == RS_RF_LISTENING) {
// The sync is regenerated by the modem so can do exact match
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0) {
m_slowData.start();
@ -436,7 +443,7 @@ void CDStarControl::writeNetwork()
if (length == 0U)
return;
if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE)
if (m_rfState == RS_RF_AUDIO && m_netState == RS_NET_IDLE)
return;
m_networkWatchdog.start();

View file

@ -35,7 +35,8 @@ enum RPT_RF_STATE {
RS_RF_LISTENING,
RS_RF_LATE_ENTRY,
RS_RF_AUDIO,
RS_RF_DATA
RS_RF_DATA,
RS_RF_REJECTED
};
enum RPT_NET_STATE {