1
0
Fork 0

Add callsign display to the reflector.

ycs232-kbc
Jonathan Naylor 9 years ago
parent 3cac3af31e
commit ea61019cba

@ -69,11 +69,48 @@ void CYSFReflector::run()
::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 (;;) {
unsigned char buffer[200U];
unsigned int len = network.readData(buffer);
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);
CYSFRepeater* rpt = findRepeater(callsign);
if (rpt != NULL) {
@ -82,6 +119,11 @@ void CYSFReflector::run()
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
@ -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 defined(_WIN32) || defined(_WIN64)
::Sleep(5UL); // 5ms

Loading…
Cancel
Save