From a07e002c2b6ec8992456bb5ee61d7e70fdbd2ef5 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Fri, 22 Mar 2019 09:29:07 +0000 Subject: [PATCH] Pass DMR interrupt packets through. --- DMRGateway.cpp | 15 ++++++++++++++- DMRNetwork.cpp | 18 +++++++++++++++++- DMRNetwork.h | 4 +++- MMDVMNetwork.cpp | 24 ++++++++++++++++++++++-- MMDVMNetwork.h | 6 +++++- RepeaterProtocol.h | 4 +++- 6 files changed, 64 insertions(+), 7 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 6b6c4e2..1d83be9 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2019 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 @@ -992,6 +992,19 @@ int CDMRGateway::run() if (m_dmrNetwork4 != NULL) m_dmrNetwork4->writeHomePosition(buffer, length); } + ret = m_repeater->readInterrupt(buffer, length); + if (ret) { + if (m_xlxNetwork != NULL) + m_xlxNetwork->writeInterrupt(buffer, length); + if (m_dmrNetwork1 != NULL) + m_dmrNetwork1->writeInterrupt(buffer, length); + if (m_dmrNetwork2 != NULL) + m_dmrNetwork2->writeInterrupt(buffer, length); + if (m_dmrNetwork3 != NULL) + m_dmrNetwork3->writeInterrupt(buffer, length); + if (m_dmrNetwork4 != NULL) + m_dmrNetwork4->writeInterrupt(buffer, length); + } if (voice != NULL) { ret = voice->read(data); diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 724c4b4..eba8d35 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2019 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 @@ -276,6 +276,22 @@ bool CDMRNetwork::writeHomePosition(const unsigned char* data, unsigned int leng return write(buffer, length); } +bool CDMRNetwork::writeInterrupt(const unsigned char* data, unsigned int length) +{ + if (m_status != RUNNING) + return false; + + unsigned char buffer[50U]; + + ::memcpy(buffer + 0U, "RPTINTR", 7U); + + ::memcpy(buffer + 7U, m_id, 4U); + + ::memcpy(buffer + 11U, data + 11U, length - 11U); + + return write(buffer, length); +} + bool CDMRNetwork::isConnected() const { return m_status == RUNNING; diff --git a/DMRNetwork.h b/DMRNetwork.h index 458d8df..0059237 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2019 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 @@ -49,6 +49,8 @@ public: bool writeHomePosition(const unsigned char* data, unsigned int length); + bool writeInterrupt(const unsigned char* data, unsigned int length); + bool wantsBeacon(); void clock(unsigned int ms); diff --git a/MMDVMNetwork.cpp b/MMDVMNetwork.cpp index 1bc1d78..07c821f 100644 --- a/MMDVMNetwork.cpp +++ b/MMDVMNetwork.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2019 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 @@ -48,7 +48,9 @@ m_radioPositionLen(0U), m_talkerAliasData(NULL), m_talkerAliasLen(0U), m_homePositionData(NULL), -m_homePositionLen(0U) +m_homePositionLen(0U), +m_interruptData(NULL), +m_interruptLen(0U) { assert(!rptAddress.empty()); assert(rptPort > 0U); @@ -61,6 +63,7 @@ m_homePositionLen(0U) m_radioPositionData = new unsigned char[50U]; m_talkerAliasData = new unsigned char[50U]; m_homePositionData = new unsigned char[50U]; + m_interruptData = new unsigned char[50U]; CStopWatch stopWatch; ::srand(stopWatch.start()); @@ -74,6 +77,7 @@ CMMDVMNetwork::~CMMDVMNetwork() delete[] m_radioPositionData; delete[] m_talkerAliasData; delete[] m_homePositionData; + delete[] m_interruptData; } std::string CMMDVMNetwork::getOptions() const @@ -261,6 +265,19 @@ bool CMMDVMNetwork::readHomePosition(unsigned char* data, unsigned int& length) return true; } +bool CMMDVMNetwork::readInterrupt(unsigned char* data, unsigned int& length) +{ + if (m_interruptLen == 0U) + return false; + + ::memcpy(data, m_interruptData, m_interruptLen); + length = m_interruptLen; + + m_interruptLen = 0U; + + return true; +} + bool CMMDVMNetwork::writeBeacon() { unsigned char buffer[20U]; @@ -316,6 +333,9 @@ void CMMDVMNetwork::clock(unsigned int ms) } else if (::memcmp(m_buffer, "RPTG", 4U) == 0) { ::memcpy(m_homePositionData, m_buffer, length); m_homePositionLen = length; + } else if (::memcmp(m_buffer, "RPTINTR", 7U) == 0) { + ::memcpy(m_interruptData, m_buffer, length); + m_interruptLen = 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); diff --git a/MMDVMNetwork.h b/MMDVMNetwork.h index 39320c8..6eaa019 100644 --- a/MMDVMNetwork.h +++ b/MMDVMNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2015-2019 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 @@ -52,6 +52,8 @@ public: virtual bool readHomePosition(unsigned char* data, unsigned int& length); + virtual bool readInterrupt(unsigned char* data, unsigned int& length); + virtual bool writeBeacon(); virtual void clock(unsigned int ms); @@ -76,6 +78,8 @@ private: unsigned int m_talkerAliasLen; unsigned char* m_homePositionData; unsigned int m_homePositionLen; + unsigned char* m_interruptData; + unsigned int m_interruptLen; }; #endif diff --git a/RepeaterProtocol.h b/RepeaterProtocol.h index 9e52a40..3c8a1a1 100644 --- a/RepeaterProtocol.h +++ b/RepeaterProtocol.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2017,2018 by Jonathan Naylor G4KLX +* Copyright (C) 2017,2018,2019 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 @@ -45,6 +45,8 @@ public: virtual bool readHomePosition(unsigned char* data, unsigned int& length) = 0; + virtual bool readInterrupt(unsigned char* data, unsigned int& length) = 0; + virtual void clock(unsigned int ms) = 0; virtual bool writeBeacon() = 0;