|
|
@ -71,6 +71,7 @@ void CYSFReflector::run()
|
|
|
|
|
|
|
|
|
|
|
|
CTimer watchdogTimer(1000U, 0U, 1500U);
|
|
|
|
CTimer watchdogTimer(1000U, 0U, 1500U);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char tag[YSF_CALLSIGN_LENGTH];
|
|
|
|
unsigned char src[YSF_CALLSIGN_LENGTH];
|
|
|
|
unsigned char src[YSF_CALLSIGN_LENGTH];
|
|
|
|
unsigned char dst[YSF_CALLSIGN_LENGTH];
|
|
|
|
unsigned char dst[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
|
|
|
|
|
|
@ -80,6 +81,8 @@ void CYSFReflector::run()
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
unsigned int len = network.readData(buffer);
|
|
|
|
if (len > 0U) {
|
|
|
|
if (len > 0U) {
|
|
|
|
if (!watchdogTimer.isRunning()) {
|
|
|
|
if (!watchdogTimer.isRunning()) {
|
|
|
|
|
|
|
|
::memcpy(tag, buffer + 4U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -91,38 +94,42 @@ void CYSFReflector::run()
|
|
|
|
::memcpy(dst, "??????????", YSF_CALLSIGN_LENGTH);
|
|
|
|
::memcpy(dst, "??????????", YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
if (::memcmp(tag, buffer + 4U, YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
bool changed = false;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(src, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
if (::memcmp(buffer + 14U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(src, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
::memcpy(src, buffer + 14U, YSF_CALLSIGN_LENGTH);
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (::memcmp(buffer + 24U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(dst, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
if (::memcmp(buffer + 24U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(dst, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
::memcpy(dst, buffer + 24U, YSF_CALLSIGN_LENGTH);
|
|
|
|
::memcpy(dst, buffer + 24U, YSF_CALLSIGN_LENGTH);
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
if (changed)
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
::fprintf(stdout, "Received data from %10.10s to %10.10s at %10.10s\n", src, dst, buffer + 4U);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
watchdogTimer.start();
|
|
|
|
// Only accept transmission from an already accepted repeater
|
|
|
|
|
|
|
|
if (::memcmp(tag, buffer + 4U, YSF_CALLSIGN_LENGTH) == 0) {
|
|
|
|
std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
|
|
|
|
watchdogTimer.start();
|
|
|
|
CYSFRepeater* rpt = findRepeater(callsign);
|
|
|
|
|
|
|
|
if (rpt != NULL) {
|
|
|
|
std::string callsign = std::string((char*)(buffer + 4U), YSF_CALLSIGN_LENGTH);
|
|
|
|
for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
|
|
CYSFRepeater* rpt = findRepeater(callsign);
|
|
|
|
if ((*it)->m_callsign != callsign)
|
|
|
|
if (rpt != NULL) {
|
|
|
|
network.writeData(buffer, (*it)->m_address, (*it)->m_port);
|
|
|
|
for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
|
|
|
|
|
|
|
if ((*it)->m_callsign != callsign)
|
|
|
|
|
|
|
|
network.writeData(buffer, (*it)->m_address, (*it)->m_port);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer[34U] == 0x01U) {
|
|
|
|
if (buffer[34U] == 0x01U) {
|
|
|
|
::fprintf(stdout, "Received end of transmission\n");
|
|
|
|
::fprintf(stdout, "Received end of transmission\n");
|
|
|
|
watchdogTimer.stop();
|
|
|
|
watchdogTimer.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|