Bug fixes mostly,
This commit is contained in:
parent
64db730870
commit
c17ffdbb89
4 changed files with 46 additions and 50 deletions
|
@ -167,30 +167,27 @@ WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end)
|
|||
WX_STATUS CDTMF::validate() const
|
||||
{
|
||||
size_t length = m_command.length();
|
||||
if (length != 3U && length != 4U && length != 6U)
|
||||
return WXS_NONE;
|
||||
|
||||
char first = m_command.at(0U);
|
||||
if (first != '#' && first != 'A')
|
||||
return WXS_NONE;
|
||||
|
||||
if (length == 3U) {
|
||||
for (unsigned int i = 1U; i <= 3U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
if (length == 1U && first == '#') {
|
||||
return WXS_DISCONNECT;
|
||||
} else if (length == 3U && first == 'A') {
|
||||
for (unsigned int i = 1U; i < 3U; i++) {
|
||||
if (m_command.at(i) < '0' || m_command.at(i) > '9')
|
||||
return WXS_NONE;
|
||||
}
|
||||
|
||||
return WXS_CONNECT_FCS;
|
||||
} else if (length == 4U) {
|
||||
for (unsigned int i = 1U; i <= 4U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
} else if (length == 4U && first == 'A') {
|
||||
for (unsigned int i = 1U; i < 4U; i++) {
|
||||
if (m_command.at(i) < '0' || m_command.at(i) > '9')
|
||||
return WXS_NONE;
|
||||
}
|
||||
|
||||
return WXS_CONNECT_FCS;
|
||||
} else {
|
||||
for (unsigned int i = 1U; i <= 6U; i++) {
|
||||
if (m_command.at(1U) < '0' || m_command.at(1U) > '9')
|
||||
} else if (length == 6U && first == '#') {
|
||||
for (unsigned int i = 1U; i < 6U; i++) {
|
||||
if (m_command.at(i) < '0' || m_command.at(i) > '9')
|
||||
return WXS_NONE;
|
||||
}
|
||||
|
||||
|
@ -199,6 +196,8 @@ WX_STATUS CDTMF::validate() const
|
|||
|
||||
return WXS_CONNECT_YSF;
|
||||
}
|
||||
|
||||
return WXS_NONE;
|
||||
}
|
||||
|
||||
std::string CDTMF::getReflector()
|
||||
|
|
|
@ -33,13 +33,12 @@ CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigne
|
|||
m_socket(port),
|
||||
m_debug(debug),
|
||||
m_address(),
|
||||
m_port(0U),
|
||||
m_ping(NULL),
|
||||
m_info(NULL),
|
||||
m_reflector(),
|
||||
m_buffer(1000U, "FCS Network Buffer"),
|
||||
m_n(0U),
|
||||
m_pingTimer(1000U, 5U),
|
||||
m_pingTimer(1000U, 0U, 800U),
|
||||
m_state(FCS_UNLINKED)
|
||||
{
|
||||
m_info = new unsigned char[100U];
|
||||
|
@ -73,9 +72,6 @@ bool CFCSNetwork::open()
|
|||
|
||||
void CFCSNetwork::clearDestination()
|
||||
{
|
||||
m_address.s_addr = INADDR_NONE;
|
||||
m_port = 0U;
|
||||
|
||||
m_pingTimer.stop();
|
||||
|
||||
m_state = FCS_UNLINKED;
|
||||
|
@ -85,9 +81,6 @@ void CFCSNetwork::write(const unsigned char* data)
|
|||
{
|
||||
assert(data != NULL);
|
||||
|
||||
if (m_port == 0U)
|
||||
return;
|
||||
|
||||
if (m_state != FCS_LINKED)
|
||||
return;
|
||||
|
||||
|
@ -99,12 +92,12 @@ void CFCSNetwork::write(const unsigned char* data)
|
|||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Sent", buffer, 130U);
|
||||
|
||||
m_socket.write(buffer, 130U, m_address, m_port);
|
||||
m_socket.write(buffer, 130U, m_address, FCS_PORT);
|
||||
}
|
||||
|
||||
bool CFCSNetwork::writeLink(const std::string& reflector)
|
||||
{
|
||||
if (m_port == 0U) {
|
||||
if (m_state != FCS_LINKED) {
|
||||
std::string name = reflector.substr(0U, 6U);
|
||||
if (m_addresses.count(name) == 0U) {
|
||||
LogError("Unknown FCS reflector - %s", name.c_str());
|
||||
|
@ -118,32 +111,25 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
|
|||
}
|
||||
}
|
||||
|
||||
m_port = FCS_PORT;
|
||||
|
||||
m_reflector = reflector;
|
||||
|
||||
::memcpy(m_ping + 10U, m_reflector.c_str(), 8U);
|
||||
|
||||
writePing();
|
||||
m_state = FCS_LINKING;
|
||||
|
||||
m_pingTimer.start();
|
||||
|
||||
m_state = FCS_LINKING;
|
||||
writePing();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFCSNetwork::writeUnlink(unsigned int count)
|
||||
{
|
||||
if (m_port == 0U)
|
||||
if (m_state != FCS_LINKED)
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0U; i < count; i++)
|
||||
m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, m_port);
|
||||
|
||||
m_pingTimer.stop();
|
||||
|
||||
m_state = FCS_UNLINKED;
|
||||
m_socket.write((unsigned char*)"CLOSE ", 11U, m_address, FCS_PORT);
|
||||
}
|
||||
|
||||
void CFCSNetwork::clock(unsigned int ms)
|
||||
|
@ -156,7 +142,7 @@ void CFCSNetwork::clock(unsigned int ms)
|
|||
if (length <= 0)
|
||||
return;
|
||||
|
||||
if (m_port == 0U)
|
||||
if (m_state == FCS_UNLINKED)
|
||||
return;
|
||||
|
||||
m_pingTimer.clock(ms);
|
||||
|
@ -165,18 +151,20 @@ void CFCSNetwork::clock(unsigned int ms)
|
|||
m_pingTimer.start();
|
||||
}
|
||||
|
||||
if (address.s_addr != m_address.s_addr || port != m_port)
|
||||
if (address.s_addr != m_address.s_addr || port != FCS_PORT)
|
||||
return;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Received", buffer, length);
|
||||
|
||||
if (length == 7) {
|
||||
LogMessage("Linked to %s", m_reflector.c_str());
|
||||
m_state = FCS_LINKED;
|
||||
writeInfo();
|
||||
}
|
||||
|
||||
if (length == 10 && m_state == FCS_LINKING) {
|
||||
LogMessage("Linked to %s", m_reflector.c_str());
|
||||
m_state = FCS_LINKED;
|
||||
writeInfo();
|
||||
}
|
||||
|
@ -201,17 +189,22 @@ unsigned int CFCSNetwork::read(unsigned char* data)
|
|||
// Pass pings up to the gateway to reset the lost timer.
|
||||
if (len == 10U) {
|
||||
m_buffer.getData(data, len);
|
||||
return 10U;
|
||||
|
||||
::memset(data + 0U, ' ', 14U);
|
||||
::memcpy(data + 0U, "YSFP", 4U);
|
||||
::memcpy(data + 4U, m_reflector.c_str(), 8U);
|
||||
|
||||
return 14U;
|
||||
}
|
||||
|
||||
unsigned char buffer[130U];
|
||||
m_buffer.getData(buffer, len);
|
||||
|
||||
::memcpy(data + 0U, "YSFDDB0SAT DB0SAT-RPTALL ", 35U);
|
||||
::memcpy(data + 0U, "YSFD ALL ", 35U);
|
||||
::memcpy(data + 35U, buffer, 120U);
|
||||
|
||||
// Put the reflector name as the via callsign.
|
||||
::memcpy(data + 4U, buffer + 121U, 8U);
|
||||
::memcpy(data + 4U, m_reflector.c_str(), 8U);
|
||||
|
||||
data[34U] = m_n;
|
||||
m_n += 2U;
|
||||
|
@ -228,22 +221,22 @@ void CFCSNetwork::close()
|
|||
|
||||
void CFCSNetwork::writeInfo()
|
||||
{
|
||||
if (m_port == 0U)
|
||||
if (m_state != FCS_LINKED)
|
||||
return;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U);
|
||||
|
||||
m_socket.write(m_info, 100U, m_address, m_port);
|
||||
m_socket.write(m_info, 100U, m_address, FCS_PORT);
|
||||
}
|
||||
|
||||
void CFCSNetwork::writePing()
|
||||
{
|
||||
if (m_port == 0U)
|
||||
if (m_state == FCS_UNLINKED)
|
||||
return;
|
||||
|
||||
if (m_debug)
|
||||
CUtils::dump(1U, "FCS Network Data Sent", m_ping, 25U);
|
||||
|
||||
m_socket.write(m_ping, 25U, m_address, m_port);
|
||||
m_socket.write(m_ping, 25U, m_address, FCS_PORT);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ private:
|
|||
CUDPSocket m_socket;
|
||||
bool m_debug;
|
||||
in_addr m_address;
|
||||
unsigned int m_port;
|
||||
unsigned char* m_ping;
|
||||
unsigned char* m_info;
|
||||
std::string m_reflector;
|
||||
|
|
|
@ -564,11 +564,16 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
|
|||
}
|
||||
break;
|
||||
case WXS_CONNECT_FCS: {
|
||||
std::string id = m_dtmf.getReflector();
|
||||
if (id.length() == 2U)
|
||||
id = "FCS00" + id.at(0U) + std::string("0") + id.at(1U);
|
||||
else
|
||||
id = "FCS00" + id.at(0U) + id.at(1U) + id.at(2U);
|
||||
std::string raw = m_dtmf.getReflector();
|
||||
std::string id = "FCS00";
|
||||
if (raw.length() == 2U) {
|
||||
id += raw.at(0U) + std::string("0") + raw.at(1U);
|
||||
} else if (raw.length() == 3U) {
|
||||
id += raw;
|
||||
} else {
|
||||
LogWarning("Nonsense from the DTMF decoder - \"%s\"", raw.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_linkType == LINK_YSF) {
|
||||
m_ysfNetwork->writeUnlink(3U);
|
||||
|
|
Loading…
Reference in a new issue