From 5185a0c2459a166a89143e7a05f07123c34d08e1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 15 Feb 2016 18:45:57 +0000 Subject: [PATCH] Renamed DMR protocol files. --- CSBK.cpp => DMRCSBK.cpp | 18 ++-- CSBK.h => DMRCSBK.h | 10 +-- DMRControl.cpp | 6 +- DMRControl.h | 16 ++-- DMREMB.cpp | 100 +++++++++++++++++++++ EMB.h => DMREMB.h | 13 ++- EmbeddedLC.cpp => DMREmbeddedLC.cpp | 20 ++--- EmbeddedLC.h => DMREmbeddedLC.h | 23 +++-- FullLC.cpp => DMRFullLC.cpp | 17 ++-- FullLC.h => DMRFullLC.h | 20 ++--- HomebrewDMRIPSC.cpp => DMRIPSC.cpp | 35 ++++---- HomebrewDMRIPSC.h => DMRIPSC.h | 10 +-- LC.cpp => DMRLC.cpp | 38 ++++---- LC.h => DMRLC.h | 18 ++-- ShortLC.cpp => DMRShortLC.cpp | 26 +++--- ShortLC.h => DMRShortLC.h | 10 +-- DMRSlot.cpp | 129 ++++++++++++---------------- DMRSlot.h | 18 ++-- DMRSlotType.cpp | 92 ++++++++++++++++++++ SlotType.h => DMRSlotType.h | 12 +-- EMB.cpp | 100 --------------------- MMDVMHost.cpp | 2 +- MMDVMHost.h | 22 ++--- MMDVMHost.vcxproj | 36 ++++---- MMDVMHost.vcxproj.filters | 108 +++++++++++------------ Makefile | 7 +- SlotType.cpp | 92 -------------------- DMRSync.cpp => Sync.cpp | 14 +-- DMRSync.h => Sync.h | 14 ++- 29 files changed, 498 insertions(+), 528 deletions(-) rename CSBK.cpp => DMRCSBK.cpp (88%) rename CSBK.h => DMRCSBK.h (92%) create mode 100644 DMREMB.cpp rename EMB.h => DMREMB.h (89%) rename EmbeddedLC.cpp => DMREmbeddedLC.cpp (92%) rename EmbeddedLC.h => DMREmbeddedLC.h (71%) rename FullLC.cpp => DMRFullLC.cpp (89%) rename FullLC.h => DMRFullLC.h (71%) rename HomebrewDMRIPSC.cpp => DMRIPSC.cpp (89%) rename HomebrewDMRIPSC.h => DMRIPSC.h (90%) rename LC.cpp => DMRLC.cpp (80%) rename LC.h => DMRLC.h (83%) rename ShortLC.cpp => DMRShortLC.cpp (89%) rename ShortLC.h => DMRShortLC.h (92%) create mode 100644 DMRSlotType.cpp rename SlotType.h => DMRSlotType.h (86%) delete mode 100644 EMB.cpp delete mode 100644 SlotType.cpp rename DMRSync.cpp => Sync.cpp (86%) rename DMRSync.h => Sync.h (82%) diff --git a/CSBK.cpp b/DMRCSBK.cpp similarity index 88% rename from CSBK.cpp rename to DMRCSBK.cpp index b670a55..db8e938 100644 --- a/CSBK.cpp +++ b/DMRCSBK.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "CSBK.h" +#include "DMRCSBK.h" #include "BPTC19696.h" #include "Utils.h" #include "CRC.h" @@ -24,7 +24,7 @@ #include #include -CCSBK::CCSBK(const unsigned char* bytes) : +CDMRCSBK::CDMRCSBK(const unsigned char* bytes) : m_CSBKO(CSBKO_NONE), m_FID(0x00U), m_bsId(0U), @@ -84,36 +84,36 @@ m_valid(false) } } -CCSBK::~CCSBK() +CDMRCSBK::~CDMRCSBK() { } -bool CCSBK::isValid() const +bool CDMRCSBK::isValid() const { return m_valid; } -CSBKO CCSBK::getCSBKO() const +CSBKO CDMRCSBK::getCSBKO() const { return m_CSBKO; } -unsigned char CCSBK::getFID() const +unsigned char CDMRCSBK::getFID() const { return m_FID; } -unsigned int CCSBK::getBSId() const +unsigned int CDMRCSBK::getBSId() const { return m_bsId; } -unsigned int CCSBK::getSrcId() const +unsigned int CDMRCSBK::getSrcId() const { return m_srcId; } -unsigned int CCSBK::getDstId() const +unsigned int CDMRCSBK::getDstId() const { return m_dstId; } diff --git a/CSBK.h b/DMRCSBK.h similarity index 92% rename from CSBK.h rename to DMRCSBK.h index 40454b9..e583a32 100644 --- a/CSBK.h +++ b/DMRCSBK.h @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(CSBK_H) -#define CSBK_H +#if !defined(DMRCSBK_H) +#define DMRCSBK_H #include "DMRDefines.h" @@ -31,11 +31,11 @@ enum CSBKO { CSBKO_PRECCSBK = 0x3D }; -class CCSBK +class CDMRCSBK { public: - CCSBK(const unsigned char* bytes); - ~CCSBK(); + CDMRCSBK(const unsigned char* bytes); + ~CDMRCSBK(); bool isValid() const; diff --git a/DMRControl.cpp b/DMRControl.cpp index 65d49fd..dd2c60d 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -13,12 +13,12 @@ #include "DMRControl.h" #include "Defines.h" -#include "CSBK.h" +#include "DMRCSBK.h" #include "Log.h" #include -CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CHomebrewDMRIPSC* network, IDisplay* display, bool duplex) : +CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) : m_id(id), m_colorCode(colorCode), m_modem(modem), @@ -42,7 +42,7 @@ bool CDMRControl::processWakeup(const unsigned char* data) if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK)) return false; - CCSBK csbk(data + 2U); + CDMRCSBK csbk(data + 2U); CSBKO csbko = csbk.getCSBKO(); if (csbko != CSBKO_BSDWNACT) diff --git a/DMRControl.h b/DMRControl.h index 440140c..4e08485 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -19,7 +19,7 @@ #if !defined(DMRControl_H) #define DMRControl_H -#include "HomebrewDMRIPSC.h" +#include "DMRIPSC.h" #include "Display.h" #include "DMRSlot.h" #include "DMRData.h" @@ -28,7 +28,7 @@ class CDMRControl { public: - CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CHomebrewDMRIPSC* network, IDisplay* display, bool duplex); + CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex); ~CDMRControl(); bool processWakeup(const unsigned char* data); @@ -42,12 +42,12 @@ public: void clock(unsigned int ms); private: - unsigned int m_id; - unsigned int m_colorCode; - CModem* m_modem; - CHomebrewDMRIPSC* m_network; - CDMRSlot m_slot1; - CDMRSlot m_slot2; + unsigned int m_id; + unsigned int m_colorCode; + CModem* m_modem; + CDMRIPSC* m_network; + CDMRSlot m_slot1; + CDMRSlot m_slot2; }; #endif diff --git a/DMREMB.cpp b/DMREMB.cpp new file mode 100644 index 0000000..f60c7be --- /dev/null +++ b/DMREMB.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015,2016 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "DMREMB.h" + +#include "QR1676.h" + +#include +#include + +CDMREMB::CDMREMB() : +m_colorCode(0U), +m_PI(false), +m_LCSS(0U) +{ +} + +CDMREMB::~CDMREMB() +{ +} + +void CDMREMB::putData(const unsigned char* data) +{ + assert(data != NULL); + + unsigned char DMREMB[2U]; + DMREMB[0U] = (data[13U] << 4) & 0xF0U; + DMREMB[0U] |= (data[14U] >> 4) & 0x0FU; + DMREMB[1U] = (data[18U] << 4) & 0xF0U; + DMREMB[1U] |= (data[19U] >> 4) & 0x0FU; + + CQR1676::decode(DMREMB); + + m_colorCode = (DMREMB[0U] >> 4) & 0x0FU; + m_PI = (DMREMB[0U] & 0x08U) == 0x08U; + m_LCSS = (DMREMB[0U] >> 1) & 0x03U; +} + +void CDMREMB::getData(unsigned char* data) const +{ + assert(data != NULL); + + unsigned char DMREMB[2U]; + DMREMB[0U] = (m_colorCode << 4) & 0xF0U; + DMREMB[0U] |= m_PI ? 0x08U : 0x00U; + DMREMB[0U] |= (m_LCSS << 1) & 0x06U; + DMREMB[1U] = 0x00U; + + CQR1676::encode(DMREMB); + + data[13U] = (data[13U] & 0xF0U) | ((DMREMB[0U] >> 4U) & 0x0FU); + data[14U] = (data[14U] & 0x0FU) | ((DMREMB[0U] << 4U) & 0xF0U); + data[18U] = (data[18U] & 0xF0U) | ((DMREMB[1U] >> 4U) & 0x0FU); + data[19U] = (data[19U] & 0x0FU) | ((DMREMB[1U] << 4U) & 0xF0U); +} + +unsigned char CDMREMB::getColorCode() const +{ + return m_colorCode; +} + +void CDMREMB::setColorCode(unsigned char code) +{ + m_colorCode = code; +} + +bool CDMREMB::getPI() const +{ + return m_PI; +} + +void CDMREMB::setPI(bool pi) +{ + m_PI = pi; +} + +unsigned char CDMREMB::getLCSS() const +{ + return m_LCSS; +} + +void CDMREMB::setLCSS(unsigned char lcss) +{ + m_LCSS = lcss; +} diff --git a/EMB.h b/DMREMB.h similarity index 89% rename from EMB.h rename to DMREMB.h index 4283c6b..517be1e 100644 --- a/EMB.h +++ b/DMREMB.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,14 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(EMB_H) -#define EMB_H +#if !defined(DMREMB_H) +#define DMREMB_H -class CEMB +class CDMREMB { public: - CEMB(); - ~CEMB(); + CDMREMB(); + ~CDMREMB(); void putData(const unsigned char* data); void getData(unsigned char* data) const; @@ -44,4 +44,3 @@ private: }; #endif - diff --git a/EmbeddedLC.cpp b/DMREmbeddedLC.cpp similarity index 92% rename from EmbeddedLC.cpp rename to DMREmbeddedLC.cpp index c70ac7d..9738dc2 100644 --- a/EmbeddedLC.cpp +++ b/DMREmbeddedLC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,7 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "EmbeddedLC.h" +#include "DMREmbeddedLC.h" #include "Hamming.h" #include "Utils.h" @@ -27,20 +27,20 @@ #include #include -CEmbeddedLC::CEmbeddedLC() : +CDMREmbeddedLC::CDMREmbeddedLC() : m_rawLC(NULL), m_state(LCS_NONE) { m_rawLC = new bool[128U]; } -CEmbeddedLC::~CEmbeddedLC() +CDMREmbeddedLC::~CDMREmbeddedLC() { delete[] m_rawLC; } // Add LC data (which may consist of 4 blocks) to the data store -CLC* CEmbeddedLC::addData(const unsigned char* data, unsigned char lcss) +CDMRLC* CDMREmbeddedLC::addData(const unsigned char* data, unsigned char lcss) { assert(data != NULL); @@ -99,7 +99,7 @@ CLC* CEmbeddedLC::addData(const unsigned char* data, unsigned char lcss) return NULL; } -void CEmbeddedLC::setData(const CLC& lc) +void CDMREmbeddedLC::setData(const CDMRLC& lc) { bool lcData[72U]; lc.getData(lcData); @@ -150,7 +150,7 @@ void CEmbeddedLC::setData(const CLC& lc) } } -unsigned int CEmbeddedLC::getData(unsigned char* data, unsigned int n) const +unsigned int CDMREmbeddedLC::getData(unsigned char* data, unsigned int n) const { assert(data != NULL); @@ -193,7 +193,7 @@ unsigned int CEmbeddedLC::getData(unsigned char* data, unsigned int n) const } // Unpack and error check an embedded LC -CLC* CEmbeddedLC::processMultiBlockEmbeddedLC() +CDMRLC* CDMREmbeddedLC::processMultiBlockEmbeddedLC() { // The data is unpacked downwards in columns bool data[128U]; @@ -256,11 +256,11 @@ CLC* CEmbeddedLC::processMultiBlockEmbeddedLC() return NULL; } - return new CLC(lcData); + return new CDMRLC(lcData); } // Deal with a single block embedded LC -void CEmbeddedLC::processSingleBlockEmbeddedLC(const bool* data) +void CDMREmbeddedLC::processSingleBlockEmbeddedLC(const bool* data) { // Nothing interesting, or just NULL (I think) } diff --git a/EmbeddedLC.h b/DMREmbeddedLC.h similarity index 71% rename from EmbeddedLC.h rename to DMREmbeddedLC.h index f7c762b..d9543b9 100644 --- a/EmbeddedLC.h +++ b/DMREmbeddedLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,10 +16,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef EmbeddedLC_H -#define EmbeddedLC_H +#ifndef DMREmbeddedLC_H +#define DMREmbeddedLC_H -#include "LC.h" +#include "DMRLC.h" enum LC_STATE { LCS_NONE, @@ -28,24 +28,23 @@ enum LC_STATE { LCS_THIRD }; -class CEmbeddedLC +class CDMREmbeddedLC { public: - CEmbeddedLC(); - ~CEmbeddedLC(); + CDMREmbeddedLC(); + ~CDMREmbeddedLC(); - CLC* addData(const unsigned char* data, unsigned char lcss); + CDMRLC* addData(const unsigned char* data, unsigned char lcss); - void setData(const CLC& lc); + void setData(const CDMRLC& lc); unsigned int getData(unsigned char* data, unsigned int n) const; private: bool* m_rawLC; LC_STATE m_state; - CLC* processMultiBlockEmbeddedLC(); - void processSingleBlockEmbeddedLC(const bool* data); + CDMRLC* processMultiBlockEmbeddedLC(); + void processSingleBlockEmbeddedLC(const bool* data); }; #endif - diff --git a/FullLC.cpp b/DMRFullLC.cpp similarity index 89% rename from FullLC.cpp rename to DMRFullLC.cpp index 135678a..3f5b85b 100644 --- a/FullLC.cpp +++ b/DMRFullLC.cpp @@ -17,24 +17,25 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "FullLC.h" -#include "Log.h" +#include "DMRFullLC.h" + #include "DMRDefines.h" #include "RS129.h" +#include "Log.h" #include #include -CFullLC::CFullLC() : +CDMRFullLC::CDMRFullLC() : m_bptc() { } -CFullLC::~CFullLC() +CDMRFullLC::~CDMRFullLC() { } -CLC* CFullLC::decode(const unsigned char* data, unsigned char type) +CDMRLC* CDMRFullLC::decode(const unsigned char* data, unsigned char type) { assert(data != NULL); @@ -61,15 +62,15 @@ CLC* CFullLC::decode(const unsigned char* data, unsigned char type) if (!CRS129::check(lcData)) { ::LogDebug("Checksum failed for the LC"); - CLC lc(lcData); + CDMRLC lc(lcData); LogDebug("Invalid LC, src = %u, dst = %s%u", lc.getSrcId(), lc.getFLCO() == FLCO_GROUP ? "TG " : "", lc.getDstId()); return NULL; } - return new CLC(lcData); + return new CDMRLC(lcData); } -void CFullLC::encode(const CLC& lc, unsigned char* data, unsigned char type) +void CDMRFullLC::encode(const CDMRLC& lc, unsigned char* data, unsigned char type) { assert(data != NULL); diff --git a/FullLC.h b/DMRFullLC.h similarity index 71% rename from FullLC.h rename to DMRFullLC.h index 28ba8cf..d3294ef 100644 --- a/FullLC.h +++ b/DMRFullLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,23 +16,23 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef FullLC_H -#define FullLC_H +#ifndef DMRFullLC_H +#define DMRFullLC_H -#include "LC.h" -#include "SlotType.h" +#include "DMRLC.h" +#include "DMRSlotType.h" #include "BPTC19696.h" -class CFullLC +class CDMRFullLC { public: - CFullLC(); - ~CFullLC(); + CDMRFullLC(); + ~CDMRFullLC(); - CLC* decode(const unsigned char* data, unsigned char type); + CDMRLC* decode(const unsigned char* data, unsigned char type); - void encode(const CLC& lc, unsigned char* data, unsigned char type); + void encode(const CDMRLC& lc, unsigned char* data, unsigned char type); private: CBPTC19696 m_bptc; diff --git a/HomebrewDMRIPSC.cpp b/DMRIPSC.cpp similarity index 89% rename from HomebrewDMRIPSC.cpp rename to DMRIPSC.cpp index 4774e6e..00e1a6e 100644 --- a/HomebrewDMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,7 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "HomebrewDMRIPSC.h" +#include "DMRIPSC.h" + #include "StopWatch.h" #include "SHA256.h" #include "Utils.h" @@ -29,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U; -CHomebrewDMRIPSC::CHomebrewDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug) : +CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug) : m_address(), m_port(port), m_id(NULL), @@ -84,7 +85,7 @@ m_beacon(false) ::srand(stopWatch.start()); } -CHomebrewDMRIPSC::~CHomebrewDMRIPSC() +CDMRIPSC::~CDMRIPSC() { delete[] m_buffer; delete[] m_salt; @@ -92,7 +93,7 @@ CHomebrewDMRIPSC::~CHomebrewDMRIPSC() delete[] m_id; } -void CHomebrewDMRIPSC::setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url) +void CDMRIPSC::setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url) { m_callsign = callsign; m_rxFrequency = rxFrequency; @@ -107,7 +108,7 @@ void CHomebrewDMRIPSC::setConfig(const std::string& callsign, unsigned int rxFre m_url = url; } -bool CHomebrewDMRIPSC::open() +bool CDMRIPSC::open() { LogMessage("Opening DMR IPSC"); @@ -128,12 +129,12 @@ bool CHomebrewDMRIPSC::open() return true; } -void CHomebrewDMRIPSC::enable(bool enabled) +void CDMRIPSC::enable(bool enabled) { m_enabled = enabled; } -bool CHomebrewDMRIPSC::read(CDMRData& data) +bool CDMRIPSC::read(CDMRData& data) { if (m_status != RUNNING) return false; @@ -188,7 +189,7 @@ bool CHomebrewDMRIPSC::read(CDMRData& data) return true; } -bool CHomebrewDMRIPSC::write(const CDMRData& data) +bool CDMRIPSC::write(const CDMRData& data) { if (m_status != RUNNING) return false; @@ -242,7 +243,7 @@ bool CHomebrewDMRIPSC::write(const CDMRData& data) return write(buffer, HOMEBREW_DATA_PACKET_LENGTH); } -void CHomebrewDMRIPSC::close() +void CDMRIPSC::close() { LogMessage("Closing DMR IPSC"); @@ -254,7 +255,7 @@ void CHomebrewDMRIPSC::close() m_socket.close(); } -void CHomebrewDMRIPSC::clock(unsigned int ms) +void CDMRIPSC::clock(unsigned int ms) { in_addr address; unsigned int port; @@ -359,7 +360,7 @@ void CHomebrewDMRIPSC::clock(unsigned int ms) } } -bool CHomebrewDMRIPSC::writeLogin() +bool CDMRIPSC::writeLogin() { unsigned char buffer[8U]; @@ -369,7 +370,7 @@ bool CHomebrewDMRIPSC::writeLogin() return write(buffer, 8U); } -bool CHomebrewDMRIPSC::writeAuthorisation() +bool CDMRIPSC::writeAuthorisation() { unsigned int size = m_password.size(); @@ -390,7 +391,7 @@ bool CHomebrewDMRIPSC::writeAuthorisation() return write(out, 40U); } -bool CHomebrewDMRIPSC::writeConfig() +bool CDMRIPSC::writeConfig() { char buffer[400U]; @@ -404,7 +405,7 @@ bool CHomebrewDMRIPSC::writeConfig() return write((unsigned char*)buffer, 302U); } -bool CHomebrewDMRIPSC::writePing() +bool CDMRIPSC::writePing() { unsigned char buffer[11U]; @@ -414,7 +415,7 @@ bool CHomebrewDMRIPSC::writePing() return write(buffer, 11U); } -bool CHomebrewDMRIPSC::wantsBeacon() +bool CDMRIPSC::wantsBeacon() { bool beacon = m_beacon; @@ -423,7 +424,7 @@ bool CHomebrewDMRIPSC::wantsBeacon() return beacon; } -bool CHomebrewDMRIPSC::write(const unsigned char* data, unsigned int length) +bool CDMRIPSC::write(const unsigned char* data, unsigned int length) { assert(data != NULL); assert(length > 0U); diff --git a/HomebrewDMRIPSC.h b/DMRIPSC.h similarity index 90% rename from HomebrewDMRIPSC.h rename to DMRIPSC.h index 8e804ea..244c41e 100644 --- a/HomebrewDMRIPSC.h +++ b/DMRIPSC.h @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(HOMEBREWDMRIPSC_H) -#define HOMEBREWDMRIPSC_H +#if !defined(DMRIPSC_H) +#define DMRIPSC_H #include "UDPSocket.h" #include "Timer.h" @@ -27,11 +27,11 @@ #include #include -class CHomebrewDMRIPSC +class CDMRIPSC { public: - CHomebrewDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug); - ~CHomebrewDMRIPSC(); + CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug); + ~CDMRIPSC(); void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url); diff --git a/LC.cpp b/DMRLC.cpp similarity index 80% rename from LC.cpp rename to DMRLC.cpp index 4d28033..93a6ff1 100644 --- a/LC.cpp +++ b/DMRLC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,14 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "LC.h" +#include "DMRLC.h" #include "Utils.h" #include #include -CLC::CLC(FLCO flco, unsigned int srcId, unsigned int dstId) : +CDMRLC::CDMRLC(FLCO flco, unsigned int srcId, unsigned int dstId) : m_PF(false), m_FLCO(flco), m_FID(0U), @@ -32,7 +32,7 @@ m_dstId(dstId) { } -CLC::CLC(const unsigned char* bytes) : +CDMRLC::CDMRLC(const unsigned char* bytes) : m_PF(false), m_FLCO(FLCO_GROUP), m_FID(0U), @@ -51,7 +51,7 @@ m_dstId(0U) m_srcId = bytes[6U] << 16 | bytes[7U] << 8 | bytes[8U]; } -CLC::CLC(const bool* bits) : +CDMRLC::CDMRLC(const bool* bits) : m_PF(false), m_FLCO(FLCO_GROUP), m_FID(0U), @@ -83,7 +83,7 @@ m_dstId(0U) m_dstId = d1 << 16 | d2 << 8 | d3; } -CLC::CLC() : +CDMRLC::CDMRLC() : m_PF(false), m_FLCO(FLCO_GROUP), m_FID(0U), @@ -92,11 +92,11 @@ m_dstId(0U) { } -CLC::~CLC() +CDMRLC::~CDMRLC() { } -void CLC::getData(unsigned char* bytes) const +void CDMRLC::getData(unsigned char* bytes) const { assert(bytes != NULL); @@ -116,7 +116,7 @@ void CLC::getData(unsigned char* bytes) const bytes[8U] = m_srcId >> 0; } -void CLC::getData(bool* bits) const +void CDMRLC::getData(bool* bits) const { unsigned char bytes[9U]; getData(bytes); @@ -132,52 +132,52 @@ void CLC::getData(bool* bits) const CUtils::byteToBitsBE(bytes[8U], bits + 64U); } -bool CLC::getPF() const +bool CDMRLC::getPF() const { return m_PF; } -void CLC::setPF(bool pf) +void CDMRLC::setPF(bool pf) { m_PF = pf; } -FLCO CLC::getFLCO() const +FLCO CDMRLC::getFLCO() const { return m_FLCO; } -void CLC::setFLCO(FLCO flco) +void CDMRLC::setFLCO(FLCO flco) { m_FLCO = flco; } -unsigned char CLC::getFID() const +unsigned char CDMRLC::getFID() const { return m_FID; } -void CLC::setFID(unsigned char fid) +void CDMRLC::setFID(unsigned char fid) { m_FID = fid; } -unsigned int CLC::getSrcId() const +unsigned int CDMRLC::getSrcId() const { return m_srcId; } -void CLC::setSrcId(unsigned int id) +void CDMRLC::setSrcId(unsigned int id) { m_srcId = id; } -unsigned int CLC::getDstId() const +unsigned int CDMRLC::getDstId() const { return m_dstId; } -void CLC::setDstId(unsigned int id) +void CDMRLC::setDstId(unsigned int id) { m_dstId = id; } diff --git a/LC.h b/DMRLC.h similarity index 83% rename from LC.h rename to DMRLC.h index ca31914..81b6785 100644 --- a/LC.h +++ b/DMRLC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,19 +16,19 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(LC_H) -#define LC_H +#if !defined(DMRLC_H) +#define DMRLC_H #include "DMRDefines.h" -class CLC +class CDMRLC { public: - CLC(FLCO flco, unsigned int srcId, unsigned int dstId); - CLC(const unsigned char* bytes); - CLC(const bool* bits); - CLC(); - ~CLC(); + CDMRLC(FLCO flco, unsigned int srcId, unsigned int dstId); + CDMRLC(const unsigned char* bytes); + CDMRLC(const bool* bits); + CDMRLC(); + ~CDMRLC(); void getData(unsigned char* bytes) const; void getData(bool* bits) const; diff --git a/ShortLC.cpp b/DMRShortLC.cpp similarity index 89% rename from ShortLC.cpp rename to DMRShortLC.cpp index 8b6c56a..7184066 100644 --- a/ShortLC.cpp +++ b/DMRShortLC.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "ShortLC.h" +#include "DMRShortLC.h" #include "Hamming.h" #include "Utils.h" @@ -25,7 +25,7 @@ #include #include -CShortLC::CShortLC() : +CDMRShortLC::CDMRShortLC() : m_rawData(NULL), m_deInterData(NULL) { @@ -33,14 +33,14 @@ m_deInterData(NULL) m_deInterData = new bool[68U]; } -CShortLC::~CShortLC() +CDMRShortLC::~CDMRShortLC() { delete[] m_rawData; delete[] m_deInterData; } // The main decode function -bool CShortLC::decode(const unsigned char* in, unsigned char* out) +bool CDMRShortLC::decode(const unsigned char* in, unsigned char* out) { assert(in != NULL); assert(out != NULL); @@ -63,7 +63,7 @@ bool CShortLC::decode(const unsigned char* in, unsigned char* out) } // The main encode function -void CShortLC::encode(const unsigned char* in, unsigned char* out) +void CDMRShortLC::encode(const unsigned char* in, unsigned char* out) { assert(in != NULL); assert(out != NULL); @@ -81,7 +81,7 @@ void CShortLC::encode(const unsigned char* in, unsigned char* out) encodeExtractBinary(out); } -void CShortLC::decodeExtractBinary(const unsigned char* in) +void CDMRShortLC::decodeExtractBinary(const unsigned char* in) { CUtils::byteToBitsBE(in[0U], m_rawData + 0U); CUtils::byteToBitsBE(in[1U], m_rawData + 8U); @@ -95,7 +95,7 @@ void CShortLC::decodeExtractBinary(const unsigned char* in) } // Deinterleave the raw data -void CShortLC::decodeDeInterleave() +void CDMRShortLC::decodeDeInterleave() { for (unsigned int i = 0U; i < 68U; i++) m_deInterData[i] = false; @@ -111,7 +111,7 @@ void CShortLC::decodeDeInterleave() } // Check each row with a Hamming (17,12,3) code and each column with a parity bit -bool CShortLC::decodeErrorCheck() +bool CDMRShortLC::decodeErrorCheck() { // Run through each of the 3 rows containing data CHamming::decode17123(m_deInterData + 0U); @@ -129,7 +129,7 @@ bool CShortLC::decodeErrorCheck() } // Extract the 36 bits of payload -void CShortLC::decodeExtractData(unsigned char* data) const +void CDMRShortLC::decodeExtractData(unsigned char* data) const { bool bData[40U]; @@ -154,7 +154,7 @@ void CShortLC::decodeExtractData(unsigned char* data) const } // Extract the 36 bits of payload -void CShortLC::encodeExtractData(const unsigned char* in) const +void CDMRShortLC::encodeExtractData(const unsigned char* in) const { bool bData[40U]; CUtils::byteToBitsBE(in[0U], bData + 0U); @@ -178,7 +178,7 @@ void CShortLC::encodeExtractData(const unsigned char* in) const } // Check each row with a Hamming (17,12,3) code and each column with a parity bit -void CShortLC::encodeErrorCheck() +void CDMRShortLC::encodeErrorCheck() { // Run through each of the 3 rows containing data CHamming::encode17123(m_deInterData + 0U); @@ -191,7 +191,7 @@ void CShortLC::encodeErrorCheck() } // Interleave the raw data -void CShortLC::encodeInterleave() +void CDMRShortLC::encodeInterleave() { for (unsigned int i = 0U; i < 72U; i++) m_rawData[i] = false; @@ -206,7 +206,7 @@ void CShortLC::encodeInterleave() m_rawData[67U] = m_deInterData[67U]; } -void CShortLC::encodeExtractBinary(unsigned char* data) +void CDMRShortLC::encodeExtractBinary(unsigned char* data) { CUtils::bitsToByteBE(m_rawData + 0U, data[0U]); CUtils::bitsToByteBE(m_rawData + 8U, data[1U]); diff --git a/ShortLC.h b/DMRShortLC.h similarity index 92% rename from ShortLC.h rename to DMRShortLC.h index 04e69a5..af21589 100644 --- a/ShortLC.h +++ b/DMRShortLC.h @@ -16,14 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(SHORTLC_H) -#define SHORTLC_H +#if !defined(DMRSHORTLC_H) +#define DMRSHORTLC_H -class CShortLC +class CDMRShortLC { public: - CShortLC(); - ~CShortLC(); + CDMRShortLC(); + ~CDMRShortLC(); bool decode(const unsigned char* in, unsigned char* out); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 84aa677..9d8a282 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -12,33 +12,33 @@ */ #include "DMRDataHeader.h" -#include "SlotType.h" -#include "ShortLC.h" +#include "DMRSlotType.h" +#include "DMRShortLC.h" +#include "DMRFullLC.h" #include "DMRSlot.h" -#include "DMRSync.h" -#include "FullLC.h" +#include "DMRCSBK.h" #include "Utils.h" -#include "CSBK.h" +#include "Sync.h" #include "CRC.h" #include "Log.h" #include #include -unsigned int CDMRSlot::m_colorCode = 0U; -CModem* CDMRSlot::m_modem = NULL; -CHomebrewDMRIPSC* CDMRSlot::m_network = NULL; -IDisplay* CDMRSlot::m_display = NULL; -bool CDMRSlot::m_duplex = true; +unsigned int CDMRSlot::m_colorCode = 0U; +CModem* CDMRSlot::m_modem = NULL; +CDMRIPSC* CDMRSlot::m_network = NULL; +IDisplay* CDMRSlot::m_display = NULL; +bool CDMRSlot::m_duplex = true; -unsigned char* CDMRSlot::m_idle = NULL; +unsigned char* CDMRSlot::m_idle = NULL; -FLCO CDMRSlot::m_flco1; -unsigned char CDMRSlot::m_id1 = 0U; -bool CDMRSlot::m_voice1 = true; -FLCO CDMRSlot::m_flco2; -unsigned char CDMRSlot::m_id2 = 0U; -bool CDMRSlot::m_voice2 = true; +FLCO CDMRSlot::m_flco1; +unsigned char CDMRSlot::m_id1 = 0U; +bool CDMRSlot::m_voice1 = true; +FLCO CDMRSlot::m_flco2; +unsigned char CDMRSlot::m_id2 = 0U; +bool CDMRSlot::m_voice2 = true; // #define DUMP_DMR @@ -98,7 +98,7 @@ void CDMRSlot::writeModem(unsigned char *data) bool audioSync = (data[1U] & DMR_SYNC_AUDIO) == DMR_SYNC_AUDIO; if (dataSync) { - CSlotType slotType; + CDMRSlotType slotType; slotType.putData(data + 2U); unsigned char dataType = slotType.getDataType(); @@ -107,7 +107,7 @@ void CDMRSlot::writeModem(unsigned char *data) if (m_state == RS_RELAYING_RF_AUDIO) return; - CFullLC fullLC; + CDMRFullLC fullLC; m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); if (m_lc == NULL) { LogMessage("DMR Slot %u: unable to decode the LC", m_slotNo); @@ -118,8 +118,7 @@ void CDMRSlot::writeModem(unsigned char *data) slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -156,8 +155,7 @@ void CDMRSlot::writeModem(unsigned char *data) slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -176,8 +174,7 @@ void CDMRSlot::writeModem(unsigned char *data) slotType.getData(data + 2U); // Set the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_EOT; data[1U] = 0x00U; @@ -211,14 +208,13 @@ void CDMRSlot::writeModem(unsigned char *data) m_frames = dataHeader.getBlocks(); - m_lc = new CLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId); + m_lc = new CDMRLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId); // Regenerate the Slot Type slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -244,7 +240,7 @@ void CDMRSlot::writeModem(unsigned char *data) LogMessage("DMR Slot %u, received RF data header from %u to %s%u, %u blocks", m_slotNo, srcId, gi ? "TG ": "", dstId, m_frames); } else if (dataType == DT_CSBK) { - CCSBK csbk(data + 2U); + CDMRCSBK csbk(data + 2U); // if (!csbk.isValid()) { // LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo); // return; @@ -263,8 +259,7 @@ void CDMRSlot::writeModem(unsigned char *data) slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -292,8 +287,7 @@ void CDMRSlot::writeModem(unsigned char *data) slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); m_frames--; @@ -316,8 +310,7 @@ void CDMRSlot::writeModem(unsigned char *data) } else if (audioSync) { if (m_state == RS_RELAYING_RF_AUDIO) { // Convert the Audio Sync to be from the BS - CDMRSync sync; - sync.addAudioSync(data + 2U); + CSync::addDMRAudioSync(data + 2U); unsigned char fid = m_lc->getFID(); if (fid == FID_ETSI || fid == FID_DMRA) @@ -337,7 +330,7 @@ void CDMRSlot::writeModem(unsigned char *data) m_state = RS_LATE_ENTRY; } } else { - CEMB emb; + CDMREMB emb; emb.putData(data + 2U); if (m_state == RS_RELAYING_RF_AUDIO) { @@ -370,13 +363,12 @@ void CDMRSlot::writeModem(unsigned char *data) // Create a dummy start frame to replace the received frame unsigned char start[DMR_FRAME_LENGTH_BYTES + 2U]; - CDMRSync sync; - sync.addDataSync(start + 2U); + CSync::addDMRDataSync(data + 2U); - CFullLC fullLC; + CDMRFullLC fullLC; fullLC.encode(*m_lc, start + 2U, DT_VOICE_LC_HEADER); - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_VOICE_LC_HEADER); slotType.getData(start + 2U); @@ -468,13 +460,12 @@ void CDMRSlot::writeEndOfTransmission(bool writeEnd) // Create a dummy start end frame unsigned char data[DMR_FRAME_LENGTH_BYTES + 2U]; - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); - CFullLC fullLC; + CDMRFullLC fullLC; fullLC.encode(*m_lc, data + 2U, DT_TERMINATOR_WITH_LC); - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_TERMINATOR_WITH_LC); slotType.getData(data + 2U); @@ -512,7 +503,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) if (m_state == RS_RELAYING_NETWORK_AUDIO) return; - CFullLC fullLC; + CDMRFullLC fullLC; m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); if (m_lc == NULL) { LogMessage("DMR Slot %u, bad LC received from the network", m_slotNo); @@ -520,14 +511,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_VOICE_LC_HEADER); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -562,14 +552,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) return; // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_VOICE_PI_HEADER); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -584,14 +573,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) return; // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_TERMINATOR_WITH_LC); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_EOT; data[1U] = 0x00U; @@ -626,17 +614,16 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) m_frames = dataHeader.getBlocks(); - m_lc = new CLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId); + m_lc = new CDMRLC(gi ? FLCO_GROUP : FLCO_USER_USER, srcId, dstId); // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(m_colorCode); slotType.setDataType(DT_DATA_HEADER); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -657,7 +644,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) LogMessage("DMR Slot %u, received network data header from %u to %s%u, %u blocks", m_slotNo, dmrData.getSrcId(), gi ? "TG ": "", dmrData.getDstId(), m_frames); } else if (dataType == DT_VOICE_SYNC) { if (m_state == RS_LISTENING) { - m_lc = new CLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); + m_lc = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); m_timeoutTimer.start(); @@ -703,8 +690,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } // Convert the Audio Sync to be from the BS - CDMRSync sync; - sync.addAudioSync(data + 2U); + CSync::addDMRAudioSync(data + 2U); writeQueue(data); @@ -760,7 +746,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) writeFile(data); #endif } else if (dataType == DT_CSBK) { - CCSBK csbk(data + 2U); + CDMRCSBK csbk(data + 2U); // if (!csbk.isValid()) { // LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo); // return; @@ -776,14 +762,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) case CSBKO_NACKRSP: case CSBKO_PRECCSBK: { // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.putData(data + 2U); slotType.setColorCode(m_colorCode); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); data[0U] = TAG_DATA; data[1U] = 0x00U; @@ -808,14 +793,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) return; // Regenerate the Slot Type - CSlotType slotType; + CDMRSlotType slotType; slotType.putData(data + 2U); slotType.setColorCode(m_colorCode); slotType.getData(data + 2U); // Convert the Data Sync to be from the BS - CDMRSync sync; - sync.addDataSync(data + 2U); + CSync::addDMRDataSync(data + 2U); m_frames--; @@ -930,7 +914,7 @@ void CDMRSlot::writeNetwork(const unsigned char* data, unsigned char dataType) writeNetwork(data, dataType, m_lc->getFLCO(), m_lc->getSrcId(), m_lc->getDstId()); } -void CDMRSlot::init(unsigned int colorCode, CModem* modem, CHomebrewDMRIPSC* network, IDisplay* display, bool duplex) +void CDMRSlot::init(unsigned int colorCode, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) { assert(modem != NULL); assert(display != NULL); @@ -946,7 +930,7 @@ void CDMRSlot::init(unsigned int colorCode, CModem* modem, CHomebrewDMRIPSC* net ::memcpy(m_idle, DMR_IDLE_DATA, DMR_FRAME_LENGTH_BYTES + 2U); // Generate the Slot Type for the Idle frame - CSlotType slotType; + CDMRSlotType slotType; slotType.setColorCode(colorCode); slotType.setDataType(DT_IDLE); slotType.getData(m_idle + 2U); @@ -1026,7 +1010,7 @@ void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, bool unsigned char sLC[9U]; - CShortLC shortLC; + CDMRShortLC shortLC; shortLC.encode(lc, sLC); m_modem->writeDMRShortLC(sLC); @@ -1117,8 +1101,7 @@ void CDMRSlot::insertSilence(unsigned int count) ::memcpy(data, DMR_SILENCE_DATA, DMR_FRAME_LENGTH_BYTES + 2U); if (n == 0U) { - CDMRSync sync; - sync.addAudioSync(data + 2U); + CSync::addDMRAudioSync(data + 2U); } else { // Set the Embedded LC to 0x00 ::memset(data + 2U + 13U, 0x00U, 5U); diff --git a/DMRSlot.h b/DMRSlot.h index a80fa0e..10ec0db 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -19,19 +19,19 @@ #if !defined(DMRSlot_H) #define DMRSlot_H -#include "HomebrewDMRIPSC.h" +#include "DMREmbeddedLC.h" #include "StopWatch.h" -#include "EmbeddedLC.h" #include "RingBuffer.h" #include "AMBEFEC.h" #include "DMRSlot.h" #include "DMRData.h" #include "Display.h" #include "Defines.h" +#include "DMRIPSC.h" +#include "DMREMB.h" #include "Timer.h" #include "Modem.h" -#include "EMB.h" -#include "LC.h" +#include "DMRLC.h" class CDMRSlot { public: @@ -46,14 +46,14 @@ public: void clock(unsigned int ms); - static void init(unsigned int colorCode, CModem* modem, CHomebrewDMRIPSC* network, IDisplay* display, bool duplex); + static void init(unsigned int colorCode, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex); private: unsigned int m_slotNo; CRingBuffer m_queue; RPT_STATE m_state; - CEmbeddedLC m_embeddedLC; - CLC* m_lc; + CDMREmbeddedLC m_embeddedLC; + CDMRLC* m_lc; unsigned char m_seqNo; unsigned char m_n; CTimer m_networkWatchdog; @@ -66,12 +66,12 @@ private: unsigned int m_bits; unsigned int m_errs; unsigned char* m_lastFrame; - CEMB m_lastEMB; + CDMREMB m_lastEMB; FILE* m_fp; static unsigned int m_colorCode; static CModem* m_modem; - static CHomebrewDMRIPSC* m_network; + static CDMRIPSC* m_network; static IDisplay* m_display; static bool m_duplex; diff --git a/DMRSlotType.cpp b/DMRSlotType.cpp new file mode 100644 index 0000000..d855303 --- /dev/null +++ b/DMRSlotType.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2015,2016 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "DMRSlotType.h" + +#include "Golay2087.h" + +#include +#include + +CDMRSlotType::CDMRSlotType() : +m_colorCode(0U), +m_dataType(0U) +{ +} + +CDMRSlotType::~CDMRSlotType() +{ +} + +void CDMRSlotType::putData(const unsigned char* data) +{ + assert(data != NULL); + + unsigned char DMRSlotType[3U]; + DMRSlotType[0U] = (data[12U] << 2) & 0xFCU; + DMRSlotType[0U] |= (data[13U] >> 6) & 0x03U; + + DMRSlotType[1U] = (data[13U] << 2) & 0xC0U; + DMRSlotType[1U] |= (data[19U] << 2) & 0x3CU; + DMRSlotType[1U] |= (data[20U] >> 6) & 0x03U; + + DMRSlotType[2U] = (data[20U] << 2) & 0xF0U; + + unsigned char code = CGolay2087::decode(DMRSlotType); + + m_colorCode = (code >> 4) & 0x0FU; + m_dataType = (code >> 0) & 0x0FU; +} + +void CDMRSlotType::getData(unsigned char* data) const +{ + assert(data != NULL); + + unsigned char DMRSlotType[3U]; + DMRSlotType[0U] = (m_colorCode << 4) & 0xF0U; + DMRSlotType[0U] |= (m_dataType << 0) & 0x0FU; + DMRSlotType[1U] = 0x00U; + DMRSlotType[2U] = 0x00U; + + CGolay2087::encode(DMRSlotType); + + data[12U] = (data[12U] & 0xC0U) | ((DMRSlotType[0U] >> 2) & 0x3FU); + data[13U] = (data[13U] & 0x0FU) | ((DMRSlotType[0U] << 6) & 0xC0U) | ((DMRSlotType[1U] >> 2) & 0x30U); + data[19U] = (data[19U] & 0xF0U) | ((DMRSlotType[1U] >> 2) & 0x0FU); + data[20U] = (data[20U] & 0x03U) | ((DMRSlotType[1U] << 6) & 0xC0U) | ((DMRSlotType[2U] >> 2) & 0x3CU); +} + +unsigned char CDMRSlotType::getColorCode() const +{ + return m_colorCode; +} + +void CDMRSlotType::setColorCode(unsigned char code) +{ + m_colorCode = code; +} + +unsigned char CDMRSlotType::getDataType() const +{ + return m_dataType; +} + +void CDMRSlotType::setDataType(unsigned char type) +{ + m_dataType = type; +} diff --git a/SlotType.h b/DMRSlotType.h similarity index 86% rename from SlotType.h rename to DMRSlotType.h index 07440df..e76821f 100644 --- a/SlotType.h +++ b/DMRSlotType.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 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 @@ -16,14 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(SLOTTYPE_H) -#define SLOTTYPE_H +#if !defined(DMRSLOTTYPE_H) +#define DMRSLOTTYPE_H -class CSlotType +class CDMRSlotType { public: - CSlotType(); - ~CSlotType(); + CDMRSlotType(); + ~CDMRSlotType(); void putData(const unsigned char* data); void getData(unsigned char* data) const; diff --git a/EMB.cpp b/EMB.cpp deleted file mode 100644 index c2053df..0000000 --- a/EMB.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2015 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "EMB.h" - -#include "QR1676.h" - -#include -#include - -CEMB::CEMB() : -m_colorCode(0U), -m_PI(false), -m_LCSS(0U) -{ -} - -CEMB::~CEMB() -{ -} - -void CEMB::putData(const unsigned char* data) -{ - assert(data != NULL); - - unsigned char emb[2U]; - emb[0U] = (data[13U] << 4) & 0xF0U; - emb[0U] |= (data[14U] >> 4) & 0x0FU; - emb[1U] = (data[18U] << 4) & 0xF0U; - emb[1U] |= (data[19U] >> 4) & 0x0FU; - - CQR1676::decode(emb); - - m_colorCode = (emb[0U] >> 4) & 0x0FU; - m_PI = (emb[0U] & 0x08U) == 0x08U; - m_LCSS = (emb[0U] >> 1) & 0x03U; -} - -void CEMB::getData(unsigned char* data) const -{ - assert(data != NULL); - - unsigned char emb[2U]; - emb[0U] = (m_colorCode << 4) & 0xF0U; - emb[0U] |= m_PI ? 0x08U : 0x00U; - emb[0U] |= (m_LCSS << 1) & 0x06U; - emb[1U] = 0x00U; - - CQR1676::encode(emb); - - data[13U] = (data[13U] & 0xF0U) | ((emb[0U] >> 4U) & 0x0FU); - data[14U] = (data[14U] & 0x0FU) | ((emb[0U] << 4U) & 0xF0U); - data[18U] = (data[18U] & 0xF0U) | ((emb[1U] >> 4U) & 0x0FU); - data[19U] = (data[19U] & 0x0FU) | ((emb[1U] << 4U) & 0xF0U); -} - -unsigned char CEMB::getColorCode() const -{ - return m_colorCode; -} - -void CEMB::setColorCode(unsigned char code) -{ - m_colorCode = code; -} - -bool CEMB::getPI() const -{ - return m_PI; -} - -void CEMB::setPI(bool pi) -{ - m_PI = pi; -} - -unsigned char CEMB::getLCSS() const -{ - return m_LCSS; -} - -void CEMB::setLCSS(unsigned char lcss) -{ - m_LCSS = lcss; -} diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 0f2ef98..2a551c9 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -446,7 +446,7 @@ bool CMMDVMHost::createDMRNetwork() LogInfo(" Address: %s", address.c_str()); LogInfo(" Port: %u", port); - m_dmrNetwork = new CHomebrewDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug); + m_dmrNetwork = new CDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug); std::string callsign = m_conf.getCallsign(); unsigned int rxFrequency = m_conf.getRxFrequency(); diff --git a/MMDVMHost.h b/MMDVMHost.h index 059559f..406d4cb 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -19,8 +19,8 @@ #if !defined(MMDVMHOST_H) #define MMDVMHOST_H -#include "HomebrewDMRIPSC.h" #include "DStarNetwork.h" +#include "DMRIPSC.h" #include "Display.h" #include "Timer.h" #include "Modem.h" @@ -37,16 +37,16 @@ public: int run(); private: - CConf m_conf; - CModem* m_modem; - CDStarNetwork* m_dstarNetwork; - CHomebrewDMRIPSC* m_dmrNetwork; - IDisplay* m_display; - unsigned char m_mode; - CTimer m_modeTimer; - bool m_dstarEnabled; - bool m_dmrEnabled; - bool m_ysfEnabled; + CConf m_conf; + CModem* m_modem; + CDStarNetwork* m_dstarNetwork; + CDMRIPSC* m_dmrNetwork; + IDisplay* m_display; + unsigned char m_mode; + CTimer m_modeTimer; + bool m_dstarEnabled; + bool m_dmrEnabled; + bool m_ysfEnabled; void readParams(); bool createModem(); diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 0e9805b..0536a41 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -150,28 +150,29 @@ - + + + + + + + - + - - - - - @@ -181,9 +182,8 @@ - - + @@ -199,25 +199,26 @@ - + + + + + + + - + - - - - - @@ -226,9 +227,8 @@ - - + diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index ca31965..4f018f7 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -20,9 +20,6 @@ Header Files - - Header Files - Header Files @@ -41,21 +38,9 @@ Header Files - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - Header Files @@ -65,12 +50,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -98,12 +77,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -152,6 +125,33 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + @@ -163,9 +163,6 @@ Source Files - - Source Files - Source Files @@ -178,18 +175,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files @@ -199,12 +184,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -229,12 +208,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -277,5 +250,32 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/Makefile b/Makefile index 8f45a0b..6e1b4fd 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,9 @@ LIBS = LDFLAGS = -g OBJECTS = \ - AMBEFEC.o BPTC19696.o Conf.o CRC.o CSBK.o Display.o DMRControl.o DMRData.o DMRDataHeader.o DMRSlot.o DMRSync.o DStarControl.o DStarHeader.o \ - DStarNetwork.o DStarSlowData.o EMB.o EmbeddedLC.o FullLC.o Golay2087.o Golay24128.o Hamming.o HomebrewDMRIPSC.o LC.o Log.o MMDVMHost.o Modem.o \ - NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o ShortLC.o SlotType.o StopWatch.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFConvolution.o \ - YSFEcho.o YSFFICH.o + AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLC.o DMRShortLC.o \ + DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o NullDisplay.o \ + QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFConvolution.o YSFEcho.o YSFFICH.o all: MMDVMHost diff --git a/SlotType.cpp b/SlotType.cpp deleted file mode 100644 index 2319ba6..0000000 --- a/SlotType.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2015 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "SlotType.h" - -#include "Golay2087.h" - -#include -#include - -CSlotType::CSlotType() : -m_colorCode(0U), -m_dataType(0U) -{ -} - -CSlotType::~CSlotType() -{ -} - -void CSlotType::putData(const unsigned char* data) -{ - assert(data != NULL); - - unsigned char slotType[3U]; - slotType[0U] = (data[12U] << 2) & 0xFCU; - slotType[0U] |= (data[13U] >> 6) & 0x03U; - - slotType[1U] = (data[13U] << 2) & 0xC0U; - slotType[1U] |= (data[19U] << 2) & 0x3CU; - slotType[1U] |= (data[20U] >> 6) & 0x03U; - - slotType[2U] = (data[20U] << 2) & 0xF0U; - - unsigned char code = CGolay2087::decode(slotType); - - m_colorCode = (code >> 4) & 0x0FU; - m_dataType = (code >> 0) & 0x0FU; -} - -void CSlotType::getData(unsigned char* data) const -{ - assert(data != NULL); - - unsigned char slotType[3U]; - slotType[0U] = (m_colorCode << 4) & 0xF0U; - slotType[0U] |= (m_dataType << 0) & 0x0FU; - slotType[1U] = 0x00U; - slotType[2U] = 0x00U; - - CGolay2087::encode(slotType); - - data[12U] = (data[12U] & 0xC0U) | ((slotType[0U] >> 2) & 0x3FU); - data[13U] = (data[13U] & 0x0FU) | ((slotType[0U] << 6) & 0xC0U) | ((slotType[1U] >> 2) & 0x30U); - data[19U] = (data[19U] & 0xF0U) | ((slotType[1U] >> 2) & 0x0FU); - data[20U] = (data[20U] & 0x03U) | ((slotType[1U] << 6) & 0xC0U) | ((slotType[2U] >> 2) & 0x3CU); -} - -unsigned char CSlotType::getColorCode() const -{ - return m_colorCode; -} - -void CSlotType::setColorCode(unsigned char code) -{ - m_colorCode = code; -} - -unsigned char CSlotType::getDataType() const -{ - return m_dataType; -} - -void CSlotType::setDataType(unsigned char type) -{ - m_dataType = type; -} diff --git a/DMRSync.cpp b/Sync.cpp similarity index 86% rename from DMRSync.cpp rename to Sync.cpp index 9ff568e..6bca463 100644 --- a/DMRSync.cpp +++ b/Sync.cpp @@ -16,22 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "DMRSync.h" +#include "Sync.h" #include "DMRDefines.h" #include #include -CDMRSync::CDMRSync() -{ -} - -CDMRSync::~CDMRSync() -{ -} - -void CDMRSync::addDataSync(unsigned char* data) const +void CSync::addDMRDataSync(unsigned char* data) { assert(data != NULL); @@ -39,7 +31,7 @@ void CDMRSync::addDataSync(unsigned char* data) const data[i + 13U] = (data[i + 13U] & ~SYNC_MASK[i]) | BS_SOURCED_DATA_SYNC[i]; } -void CDMRSync::addAudioSync(unsigned char* data) const +void CSync::addDMRAudioSync(unsigned char* data) { assert(data != NULL); diff --git a/DMRSync.h b/Sync.h similarity index 82% rename from DMRSync.h rename to Sync.h index f0a0b47..507662e 100644 --- a/DMRSync.h +++ b/Sync.h @@ -16,18 +16,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(DMRSYNC_H) -#define DMRSYNC_H +#if !defined(SYNC_H) +#define SYNC_H -class CDMRSync +class CSync { public: - CDMRSync(); - ~CDMRSync(); - - void addDataSync(unsigned char* data) const; - - void addAudioSync(unsigned char* data) const; + static void addDMRDataSync(unsigned char* data); + static void addDMRAudioSync(unsigned char* data); private: };