Pass through new GPS and TA data.

This commit is contained in:
Jonathan Naylor
2017-05-17 18:58:46 +01:00
parent 5eff056ed0
commit 90f5e17be9
8 changed files with 115 additions and 6 deletions

View File

@@ -474,6 +474,27 @@ int CDMRGateway::run()
} }
} }
unsigned char buffer[50U];
unsigned int length;
ret = m_repeater->readPosition(buffer, length);
if (ret) {
if (m_xlxNetwork != NULL)
m_xlxNetwork->writePosition(buffer, length);
if (m_dmrNetwork1 != NULL)
m_dmrNetwork1->writePosition(buffer, length);
if (m_dmrNetwork2 != NULL)
m_dmrNetwork2->writePosition(buffer, length);
}
ret = m_repeater->readTalkerAlias(buffer, length);
if (ret) {
if (m_xlxNetwork != NULL)
m_xlxNetwork->writeTalkerAlias(buffer, length);
if (m_dmrNetwork1 != NULL)
m_dmrNetwork1->writeTalkerAlias(buffer, length);
if (m_dmrNetwork2 != NULL)
m_dmrNetwork2->writeTalkerAlias(buffer, length);
}
if (voice != NULL) { if (voice != NULL) {
ret = voice->read(data); ret = voice->read(data);
if (ret) { if (ret) {

View File

@@ -37,9 +37,9 @@ Address=44.131.4.1
Port=62031 Port=62031
# Local=3352 # Local=3352
# Local cluster # Local cluster
TGRewrite=1,9,1,9 TGRewrite=1,9,1,9,1
# Reflector TG on to slot 2 TG9 # Reflector TG on to slot 2 TG9
TGRewrite=2,9,2,9 TGRewrite=2,9,2,9,1
# Reflector control command slot 2 94000->4000 to 95000->5000 # Reflector control command slot 2 94000->4000 to 95000->5000
PCRewrite=2,94000,2,4000,1001 PCRewrite=2,94000,2,4000,1001
# Echo on slot 1 9990 # Echo on slot 1 9990
@@ -56,7 +56,7 @@ Address=44.131.4.1
Port=55555 Port=55555
# Local=3352 # Local=3352
# Reflector TG on to slot 2 TG8 # Reflector TG on to slot 2 TG8
TGRewrite=2,8,2,9 TGRewrite=2,8,2,9,1
# Echo on slot 2 TG9990 # Echo on slot 2 TG9990
TGRewrite=2,9990,2,9990,1 TGRewrite=2,9990,2,9990,1
# Reflector control command slot 2 84000->4000 to 85000->5000 # Reflector control command slot 2 84000->4000 to 85000->5000

View File

@@ -226,6 +226,38 @@ bool CDMRNetwork::write(const CDMRData& data)
return true; return true;
} }
bool CDMRNetwork::writePosition(const unsigned char* data, unsigned int length)
{
if (m_status != RUNNING)
return false;
unsigned char buffer[50U];
::memcpy(buffer + 0U, "DMRG", 4U);
::memcpy(buffer + 4U, m_id, 4U);
::memcpy(buffer + 8U, data + 8U, length - 8U);
return write(buffer, length);
}
bool CDMRNetwork::writeTalkerAlias(const unsigned char* data, unsigned int length)
{
if (m_status != RUNNING)
return false;
unsigned char buffer[50U];
::memcpy(buffer + 0U, "DMRA", 4U);
::memcpy(buffer + 4U, m_id, 4U);
::memcpy(buffer + 8U, data + 8U, length - 8U);
return write(buffer, length);
}
void CDMRNetwork::close() void CDMRNetwork::close()
{ {
LogMessage("%s, Closing DMR Network", m_name); LogMessage("%s, Closing DMR Network", m_name);

View File

@@ -43,6 +43,10 @@ public:
bool write(const CDMRData& data); bool write(const CDMRData& data);
bool writePosition(const unsigned char* data, unsigned int length);
bool writeTalkerAlias(const unsigned char* data, unsigned int length);
bool wantsBeacon(); bool wantsBeacon();
void clock(unsigned int ms); void clock(unsigned int ms);

View File

@@ -42,7 +42,11 @@ m_buffer(NULL),
m_rxData(1000U, "MMDVM Network"), m_rxData(1000U, "MMDVM Network"),
m_options(), m_options(),
m_configData(NULL), m_configData(NULL),
m_configLen(0U) m_configLen(0U),
m_positionData(NULL),
m_positionLen(0U),
m_talkerAliasData(NULL),
m_talkerAliasLen(0U)
{ {
assert(!rptAddress.empty()); assert(!rptAddress.empty());
assert(rptPort > 0U); assert(rptPort > 0U);
@@ -52,6 +56,9 @@ m_configLen(0U)
m_buffer = new unsigned char[BUFFER_LENGTH]; m_buffer = new unsigned char[BUFFER_LENGTH];
m_netId = new unsigned char[4U]; m_netId = new unsigned char[4U];
m_positionData = new unsigned char[50U];
m_talkerAliasData = new unsigned char[50U];
CStopWatch stopWatch; CStopWatch stopWatch;
::srand(stopWatch.start()); ::srand(stopWatch.start());
} }
@@ -61,6 +68,8 @@ CMMDVMNetwork::~CMMDVMNetwork()
delete[] m_netId; delete[] m_netId;
delete[] m_buffer; delete[] m_buffer;
delete[] m_configData; delete[] m_configData;
delete[] m_positionData;
delete[] m_talkerAliasData;
} }
std::string CMMDVMNetwork::getOptions() const std::string CMMDVMNetwork::getOptions() const
@@ -209,6 +218,32 @@ bool CMMDVMNetwork::write(const CDMRData& data)
return true; return true;
} }
bool CMMDVMNetwork::readPosition(unsigned char* data, unsigned int& length)
{
if (m_positionLen == 0U)
return false;
::memcpy(data, m_positionData, m_positionLen);
length = m_positionLen;
m_positionLen = 0U;
return true;
}
bool CMMDVMNetwork::readTalkerAlias(unsigned char* data, unsigned int& length)
{
if (m_talkerAliasLen == 0U)
return false;
::memcpy(data, m_talkerAliasData, m_talkerAliasLen);
length = m_talkerAliasLen;
m_talkerAliasLen = 0U;
return true;
}
void CMMDVMNetwork::close() void CMMDVMNetwork::close()
{ {
LogMessage("DMR, Closing MMDVM Network"); LogMessage("DMR, Closing MMDVM Network");
@@ -239,6 +274,12 @@ void CMMDVMNetwork::clock(unsigned int ms)
unsigned char len = length; unsigned char len = length;
m_rxData.addData(&len, 1U); m_rxData.addData(&len, 1U);
m_rxData.addData(m_buffer, len); m_rxData.addData(m_buffer, len);
} else if (::memcmp(m_buffer, "DMRG", 4U) == 0) {
::memcpy(m_positionData, m_buffer, length);
m_positionLen = length;
} else if (::memcmp(m_buffer, "DMRA", 4U) == 0) {
::memcpy(m_talkerAliasData, m_buffer, length);
m_talkerAliasLen = length;
} else if (::memcmp(m_buffer, "RPTL", 4U) == 0) { } else if (::memcmp(m_buffer, "RPTL", 4U) == 0) {
m_id = (m_buffer[4U] << 24) | (m_buffer[5U] << 16) | (m_buffer[6U] << 8) | (m_buffer[7U] << 0); m_id = (m_buffer[4U] << 24) | (m_buffer[5U] << 16) | (m_buffer[6U] << 8) | (m_buffer[7U] << 0);
::memcpy(m_netId, m_buffer + 4U, 4U); ::memcpy(m_netId, m_buffer + 4U, 4U);

View File

@@ -46,6 +46,10 @@ public:
virtual bool write(const CDMRData& data); virtual bool write(const CDMRData& data);
virtual bool readPosition(unsigned char* data, unsigned int& length);
virtual bool readTalkerAlias(unsigned char* data, unsigned int& length);
virtual void clock(unsigned int ms); virtual void clock(unsigned int ms);
virtual void close(); virtual void close();
@@ -62,7 +66,10 @@ private:
std::string m_options; std::string m_options;
unsigned char* m_configData; unsigned char* m_configData;
unsigned int m_configLen; unsigned int m_configLen;
unsigned char* m_positionData;
unsigned int m_positionLen;
unsigned char* m_talkerAliasData;
unsigned int m_talkerAliasLen;
}; };
#endif #endif

View File

@@ -39,6 +39,10 @@ public:
virtual bool write(const CDMRData& data) = 0; virtual bool write(const CDMRData& data) = 0;
virtual bool readPosition(unsigned char* data, unsigned int& length) = 0;
virtual bool readTalkerAlias(unsigned char* data, unsigned int& length) = 0;
virtual void clock(unsigned int ms) = 0; virtual void clock(unsigned int ms) = 0;
virtual void close() = 0; virtual void close() = 0;

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20170516"; const char* VERSION = "20170517";
#endif #endif