|
|
@ -69,11 +69,48 @@ void CYSFReflector::run()
|
|
|
|
|
|
|
|
|
|
|
|
::fprintf(stdout, "Starting YSFReflector-%s\n", VERSION);
|
|
|
|
::fprintf(stdout, "Starting YSFReflector-%s\n", VERSION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CTimer watchdogTimer(1000U, 0U, 1500U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char src[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
|
|
|
unsigned char dst[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
unsigned char buffer[200U];
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
if (len > 0U) {
|
|
|
|
if (len > 0U) {
|
|
|
|
|
|
|
|
if (!watchdogTimer.isRunning()) {
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
|
|
|
|
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
::memcpy(src, "??????????", YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 24U, " ", YSF_CALLSIGN_LENGTH) != 0)
|
|
|
|
|
|
|
|
::memcpy(dst, buffer + 24U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
::memcpy(dst, "??????????", YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(src, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 24U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(dst, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
|
|
|
|
::memcpy(dst, buffer + 24U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watchdogTimer.start();
|
|
|
|
|
|
|
|
|
|
|
|
std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
|
|
|
|
std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
|
|
|
|
CYSFRepeater* rpt = findRepeater(callsign);
|
|
|
|
CYSFRepeater* rpt = findRepeater(callsign);
|
|
|
|
if (rpt != NULL) {
|
|
|
|
if (rpt != NULL) {
|
|
|
@ -82,6 +119,11 @@ void CYSFReflector::run()
|
|
|
|
network.writeData(buffer, (*it)->m_address, (*it)->m_port);
|
|
|
|
network.writeData(buffer, (*it)->m_address, (*it)->m_port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer[34U] == 0x01U) {
|
|
|
|
|
|
|
|
::fprintf(stdout, "Received end of transmission\n");
|
|
|
|
|
|
|
|
watchdogTimer.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Refresh/add repeaters based on their polls
|
|
|
|
// Refresh/add repeaters based on their polls
|
|
|
@ -130,6 +172,12 @@ void CYSFReflector::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watchdogTimer.clock(ms);
|
|
|
|
|
|
|
|
if (watchdogTimer.isRunning() && watchdogTimer.hasExpired()) {
|
|
|
|
|
|
|
|
::fprintf(stdout, "Watchdog has expired\n");
|
|
|
|
|
|
|
|
watchdogTimer.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ms < 5U) {
|
|
|
|
if (ms < 5U) {
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
::Sleep(5UL); // 5ms
|
|
|
|
::Sleep(5UL); // 5ms
|
|
|
|