1
0
Fork 0

Have initial reply to ALL working.

ycs232-kbc
Jonathan Naylor 9 years ago
parent b71c77a9b8
commit e0e6546cc6

@ -4,7 +4,8 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread
LIBS = -lpthread
LDFLAGS = -g
OBJECTS = Network.o StopWatch.o Timer.o UDPSocket.o Utils.o YSFReflector.o
OBJECTS = APRSWriterThread.o Conf.o CRC.o Golay24128.o GPS.o Hosts.o Log.o Network.o Reflectors.o StopWatch.o Sync.o TCPSocket.o Thread.o Timer.o UDPSocket.o Utils.o \
WiresX.o YSFConvolution.o YSFFICH.o YSFGateway.o YSFPayload.o
all: YSFGateway

@ -29,6 +29,7 @@ m_hostsFile(hostsFile),
m_socket(statusPort),
m_reflectors(),
m_it(),
m_current(),
m_timer(1000U, 60U)
{
assert(statusPort > 0U);
@ -81,6 +82,18 @@ CYSFReflector* CReflectors::find(const std::string& id)
return NULL;
}
std::vector<CYSFReflector*>& CReflectors::current()
{
m_current.clear();
for (std::vector<CYSFReflector*>::iterator it = m_reflectors.begin(); it != m_reflectors.end(); ++it) {
if ((*it)->m_timer.isRunning() && !(*it)->m_timer.hasExpired())
m_current.push_back(*it);
}
return m_current;
}
void CReflectors::clock(unsigned int ms)
{
m_timer.clock(ms);

@ -56,6 +56,8 @@ public:
CYSFReflector* find(const std::string& id);
std::vector<CYSFReflector*>& current();
void clock(unsigned int ms);
private:
@ -63,6 +65,7 @@ private:
CUDPSocket m_socket;
std::vector<CYSFReflector*> m_reflectors;
std::vector <CYSFReflector*>::iterator m_it;
std::vector<CYSFReflector*> m_current;
CTimer m_timer;
};

@ -200,6 +200,8 @@ void CWiresX::processDX()
void CWiresX::processAll()
{
::LogDebug("Received ALL from %10.10s", m_source + 10U);
m_status = WXSI_ALL;
m_timer.start();
}
@ -504,5 +506,68 @@ void CWiresX::sendDisconnectReply()
void CWiresX::sendAllReply()
{
std::vector<CYSFReflector*>& curr = m_reflectors.current();
unsigned char data[1100U];
::memset(data, 0x00U, 1100U);
data[0U] = m_seqNo;
for (unsigned int i = 0U; i < 4U; i++)
data[i + 1U] = ALL_RESP[i];
data[5U] = '2';
data[6U] = '1';
for (unsigned int i = 0U; i < 5U; i++)
data[i + 7U] = m_id.at(i);
for (unsigned int i = 0U; i < 10U; i++)
data[i + 12U] = m_callsign.at(i);
unsigned int total = curr.size();
if (total > 999U) total = 999U;
unsigned int n = curr.size();
if (n > 20U) n = 20U;
::sprintf((char*)(data + 22U), "%03u%03u", n, total);
data[28U] = 0x0DU;
unsigned int offset = 29U;
for (unsigned int j = 0U; j < n; j++, offset += 50U) {
CYSFReflector* refl = curr.at(j);
data[offset + 0U] = '5';
for (unsigned int i = 0U; i < 5U; i++)
data[i + offset + 1U] = refl->m_id.at(i);
for (unsigned int i = 0U; i < 16U; i++)
data[i + offset + 6U] = refl->m_name.at(i);
for (unsigned int i = 0U; i < 3U; i++)
data[i + offset + 22U] = refl->m_count.at(i);
for (unsigned int i = 0U; i < 10U; i++)
data[i + offset + 25U] = ' ';
for (unsigned int i = 0U; i < 14U; i++)
data[i + offset + 35U] = refl->m_desc.at(i);
data[offset + 49U] = 0x0DU;
}
data[offset + 0U] = 0x03U; // End of data marker
data[offset + 1U] = CCRC::addCRC(data, offset + 1U);
unsigned int blocks = (offset + 1U) / 20U;
if ((blocks % 20U) > 0U) blocks++;
CUtils::dump(1U, "ALL Reply", data, blocks * 20U);
createReply(data, blocks * 20U);
m_seqNo++;
}

Loading…
Cancel
Save