1
0
Fork 0

Still need to handle polls and such like.

ycs232-kbc
Jonathan Naylor 7 years ago
parent a52d831ba5
commit 295677878e

@ -54,17 +54,16 @@ CFCSNetwork::~CFCSNetwork()
bool CFCSNetwork::open() bool CFCSNetwork::open()
{ {
m_addresses["FCS001"] = CUDPSocket::lookup("fcs001.xreflector.net");
m_addresses["FCS002"] = CUDPSocket::lookup("fcs002.xreflector.net");
m_addresses["FCS003"] = CUDPSocket::lookup("fcs003.xreflector.net");
m_addresses["FCS004"] = CUDPSocket::lookup("fcs004.xreflector.net");
LogMessage("Opening FCS network connection"); LogMessage("Opening FCS network connection");
return m_socket.open(); return m_socket.open();
} }
void CFCSNetwork::setDestination(const in_addr& address, unsigned int port)
{
m_address = address;
m_port = port;
}
void CFCSNetwork::clearDestination() void CFCSNetwork::clearDestination()
{ {
m_address.s_addr = INADDR_NONE; m_address.s_addr = INADDR_NONE;
@ -91,8 +90,17 @@ bool CFCSNetwork::write(const unsigned char* data)
bool CFCSNetwork::writeLink(const std::string& reflector) bool CFCSNetwork::writeLink(const std::string& reflector)
{ {
if (m_port == 0U) m_port = 0U;
return true;
if (m_addresses.count(reflector) == 0U)
return false;
m_address = m_addresses[reflector];
if (m_address.s_addr == INADDR_NONE)
return false;
m_port = FCS_PORT;
m_reflector = reflector; m_reflector = reflector;
m_reflector.resize(8U, ' '); m_reflector.resize(8U, ' ');

@ -25,6 +25,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <map>
class CFCSNetwork { class CFCSNetwork {
public: public:
@ -33,7 +34,6 @@ public:
bool open(); bool open();
void setDestination(const in_addr& address, unsigned int port);
void clearDestination(); void clearDestination();
bool write(const unsigned char* data); bool write(const unsigned char* data);
@ -49,14 +49,15 @@ public:
void close(); void close();
private: private:
CUDPSocket m_socket; CUDPSocket m_socket;
bool m_debug; bool m_debug;
in_addr m_address; in_addr m_address;
unsigned int m_port; unsigned int m_port;
unsigned char* m_info; unsigned char* m_info;
std::string m_callsign; std::string m_callsign;
std::string m_reflector; std::string m_reflector;
CRingBuffer<unsigned char> m_buffer; CRingBuffer<unsigned char> m_buffer;
std::map<std::string, in_addr> m_addresses;
void writeInfo(); void writeInfo();
}; };

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -47,4 +47,6 @@ const unsigned char YSF_CM_INDIVIDUAL = 0x03U;
const unsigned char YSF_MR_NOT_BUSY = 0x01U; const unsigned char YSF_MR_NOT_BUSY = 0x01U;
const unsigned char YSF_MR_BUSY = 0x02U; const unsigned char YSF_MR_BUSY = 0x02U;
const unsigned int FCS_PORT = 62500U;
#endif #endif

@ -397,6 +397,9 @@ int CYSFGateway::run()
if (m_wiresX != NULL) if (m_wiresX != NULL)
m_wiresX->processDisconnect(); m_wiresX->processDisconnect();
if (m_fcsNetwork != NULL)
m_fcsNetwork->clearDestination();
if (m_ysfNetwork != NULL) if (m_ysfNetwork != NULL)
m_ysfNetwork->clearDestination(); m_ysfNetwork->clearDestination();
@ -556,6 +559,12 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt)
m_ysfNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
m_ysfNetwork->writeUnlink(); m_ysfNetwork->writeUnlink();
} }
if (m_linkType == LINK_FCS) {
m_fcsNetwork->writeUnlink();
m_fcsNetwork->writeUnlink();
m_fcsNetwork->writeUnlink();
m_fcsNetwork->clearDestination();
}
LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U); LogMessage("Connect via DTMF to %5.5s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U);
@ -572,6 +581,38 @@ void CYSFGateway::processDTMF(const unsigned char* buffer, unsigned char dt)
} }
} }
break; 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);
if (m_linkType == LINK_YSF) {
m_ysfNetwork->writeUnlink();
m_ysfNetwork->writeUnlink();
m_ysfNetwork->writeUnlink();
m_ysfNetwork->clearDestination();
m_ysfPollTimer.stop();
}
if (m_linkType == LINK_FCS) {
m_fcsNetwork->writeUnlink();
m_fcsNetwork->writeUnlink();
m_fcsNetwork->writeUnlink();
}
LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U);
m_fcsNetwork->writeLink(id);
m_fcsNetwork->writeLink(id);
m_fcsNetwork->writeLink(id);
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_FCS;
}
break;
case WXS_DISCONNECT: case WXS_DISCONNECT:
if (m_linkType == LINK_YSF) { if (m_linkType == LINK_YSF) {
if (m_wiresX != NULL) if (m_wiresX != NULL)

Loading…
Cancel
Save