1
0
Fork 0

Allow link to reflector at startup.

ycs232-kbc
Jonathan Naylor 8 years ago
parent b2c33793b7
commit dda5ac7c57

@ -64,6 +64,7 @@ m_networkEnabled(false),
m_networkDataPort(0U),
m_networkStatusPort(0U),
m_networkHosts(),
m_networkStartup(),
m_networkDebug(false)
{
}
@ -174,6 +175,8 @@ bool CConf::read()
m_networkStatusPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "Hosts") == 0)
m_networkHosts = value;
else if (::strcmp(key, "Startup") == 0)
m_networkStartup = value;
else if (::strcmp(key, "Debug") == 0)
m_networkDebug = ::atoi(value) == 1;
}
@ -319,6 +322,11 @@ std::string CConf::getNetworkHosts() const
return m_networkHosts;
}
std::string CConf::getNetworkStartup() const
{
return m_networkStartup;
}
bool CConf::getNetworkDebug() const
{
return m_networkDebug;

@ -66,6 +66,7 @@ public:
unsigned int getNetworkDataPort() const;
unsigned int getNetworkStatusPort() const;
std::string getNetworkHosts() const;
std::string getNetworkStartup() const;
bool getNetworkDebug() const;
private:
@ -101,6 +102,7 @@ private:
unsigned int m_networkDataPort;
unsigned int m_networkStatusPort;
std::string m_networkHosts;
std::string m_networkStartup;
bool m_networkDebug;
};

@ -221,6 +221,13 @@ CYSFReflector* CWiresX::getReflector() const
return m_reflector;
}
CYSFReflector* CWiresX::getReflector(const std::string& id)
{
m_reflector = m_reflectors.find(id);
return m_reflector;
}
void CWiresX::processDX(const unsigned char* source)
{
::LogDebug("Received DX from %10.10s", source);

@ -52,6 +52,7 @@ public:
WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft);
CYSFReflector* getReflector() const;
CYSFReflector* getReflector(const std::string& id);
void clock(unsigned int ms);

@ -81,7 +81,9 @@ m_gps(NULL),
m_wiresX(NULL),
m_netNetwork(NULL),
m_linked(false),
m_exclude(false)
m_exclude(false),
m_startupTimer(1000U, 30U),
m_startup()
{
}
@ -204,6 +206,10 @@ int CYSFGateway::run()
m_wiresX->setInfo(name, txFrequency, rxFrequency);
m_wiresX->start();
m_startup = m_conf.getNetworkStartup();
if (!m_startup.empty())
m_startupTimer.start();
}
CStopWatch stopWatch;
@ -239,12 +245,14 @@ int CYSFGateway::run()
CYSFReflector* reflector = m_wiresX->getReflector();
LogMessage("Connect to %5.5s has been requested by %10.10s", reflector->m_id.c_str(), buffer + 14U);
m_netNetwork->setDestination(reflector->m_address, reflector->m_port);
m_startupTimer.stop();
m_linked = true;
}
break;
case WXS_DISCONNECT:
LogMessage("Disconnect has been requested by %10.10s", buffer + 14U);
m_netNetwork->setDestination();
m_startupTimer.stop();
m_linked = false;
break;
default:
@ -291,6 +299,17 @@ int CYSFGateway::run()
m_exclude = false;
}
m_startupTimer.clock(ms);
if (m_startupTimer.isRunning() && m_startupTimer.hasExpired()) {
CYSFReflector* reflector = m_wiresX->getReflector(m_startup);
if (reflector != NULL) {
LogMessage("Automatic connection to %5.5s", reflector->m_id.c_str());
m_netNetwork->setDestination(reflector->m_address, reflector->m_port);
m_startupTimer.stop();
m_linked = true;
}
}
if (ms < 5U)
CThread::sleep(5U);
}

@ -43,6 +43,8 @@ private:
CNetwork* m_netNetwork;
bool m_linked;
bool m_exclude;
CTimer m_startupTimer;
std::string m_startup;
void createGPS();
};

@ -37,4 +37,5 @@ Enable=1
DataPort=42000
StatusPort=42001
Hosts=./YSFHosts.txt
Startup=
Debug=0

Loading…
Cancel
Save