mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2025-08-02 21:12:27 -04:00
Merge branch 'master' into Kenwood
This commit is contained in:
commit
6afbe5939a
@ -35,7 +35,8 @@ enum SECTION {
|
|||||||
SECTION_LOG,
|
SECTION_LOG,
|
||||||
SECTION_APRS_FI,
|
SECTION_APRS_FI,
|
||||||
SECTION_NETWORK,
|
SECTION_NETWORK,
|
||||||
SECTION_MOBILE_GPS
|
SECTION_MOBILE_GPS,
|
||||||
|
SECTION_REMOTE_COMMANDS
|
||||||
};
|
};
|
||||||
|
|
||||||
CConf::CConf(const std::string& file) :
|
CConf::CConf(const std::string& file) :
|
||||||
@ -82,7 +83,9 @@ m_networkInactivityTimeout(0U),
|
|||||||
m_networkDebug(false),
|
m_networkDebug(false),
|
||||||
m_mobileGPSEnabled(false),
|
m_mobileGPSEnabled(false),
|
||||||
m_mobileGPSAddress(),
|
m_mobileGPSAddress(),
|
||||||
m_mobileGPSPort(0U)
|
m_mobileGPSPort(0U),
|
||||||
|
m_remoteCommandsEnabled(false),
|
||||||
|
m_remoteCommandsPort(6075U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +125,8 @@ bool CConf::read()
|
|||||||
section = SECTION_NETWORK;
|
section = SECTION_NETWORK;
|
||||||
else if (::strncmp(buffer, "[Mobile GPS]", 12U) == 0)
|
else if (::strncmp(buffer, "[Mobile GPS]", 12U) == 0)
|
||||||
section = SECTION_MOBILE_GPS;
|
section = SECTION_MOBILE_GPS;
|
||||||
|
else if (::strncmp(buffer, "[Remote Commands]", 17U) == 0)
|
||||||
|
section = SECTION_REMOTE_COMMANDS;
|
||||||
else
|
else
|
||||||
section = SECTION_NONE;
|
section = SECTION_NONE;
|
||||||
|
|
||||||
@ -233,6 +238,11 @@ bool CConf::read()
|
|||||||
m_mobileGPSAddress = value;
|
m_mobileGPSAddress = value;
|
||||||
else if (::strcmp(key, "Port") == 0)
|
else if (::strcmp(key, "Port") == 0)
|
||||||
m_mobileGPSPort = (unsigned int)::atoi(value);
|
m_mobileGPSPort = (unsigned int)::atoi(value);
|
||||||
|
} else if (section == SECTION_REMOTE_COMMANDS) {
|
||||||
|
if (::strcmp(key, "Enable") == 0)
|
||||||
|
m_remoteCommandsEnabled = ::atoi(value) == 1;
|
||||||
|
else if (::strcmp(key, "Port") == 0)
|
||||||
|
m_remoteCommandsPort = (unsigned int)::atoi(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,3 +466,12 @@ unsigned int CConf::getMobileGPSPort() const
|
|||||||
return m_mobileGPSPort;
|
return m_mobileGPSPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CConf::getRemoteCommandsEnabled() const
|
||||||
|
{
|
||||||
|
return m_remoteCommandsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getRemoteCommandsPort() const
|
||||||
|
{
|
||||||
|
return m_remoteCommandsPort;
|
||||||
|
}
|
||||||
|
@ -85,9 +85,13 @@ public:
|
|||||||
bool getNetworkDebug() const;
|
bool getNetworkDebug() const;
|
||||||
|
|
||||||
// The Mobile GPS section
|
// The Mobile GPS section
|
||||||
bool getMobileGPSEnabled() const;
|
bool getMobileGPSEnabled() const;
|
||||||
std::string getMobileGPSAddress() const;
|
std::string getMobileGPSAddress() const;
|
||||||
unsigned int getMobileGPSPort() const;
|
unsigned int getMobileGPSPort() const;
|
||||||
|
|
||||||
|
// The Remote Commands section
|
||||||
|
bool getRemoteCommandsEnabled() const;
|
||||||
|
unsigned int getRemoteCommandsPort() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_file;
|
std::string m_file;
|
||||||
@ -141,6 +145,9 @@ private:
|
|||||||
bool m_mobileGPSEnabled;
|
bool m_mobileGPSEnabled;
|
||||||
std::string m_mobileGPSAddress;
|
std::string m_mobileGPSAddress;
|
||||||
unsigned int m_mobileGPSPort;
|
unsigned int m_mobileGPSPort;
|
||||||
|
|
||||||
|
bool m_remoteCommandsEnabled;
|
||||||
|
unsigned int m_remoteCommandsPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
@ -202,6 +203,16 @@ void CNXDNGateway::run()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUDPSocket* remoteSocket = NULL;
|
||||||
|
if (m_conf.getRemoteCommandsEnabled()) {
|
||||||
|
remoteSocket = new CUDPSocket(m_conf.getRemoteCommandsPort());
|
||||||
|
ret = remoteSocket->open();
|
||||||
|
if (!ret) {
|
||||||
|
delete remoteSocket;
|
||||||
|
remoteSocket = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CReflectors reflectors(m_conf.getNetworkHosts1(), m_conf.getNetworkHosts2(), m_conf.getNetworkReloadTime());
|
CReflectors reflectors(m_conf.getNetworkHosts1(), m_conf.getNetworkHosts2(), m_conf.getNetworkReloadTime());
|
||||||
if (m_conf.getNetworkParrotPort() > 0U)
|
if (m_conf.getNetworkParrotPort() > 0U)
|
||||||
reflectors.setParrot(m_conf.getNetworkParrotAddress(), m_conf.getNetworkParrotPort());
|
reflectors.setParrot(m_conf.getNetworkParrotAddress(), m_conf.getNetworkParrotPort());
|
||||||
@ -257,7 +268,7 @@ void CNXDNGateway::run()
|
|||||||
|
|
||||||
LogMessage("Linked at startup to reflector %u", currentId);
|
LogMessage("Linked at startup to reflector %u", currentId);
|
||||||
} else {
|
} else {
|
||||||
startupId = 9999U;
|
startupId = 9999U;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +403,79 @@ startupId = 9999U;
|
|||||||
localNetwork->write(buffer, length);
|
localNetwork->write(buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remoteSocket != NULL) {
|
||||||
|
int res = remoteSocket->read(buffer, 200U, address, port);
|
||||||
|
if (res > 0) {
|
||||||
|
buffer[res] = '\0';
|
||||||
|
if (::memcmp(buffer + 0U, "TalkGroup", 9U) == 0) {
|
||||||
|
unsigned int tg = (unsigned int)::atoi((char*)(buffer + 9U));
|
||||||
|
|
||||||
|
CNXDNReflector* reflector = NULL;
|
||||||
|
if (tg != 9999U)
|
||||||
|
reflector = reflectors.find(tg);
|
||||||
|
|
||||||
|
if (reflector == NULL && currentId != 9999U) {
|
||||||
|
LogMessage("Unlinked from reflector %u by remote command", currentId);
|
||||||
|
|
||||||
|
if (voice != NULL)
|
||||||
|
voice->unlinked();
|
||||||
|
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
|
inactivityTimer.stop();
|
||||||
|
pollTimer.stop();
|
||||||
|
lostTimer.stop();
|
||||||
|
|
||||||
|
currentId = 9999U;
|
||||||
|
} else if (reflector != NULL && currentId == 9999U) {
|
||||||
|
currentId = tg;
|
||||||
|
currentAddr = reflector->m_address;
|
||||||
|
currentPort = reflector->m_port;
|
||||||
|
|
||||||
|
LogMessage("Linked to reflector %u by remote command", currentId);
|
||||||
|
|
||||||
|
if (voice != NULL)
|
||||||
|
voice->linkedTo(currentId);
|
||||||
|
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
|
inactivityTimer.start();
|
||||||
|
pollTimer.start();
|
||||||
|
lostTimer.start();
|
||||||
|
} else if (reflector != NULL && currentId != 9999U) {
|
||||||
|
LogMessage("Unlinked from reflector %u by remote command", currentId);
|
||||||
|
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writeUnlink(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
|
currentId = tg;
|
||||||
|
currentAddr = reflector->m_address;
|
||||||
|
currentPort = reflector->m_port;
|
||||||
|
|
||||||
|
LogMessage("Linked to reflector %u by remote command", currentId);
|
||||||
|
|
||||||
|
if (voice != NULL)
|
||||||
|
voice->linkedTo(currentId);
|
||||||
|
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
remoteNetwork.writePoll(currentAddr, currentPort, currentId);
|
||||||
|
|
||||||
|
inactivityTimer.start();
|
||||||
|
pollTimer.start();
|
||||||
|
lostTimer.start();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CUtils::dump("Invalid remote command received", buffer, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int ms = stopWatch.elapsed();
|
unsigned int ms = stopWatch.elapsed();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
@ -482,6 +566,11 @@ startupId = 9999U;
|
|||||||
localNetwork->close();
|
localNetwork->close();
|
||||||
delete localNetwork;
|
delete localNetwork;
|
||||||
|
|
||||||
|
if (remoteSocket != NULL) {
|
||||||
|
remoteSocket->close();
|
||||||
|
delete remoteSocket;
|
||||||
|
}
|
||||||
|
|
||||||
remoteNetwork.close();
|
remoteNetwork.close();
|
||||||
|
|
||||||
lookup->stop();
|
lookup->stop();
|
||||||
|
@ -58,3 +58,6 @@ Enable=0
|
|||||||
Address=127.0.0.1
|
Address=127.0.0.1
|
||||||
Port=7834
|
Port=7834
|
||||||
|
|
||||||
|
[Remote Commands]
|
||||||
|
Enable=0
|
||||||
|
Port=6075
|
||||||
|
Loading…
x
Reference in New Issue
Block a user