Pass through the MMDVM's home position to all connected networks.

This commit is contained in:
Jonathan Naylor
2018-10-30 07:42:04 +00:00
parent 6aa09f735e
commit 0c31af146c
6 changed files with 82 additions and 27 deletions

View File

@@ -849,16 +849,16 @@ int CDMRGateway::run()
unsigned char buffer[50U];
unsigned int length;
ret = m_repeater->readPosition(buffer, length);
ret = m_repeater->readRadioPosition(buffer, length);
if (ret) {
if (m_xlxNetwork != NULL)
m_xlxNetwork->writePosition(buffer, length);
m_xlxNetwork->writeRadioPosition(buffer, length);
if (m_dmrNetwork1 != NULL)
m_dmrNetwork1->writePosition(buffer, length);
m_dmrNetwork1->writeRadioPosition(buffer, length);
if (m_dmrNetwork2 != NULL)
m_dmrNetwork2->writePosition(buffer, length);
m_dmrNetwork2->writeRadioPosition(buffer, length);
if (m_dmrNetwork3 != NULL)
m_dmrNetwork3->writePosition(buffer, length);
m_dmrNetwork3->writeRadioPosition(buffer, length);
}
ret = m_repeater->readTalkerAlias(buffer, length);
if (ret) {
@@ -871,6 +871,17 @@ int CDMRGateway::run()
if (m_dmrNetwork3 != NULL)
m_dmrNetwork3->writeTalkerAlias(buffer, length);
}
ret = m_repeater->readHomePosition(buffer, length);
if (ret) {
if (m_xlxNetwork != NULL)
m_xlxNetwork->writeHomePosition(buffer, length);
if (m_dmrNetwork1 != NULL)
m_dmrNetwork1->writeHomePosition(buffer, length);
if (m_dmrNetwork2 != NULL)
m_dmrNetwork2->writeHomePosition(buffer, length);
if (m_dmrNetwork3 != NULL)
m_dmrNetwork3->writeHomePosition(buffer, length);
}
if (voice != NULL) {
ret = voice->read(data);

View File

@@ -228,7 +228,7 @@ bool CDMRNetwork::write(const CDMRData& data)
return true;
}
bool CDMRNetwork::writePosition(const unsigned char* data, unsigned int length)
bool CDMRNetwork::writeRadioPosition(const unsigned char* data, unsigned int length)
{
if (m_status != RUNNING)
return false;
@@ -260,6 +260,22 @@ bool CDMRNetwork::writeTalkerAlias(const unsigned char* data, unsigned int lengt
return write(buffer, length);
}
bool CDMRNetwork::writeHomePosition(const unsigned char* data, unsigned int length)
{
if (m_status != RUNNING)
return false;
unsigned char buffer[50U];
::memcpy(buffer + 0U, "RPTG", 4U);
::memcpy(buffer + 4U, m_id, 4U);
::memcpy(buffer + 8U, data + 8U, length - 8U);
return write(buffer, length);
}
bool CDMRNetwork::isConnected() const
{
return m_status == RUNNING;

View File

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

View File

@@ -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
* it under the terms of the GNU General Public License as published by
@@ -43,10 +43,12 @@ m_rxData(1000U, "MMDVM Network"),
m_options(),
m_configData(NULL),
m_configLen(0U),
m_positionData(NULL),
m_positionLen(0U),
m_radioPositionData(NULL),
m_radioPositionLen(0U),
m_talkerAliasData(NULL),
m_talkerAliasLen(0U)
m_talkerAliasLen(0U),
m_homePositionData(NULL),
m_homePositionLen(0U)
{
assert(!rptAddress.empty());
assert(rptPort > 0U);
@@ -56,8 +58,9 @@ m_talkerAliasLen(0U)
m_buffer = new unsigned char[BUFFER_LENGTH];
m_netId = new unsigned char[4U];
m_positionData = new unsigned char[50U];
m_talkerAliasData = new unsigned char[50U];
m_radioPositionData = new unsigned char[50U];
m_talkerAliasData = new unsigned char[50U];
m_homePositionData = new unsigned char[50U];
CStopWatch stopWatch;
::srand(stopWatch.start());
@@ -68,8 +71,9 @@ CMMDVMNetwork::~CMMDVMNetwork()
delete[] m_netId;
delete[] m_buffer;
delete[] m_configData;
delete[] m_positionData;
delete[] m_radioPositionData;
delete[] m_talkerAliasData;
delete[] m_homePositionData;
}
std::string CMMDVMNetwork::getOptions() const
@@ -218,15 +222,15 @@ bool CMMDVMNetwork::write(const CDMRData& data)
return true;
}
bool CMMDVMNetwork::readPosition(unsigned char* data, unsigned int& length)
bool CMMDVMNetwork::readRadioPosition(unsigned char* data, unsigned int& length)
{
if (m_positionLen == 0U)
if (m_radioPositionLen == 0U)
return false;
::memcpy(data, m_positionData, m_positionLen);
length = m_positionLen;
::memcpy(data, m_radioPositionData, m_radioPositionLen);
length = m_radioPositionLen;
m_positionLen = 0U;
m_radioPositionLen = 0U;
return true;
}
@@ -244,6 +248,19 @@ bool CMMDVMNetwork::readTalkerAlias(unsigned char* data, unsigned int& length)
return true;
}
bool CMMDVMNetwork::readHomePosition(unsigned char* data, unsigned int& length)
{
if (m_homePositionLen == 0U)
return false;
::memcpy(data, m_homePositionData, m_homePositionLen);
length = m_homePositionLen;
m_homePositionLen = 0U;
return true;
}
bool CMMDVMNetwork::writeBeacon()
{
unsigned char buffer[20U];
@@ -291,11 +308,14 @@ void CMMDVMNetwork::clock(unsigned int ms)
m_rxData.addData(&len, 1U);
m_rxData.addData(m_buffer, len);
} else if (::memcmp(m_buffer, "DMRG", 4U) == 0) {
::memcpy(m_positionData, m_buffer, length);
m_positionLen = length;
::memcpy(m_radioPositionData, m_buffer, length);
m_radioPositionLen = length;
} else if (::memcmp(m_buffer, "DMRA", 4U) == 0) {
::memcpy(m_talkerAliasData, m_buffer, length);
m_talkerAliasLen = length;
} else if (::memcmp(m_buffer, "RPTG", 4U) == 0) {
::memcpy(m_homePositionData, m_buffer, length);
m_homePositionLen = length;
} 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);
::memcpy(m_netId, m_buffer + 4U, 4U);

