Add SelfOnly to YSF.

This commit is contained in:
Jonathan Naylor
2017-08-15 10:11:05 +01:00
parent b3c0e68b23
commit 8b2544ba85
6 changed files with 58 additions and 3 deletions

View File

@@ -23,8 +23,10 @@
// #define DUMP_YSF
CYSFControl::CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL),
m_selfCallsign(NULL),
m_selfOnly(selfOnly),
m_network(network),
m_display(display),
m_duplex(duplex),
@@ -81,6 +83,12 @@ m_fp(NULL)
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++)
m_callsign[i] = node.at(i);
m_selfCallsign = new unsigned char[YSF_CALLSIGN_LENGTH];
::memset(m_selfCallsign, 0x00U, YSF_CALLSIGN_LENGTH);
for (unsigned int i = 0U; i < callsign.length(); i++)
m_selfCallsign[i] = callsign.at(i);
}
CYSFControl::~CYSFControl()
@@ -88,6 +96,7 @@ CYSFControl::~CYSFControl()
delete[] m_netSource;
delete[] m_netDest;
delete[] m_callsign;
delete[] m_selfCallsign;
}
void CYSFControl::setSQL(bool on, unsigned char value)
@@ -201,6 +210,12 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
m_rfSource = m_rfPayload.getSource();
if (m_selfOnly) {
bool ret = checkCallsign(m_rfSource);
if (!ret)
return false;
}
unsigned char cm = m_lastFICH.getCM();
if (cm == YSF_CM_GROUP)
m_rfDest = (unsigned char*)"ALL ";
@@ -375,6 +390,12 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
m_rfSource = m_rfPayload.getSource();
if (m_selfOnly) {
bool ret = checkCallsign(m_rfSource);
if (!ret)
return false;
}
unsigned char cm = m_lastFICH.getCM();
if (cm == YSF_CM_GROUP)
m_rfDest = (unsigned char*)"ALL ";
@@ -584,6 +605,12 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
if (m_rfSource == NULL || m_rfDest == NULL)
return false;
if (m_selfOnly) {
bool ret = checkCallsign(m_rfSource);
if (!ret)
return false;
}
m_rfFrames = 0U;
m_rfErrs = 0U;
m_rfBits = 1U;
@@ -697,6 +724,12 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
m_rfSource = m_rfPayload.getSource();
if (m_selfOnly) {
bool ret = checkCallsign(m_rfSource);
if (!ret)
return false;
}
unsigned char cm = m_lastFICH.getCM();
if (cm == YSF_CM_GROUP)
m_rfDest = (unsigned char*)"ALL ";
@@ -1163,3 +1196,8 @@ void CYSFControl::closeFile()
m_fp = NULL;
}
}
bool CYSFControl::checkCallsign(const unsigned char* callsign) const
{
return ::memcmp(callsign, m_selfCallsign, ::strlen((char*)m_selfCallsign)) == 0;
}