View File

@@ -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
* it under the terms of the GNU General Public License as published by
@@ -46,10 +46,12 @@ public:
virtual bool write(const CDMRData& data);
virtual bool readPosition(unsigned char* data, unsigned int& length);
virtual bool readRadioPosition(unsigned char* data, unsigned int& length);
virtual bool readTalkerAlias(unsigned char* data, unsigned int& length);
virtual bool readHomePosition(unsigned char* data, unsigned int& length);
virtual bool writeBeacon();
virtual void clock(unsigned int ms);
@@ -68,10 +70,12 @@ private:
std::string m_options;
unsigned char* m_configData;
unsigned int m_configLen;
unsigned char* m_positionData;
unsigned int m_positionLen;
unsigned char* m_radioPositionData;
unsigned int m_radioPositionLen;
unsigned char* m_talkerAliasData;
unsigned int m_talkerAliasLen;
unsigned char* m_homePositionData;
unsigned int m_homePositionLen;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 by Jonathan Naylor G4KLX
* Copyright (C) 2017,2018 by Jonathan Naylor G4KLX
*
* 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
@@ -39,10 +39,12 @@ public:
virtual bool write(const CDMRData& data) = 0;
virtual bool readPosition(unsigned char* data, unsigned int& length) = 0;
virtual bool readRadioPosition(unsigned char* data, unsigned int& length) = 0;
virtual bool readTalkerAlias(unsigned char* data, unsigned int& length) = 0;
virtual bool readHomePosition(unsigned char* data, unsigned int& length) = 0;
virtual void clock(unsigned int ms) = 0;
virtual bool writeBeacon() = 0;