Renamed DMR protocol files.

This commit is contained in:
Jonathan Naylor 2016-02-15 18:45:57 +00:00
parent 656be113f5
commit 5185a0c245
29 changed files with 498 additions and 528 deletions

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "CSBK.h" #include "DMRCSBK.h"
#include "BPTC19696.h" #include "BPTC19696.h"
#include "Utils.h" #include "Utils.h"
#include "CRC.h" #include "CRC.h"
@ -24,7 +24,7 @@
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
CCSBK::CCSBK(const unsigned char* bytes) : CDMRCSBK::CDMRCSBK(const unsigned char* bytes) :
m_CSBKO(CSBKO_NONE), m_CSBKO(CSBKO_NONE),
m_FID(0x00U), m_FID(0x00U),
m_bsId(0U), 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; return m_valid;
} }
CSBKO CCSBK::getCSBKO() const CSBKO CDMRCSBK::getCSBKO() const
{ {
return m_CSBKO; return m_CSBKO;
} }
unsigned char CCSBK::getFID() const unsigned char CDMRCSBK::getFID() const
{ {
return m_FID; return m_FID;
} }
unsigned int CCSBK::getBSId() const unsigned int CDMRCSBK::getBSId() const
{ {
return m_bsId; return m_bsId;
} }
unsigned int CCSBK::getSrcId() const unsigned int CDMRCSBK::getSrcId() const
{ {
return m_srcId; return m_srcId;
} }
unsigned int CCSBK::getDstId() const unsigned int CDMRCSBK::getDstId() const
{ {
return m_dstId; return m_dstId;
} }

View File

@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(CSBK_H) #if !defined(DMRCSBK_H)
#define CSBK_H #define DMRCSBK_H
#include "DMRDefines.h" #include "DMRDefines.h"
@ -31,11 +31,11 @@ enum CSBKO {
CSBKO_PRECCSBK = 0x3D CSBKO_PRECCSBK = 0x3D
}; };
class CCSBK class CDMRCSBK
{ {
public: public:
CCSBK(const unsigned char* bytes); CDMRCSBK(const unsigned char* bytes);
~CCSBK(); ~CDMRCSBK();
bool isValid() const; bool isValid() const;

View File

@ -13,12 +13,12 @@
#include "DMRControl.h" #include "DMRControl.h"
#include "Defines.h" #include "Defines.h"
#include "CSBK.h" #include "DMRCSBK.h"
#include "Log.h" #include "Log.h"
#include <cassert> #include <cassert>
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_id(id),
m_colorCode(colorCode), m_colorCode(colorCode),
m_modem(modem), 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)) if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
return false; return false;
CCSBK csbk(data + 2U); CDMRCSBK csbk(data + 2U);
CSBKO csbko = csbk.getCSBKO(); CSBKO csbko = csbk.getCSBKO();
if (csbko != CSBKO_BSDWNACT) if (csbko != CSBKO_BSDWNACT)

View File

@ -19,7 +19,7 @@
#if !defined(DMRControl_H) #if !defined(DMRControl_H)
#define DMRControl_H #define DMRControl_H
#include "HomebrewDMRIPSC.h" #include "DMRIPSC.h"
#include "Display.h" #include "Display.h"
#include "DMRSlot.h" #include "DMRSlot.h"
#include "DMRData.h" #include "DMRData.h"
@ -28,7 +28,7 @@
class CDMRControl { class CDMRControl {
public: 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(); ~CDMRControl();
bool processWakeup(const unsigned char* data); bool processWakeup(const unsigned char* data);
@ -42,12 +42,12 @@ public:
void clock(unsigned int ms); void clock(unsigned int ms);
private: private:
unsigned int m_id; unsigned int m_id;
unsigned int m_colorCode; unsigned int m_colorCode;
CModem* m_modem; CModem* m_modem;
CHomebrewDMRIPSC* m_network; CDMRIPSC* m_network;
CDMRSlot m_slot1; CDMRSlot m_slot1;
CDMRSlot m_slot2; CDMRSlot m_slot2;
}; };
#endif #endif

100
DMREMB.cpp Normal file
View File

@ -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 <cstdio>
#include <cassert>
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;
}

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(EMB_H) #if !defined(DMREMB_H)
#define EMB_H #define DMREMB_H
class CEMB class CDMREMB
{ {
public: public:
CEMB(); CDMREMB();
~CEMB(); ~CDMREMB();
void putData(const unsigned char* data); void putData(const unsigned char* data);
void getData(unsigned char* data) const; void getData(unsigned char* data) const;
@ -44,4 +44,3 @@ private:
}; };
#endif #endif

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "EmbeddedLC.h" #include "DMREmbeddedLC.h"
#include "Hamming.h" #include "Hamming.h"
#include "Utils.h" #include "Utils.h"
@ -27,20 +27,20 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
CEmbeddedLC::CEmbeddedLC() : CDMREmbeddedLC::CDMREmbeddedLC() :
m_rawLC(NULL), m_rawLC(NULL),
m_state(LCS_NONE) m_state(LCS_NONE)
{ {
m_rawLC = new bool[128U]; m_rawLC = new bool[128U];
} }
CEmbeddedLC::~CEmbeddedLC() CDMREmbeddedLC::~CDMREmbeddedLC()
{ {
delete[] m_rawLC; delete[] m_rawLC;
} }
// Add LC data (which may consist of 4 blocks) to the data store // 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); assert(data != NULL);
@ -99,7 +99,7 @@ CLC* CEmbeddedLC::addData(const unsigned char* data, unsigned char lcss)
return NULL; return NULL;
} }
void CEmbeddedLC::setData(const CLC& lc) void CDMREmbeddedLC::setData(const CDMRLC& lc)
{ {
bool lcData[72U]; bool lcData[72U];
lc.getData(lcData); 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); 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 // Unpack and error check an embedded LC
CLC* CEmbeddedLC::processMultiBlockEmbeddedLC() CDMRLC* CDMREmbeddedLC::processMultiBlockEmbeddedLC()
{ {
// The data is unpacked downwards in columns // The data is unpacked downwards in columns
bool data[128U]; bool data[128U];
@ -256,11 +256,11 @@ CLC* CEmbeddedLC::processMultiBlockEmbeddedLC()
return NULL; return NULL;
} }
return new CLC(lcData); return new CDMRLC(lcData);
} }
// Deal with a single block embedded LC // 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) // Nothing interesting, or just NULL (I think)
} }

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef EmbeddedLC_H #ifndef DMREmbeddedLC_H
#define EmbeddedLC_H #define DMREmbeddedLC_H
#include "LC.h" #include "DMRLC.h"
enum LC_STATE { enum LC_STATE {
LCS_NONE, LCS_NONE,
@ -28,24 +28,23 @@ enum LC_STATE {
LCS_THIRD LCS_THIRD
}; };
class CEmbeddedLC class CDMREmbeddedLC
{ {
public: public:
CEmbeddedLC(); CDMREmbeddedLC();
~CEmbeddedLC(); ~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; unsigned int getData(unsigned char* data, unsigned int n) const;
private: private:
bool* m_rawLC; bool* m_rawLC;
LC_STATE m_state; LC_STATE m_state;
CLC* processMultiBlockEmbeddedLC(); CDMRLC* processMultiBlockEmbeddedLC();
void processSingleBlockEmbeddedLC(const bool* data); void processSingleBlockEmbeddedLC(const bool* data);
}; };
#endif #endif

View File

@ -17,24 +17,25 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "FullLC.h" #include "DMRFullLC.h"
#include "Log.h"
#include "DMRDefines.h" #include "DMRDefines.h"
#include "RS129.h" #include "RS129.h"
#include "Log.h"
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
CFullLC::CFullLC() : CDMRFullLC::CDMRFullLC() :
m_bptc() 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); assert(data != NULL);
@ -61,15 +62,15 @@ CLC* CFullLC::decode(const unsigned char* data, unsigned char type)
if (!CRS129::check(lcData)) { if (!CRS129::check(lcData)) {
::LogDebug("Checksum failed for the LC"); ::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()); LogDebug("Invalid LC, src = %u, dst = %s%u", lc.getSrcId(), lc.getFLCO() == FLCO_GROUP ? "TG " : "", lc.getDstId());
return NULL; 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); assert(data != NULL);

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef FullLC_H #ifndef DMRFullLC_H
#define FullLC_H #define DMRFullLC_H
#include "LC.h" #include "DMRLC.h"
#include "SlotType.h" #include "DMRSlotType.h"
#include "BPTC19696.h" #include "BPTC19696.h"
class CFullLC class CDMRFullLC
{ {
public: public:
CFullLC(); CDMRFullLC();
~CFullLC(); ~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: private:
CBPTC19696 m_bptc; CBPTC19696 m_bptc;

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "HomebrewDMRIPSC.h" #include "DMRIPSC.h"
#include "StopWatch.h" #include "StopWatch.h"
#include "SHA256.h" #include "SHA256.h"
#include "Utils.h" #include "Utils.h"
@ -29,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U; 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_address(),
m_port(port), m_port(port),
m_id(NULL), m_id(NULL),
@ -84,7 +85,7 @@ m_beacon(false)
::srand(stopWatch.start()); ::srand(stopWatch.start());
} }
CHomebrewDMRIPSC::~CHomebrewDMRIPSC() CDMRIPSC::~CDMRIPSC()
{ {
delete[] m_buffer; delete[] m_buffer;
delete[] m_salt; delete[] m_salt;
@ -92,7 +93,7 @@ CHomebrewDMRIPSC::~CHomebrewDMRIPSC()
delete[] m_id; 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_callsign = callsign;
m_rxFrequency = rxFrequency; m_rxFrequency = rxFrequency;
@ -107,7 +108,7 @@ void CHomebrewDMRIPSC::setConfig(const std::string& callsign, unsigned int rxFre
m_url = url; m_url = url;
} }
bool CHomebrewDMRIPSC::open() bool CDMRIPSC::open()
{ {
LogMessage("Opening DMR IPSC"); LogMessage("Opening DMR IPSC");
@ -128,12 +129,12 @@ bool CHomebrewDMRIPSC::open()
return true; return true;
} }
void CHomebrewDMRIPSC::enable(bool enabled) void CDMRIPSC::enable(bool enabled)
{ {
m_enabled = enabled; m_enabled = enabled;
} }
bool CHomebrewDMRIPSC::read(CDMRData& data) bool CDMRIPSC::read(CDMRData& data)
{ {
if (m_status != RUNNING) if (m_status != RUNNING)
return false; return false;
@ -188,7 +189,7 @@ bool CHomebrewDMRIPSC::read(CDMRData& data)
return true; return true;
} }
bool CHomebrewDMRIPSC::write(const CDMRData& data) bool CDMRIPSC::write(const CDMRData& data)
{ {
if (m_status != RUNNING) if (m_status != RUNNING)
return false; return false;
@ -242,7 +243,7 @@ bool CHomebrewDMRIPSC::write(const CDMRData& data)
return write(buffer, HOMEBREW_DATA_PACKET_LENGTH); return write(buffer, HOMEBREW_DATA_PACKET_LENGTH);
} }
void CHomebrewDMRIPSC::close() void CDMRIPSC::close()
{ {
LogMessage("Closing DMR IPSC"); LogMessage("Closing DMR IPSC");
@ -254,7 +255,7 @@ void CHomebrewDMRIPSC::close()
m_socket.close(); m_socket.close();
} }
void CHomebrewDMRIPSC::clock(unsigned int ms) void CDMRIPSC::clock(unsigned int ms)
{ {
in_addr address; in_addr address;
unsigned int port; unsigned int port;
@ -359,7 +360,7 @@ void CHomebrewDMRIPSC::clock(unsigned int ms)
} }
} }
bool CHomebrewDMRIPSC::writeLogin() bool CDMRIPSC::writeLogin()
{ {
unsigned char buffer[8U]; unsigned char buffer[8U];
@ -369,7 +370,7 @@ bool CHomebrewDMRIPSC::writeLogin()
return write(buffer, 8U); return write(buffer, 8U);
} }
bool CHomebrewDMRIPSC::writeAuthorisation() bool CDMRIPSC::writeAuthorisation()
{ {
unsigned int size = m_password.size(); unsigned int size = m_password.size();
@ -390,7 +391,7 @@ bool CHomebrewDMRIPSC::writeAuthorisation()
return write(out, 40U); return write(out, 40U);
} }
bool CHomebrewDMRIPSC::writeConfig() bool CDMRIPSC::writeConfig()
{ {
char buffer[400U]; char buffer[400U];
@ -404,7 +405,7 @@ bool CHomebrewDMRIPSC::writeConfig()
return write((unsigned char*)buffer, 302U); return write((unsigned char*)buffer, 302U);
} }
bool CHomebrewDMRIPSC::writePing() bool CDMRIPSC::writePing()
{ {
unsigned char buffer[11U]; unsigned char buffer[11U];
@ -414,7 +415,7 @@ bool CHomebrewDMRIPSC::writePing()
return write(buffer, 11U); return write(buffer, 11U);
} }
bool CHomebrewDMRIPSC::wantsBeacon() bool CDMRIPSC::wantsBeacon()
{ {
bool beacon = m_beacon; bool beacon = m_beacon;
@ -423,7 +424,7 @@ bool CHomebrewDMRIPSC::wantsBeacon()
return beacon; 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(data != NULL);
assert(length > 0U); assert(length > 0U);

View File

@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(HOMEBREWDMRIPSC_H) #if !defined(DMRIPSC_H)
#define HOMEBREWDMRIPSC_H #define DMRIPSC_H
#include "UDPSocket.h" #include "UDPSocket.h"
#include "Timer.h" #include "Timer.h"
@ -27,11 +27,11 @@
#include <string> #include <string>
#include <cstdint> #include <cstdint>
class CHomebrewDMRIPSC class CDMRIPSC
{ {
public: public:
CHomebrewDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug); CDMRIPSC(const std::string& address, unsigned int port, unsigned int id, const std::string& password, const char* software, const char* version, bool debug);
~CHomebrewDMRIPSC(); ~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); 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);

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "LC.h" #include "DMRLC.h"
#include "Utils.h" #include "Utils.h"
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
CLC::CLC(FLCO flco, unsigned int srcId, unsigned int dstId) : CDMRLC::CDMRLC(FLCO flco, unsigned int srcId, unsigned int dstId) :
m_PF(false), m_PF(false),
m_FLCO(flco), m_FLCO(flco),
m_FID(0U), 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_PF(false),
m_FLCO(FLCO_GROUP), m_FLCO(FLCO_GROUP),
m_FID(0U), m_FID(0U),
@ -51,7 +51,7 @@ m_dstId(0U)
m_srcId = bytes[6U] << 16 | bytes[7U] << 8 | bytes[8U]; m_srcId = bytes[6U] << 16 | bytes[7U] << 8 | bytes[8U];
} }
CLC::CLC(const bool* bits) : CDMRLC::CDMRLC(const bool* bits) :
m_PF(false), m_PF(false),
m_FLCO(FLCO_GROUP), m_FLCO(FLCO_GROUP),
m_FID(0U), m_FID(0U),
@ -83,7 +83,7 @@ m_dstId(0U)
m_dstId = d1 << 16 | d2 << 8 | d3; m_dstId = d1 << 16 | d2 << 8 | d3;
} }
CLC::CLC() : CDMRLC::CDMRLC() :
m_PF(false), m_PF(false),
m_FLCO(FLCO_GROUP), m_FLCO(FLCO_GROUP),
m_FID(0U), 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); assert(bytes != NULL);
@ -116,7 +116,7 @@ void CLC::getData(unsigned char* bytes) const
bytes[8U] = m_srcId >> 0; bytes[8U] = m_srcId >> 0;
} }
void CLC::getData(bool* bits) const void CDMRLC::getData(bool* bits) const
{ {
unsigned char bytes[9U]; unsigned char bytes[9U];
getData(bytes); getData(bytes);
@ -132,52 +132,52 @@ void CLC::getData(bool* bits) const
CUtils::byteToBitsBE(bytes[8U], bits + 64U); CUtils::byteToBitsBE(bytes[8U], bits + 64U);
} }
bool CLC::getPF() const bool CDMRLC::getPF() const
{ {
return m_PF; return m_PF;
} }
void CLC::setPF(bool pf) void CDMRLC::setPF(bool pf)
{ {
m_PF = pf; m_PF = pf;
} }
FLCO CLC::getFLCO() const FLCO CDMRLC::getFLCO() const
{ {
return m_FLCO; return m_FLCO;
} }
void CLC::setFLCO(FLCO flco) void CDMRLC::setFLCO(FLCO flco)
{ {
m_FLCO = flco; m_FLCO = flco;
} }
unsigned char CLC::getFID() const unsigned char CDMRLC::getFID() const
{ {
return m_FID; return m_FID;
} }
void CLC::setFID(unsigned char fid) void CDMRLC::setFID(unsigned char fid)
{ {
m_FID = fid; m_FID = fid;
} }
unsigned int CLC::getSrcId() const unsigned int CDMRLC::getSrcId() const
{ {
return m_srcId; return m_srcId;
} }
void CLC::setSrcId(unsigned int id) void CDMRLC::setSrcId(unsigned int id)
{ {
m_srcId = id; m_srcId = id;
} }
unsigned int CLC::getDstId() const unsigned int CDMRLC::getDstId() const
{ {
return m_dstId; return m_dstId;
} }
void CLC::setDstId(unsigned int id) void CDMRLC::setDstId(unsigned int id)
{ {
m_dstId = id; m_dstId = id;
} }

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(LC_H) #if !defined(DMRLC_H)
#define LC_H #define DMRLC_H
#include "DMRDefines.h" #include "DMRDefines.h"
class CLC class CDMRLC
{ {
public: public:
CLC(FLCO flco, unsigned int srcId, unsigned int dstId); CDMRLC(FLCO flco, unsigned int srcId, unsigned int dstId);
CLC(const unsigned char* bytes); CDMRLC(const unsigned char* bytes);
CLC(const bool* bits); CDMRLC(const bool* bits);
CLC(); CDMRLC();
~CLC(); ~CDMRLC();
void getData(unsigned char* bytes) const; void getData(unsigned char* bytes) const;
void getData(bool* bits) const; void getData(bool* bits) const;

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "ShortLC.h" #include "DMRShortLC.h"
#include "Hamming.h" #include "Hamming.h"
#include "Utils.h" #include "Utils.h"
@ -25,7 +25,7 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
CShortLC::CShortLC() : CDMRShortLC::CDMRShortLC() :
m_rawData(NULL), m_rawData(NULL),
m_deInterData(NULL) m_deInterData(NULL)
{ {
@ -33,14 +33,14 @@ m_deInterData(NULL)
m_deInterData = new bool[68U]; m_deInterData = new bool[68U];
} }
CShortLC::~CShortLC() CDMRShortLC::~CDMRShortLC()
{ {
delete[] m_rawData; delete[] m_rawData;
delete[] m_deInterData; delete[] m_deInterData;
} }
// The main decode function // 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(in != NULL);
assert(out != NULL); assert(out != NULL);
@ -63,7 +63,7 @@ bool CShortLC::decode(const unsigned char* in, unsigned char* out)
} }
// The main encode function // 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(in != NULL);
assert(out != NULL); assert(out != NULL);
@ -81,7 +81,7 @@ void CShortLC::encode(const unsigned char* in, unsigned char* out)
encodeExtractBinary(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[0U], m_rawData + 0U);
CUtils::byteToBitsBE(in[1U], m_rawData + 8U); CUtils::byteToBitsBE(in[1U], m_rawData + 8U);
@ -95,7 +95,7 @@ void CShortLC::decodeExtractBinary(const unsigned char* in)
} }
// Deinterleave the raw data // Deinterleave the raw data
void CShortLC::decodeDeInterleave() void CDMRShortLC::decodeDeInterleave()
{ {
for (unsigned int i = 0U; i < 68U; i++) for (unsigned int i = 0U; i < 68U; i++)
m_deInterData[i] = false; 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 // 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 // Run through each of the 3 rows containing data
CHamming::decode17123(m_deInterData + 0U); CHamming::decode17123(m_deInterData + 0U);
@ -129,7 +129,7 @@ bool CShortLC::decodeErrorCheck()
} }
// Extract the 36 bits of payload // Extract the 36 bits of payload
void CShortLC::decodeExtractData(unsigned char* data) const void CDMRShortLC::decodeExtractData(unsigned char* data) const
{ {
bool bData[40U]; bool bData[40U];
@ -154,7 +154,7 @@ void CShortLC::decodeExtractData(unsigned char* data) const
} }
// Extract the 36 bits of payload // 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]; bool bData[40U];
CUtils::byteToBitsBE(in[0U], bData + 0U); 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 // 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 // Run through each of the 3 rows containing data
CHamming::encode17123(m_deInterData + 0U); CHamming::encode17123(m_deInterData + 0U);
@ -191,7 +191,7 @@ void CShortLC::encodeErrorCheck()
} }
// Interleave the raw data // Interleave the raw data
void CShortLC::encodeInterleave() void CDMRShortLC::encodeInterleave()
{ {
for (unsigned int i = 0U; i < 72U; i++) for (unsigned int i = 0U; i < 72U; i++)
m_rawData[i] = false; m_rawData[i] = false;
@ -206,7 +206,7 @@ void CShortLC::encodeInterleave()
m_rawData[67U] = m_deInterData[67U]; 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 + 0U, data[0U]);
CUtils::bitsToByteBE(m_rawData + 8U, data[1U]); CUtils::bitsToByteBE(m_rawData + 8U, data[1U]);

View File

@ -16,14 +16,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(SHORTLC_H) #if !defined(DMRSHORTLC_H)
#define SHORTLC_H #define DMRSHORTLC_H
class CShortLC class CDMRShortLC
{ {
public: public:
CShortLC(); CDMRShortLC();
~CShortLC(); ~CDMRShortLC();
bool decode(const unsigned char* in, unsigned char* out); bool decode(const unsigned char* in, unsigned char* out);

View File

@ -12,33 +12,33 @@
*/ */
#include "DMRDataHeader.h" #include "DMRDataHeader.h"
#include "SlotType.h" #include "DMRSlotType.h"
#include "ShortLC.h" #include "DMRShortLC.h"
#include "DMRFullLC.h"
#include "DMRSlot.h" #include "DMRSlot.h"
#include "DMRSync.h" #include "DMRCSBK.h"
#include "FullLC.h"
#include "Utils.h" #include "Utils.h"
#include "CSBK.h" #include "Sync.h"
#include "CRC.h" #include "CRC.h"
#include "Log.h" #include "Log.h"
#include <cassert> #include <cassert>
#include <ctime> #include <ctime>
unsigned int CDMRSlot::m_colorCode = 0U; unsigned int CDMRSlot::m_colorCode = 0U;
CModem* CDMRSlot::m_modem = NULL; CModem* CDMRSlot::m_modem = NULL;
CHomebrewDMRIPSC* CDMRSlot::m_network = NULL; CDMRIPSC* CDMRSlot::m_network = NULL;
IDisplay* CDMRSlot::m_display = NULL; IDisplay* CDMRSlot::m_display = NULL;
bool CDMRSlot::m_duplex = true; bool CDMRSlot::m_duplex = true;
unsigned char* CDMRSlot::m_idle = NULL; unsigned char* CDMRSlot::m_idle = NULL;
FLCO CDMRSlot::m_flco1; FLCO CDMRSlot::m_flco1;
unsigned char CDMRSlot::m_id1 = 0U; unsigned char CDMRSlot::m_id1 = 0U;
bool CDMRSlot::m_voice1 = true; bool CDMRSlot::m_voice1 = true;
FLCO CDMRSlot::m_flco2; FLCO CDMRSlot::m_flco2;
unsigned char CDMRSlot::m_id2 = 0U; unsigned char CDMRSlot::m_id2 = 0U;
bool CDMRSlot::m_voice2 = true; bool CDMRSlot::m_voice2 = true;
// #define DUMP_DMR // #define DUMP_DMR
@ -98,7 +98,7 @@ void CDMRSlot::writeModem(unsigned char *data)
bool audioSync = (data[1U] & DMR_SYNC_AUDIO) == DMR_SYNC_AUDIO; bool audioSync = (data[1U] & DMR_SYNC_AUDIO) == DMR_SYNC_AUDIO;
if (dataSync) { if (dataSync) {
CSlotType slotType; CDMRSlotType slotType;
slotType.putData(data + 2U); slotType.putData(data + 2U);
unsigned char dataType = slotType.getDataType(); unsigned char dataType = slotType.getDataType();
@ -107,7 +107,7 @@ void CDMRSlot::writeModem(unsigned char *data)
if (m_state == RS_RELAYING_RF_AUDIO) if (m_state == RS_RELAYING_RF_AUDIO)
return; return;
CFullLC fullLC; CDMRFullLC fullLC;
m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER);
if (m_lc == NULL) { if (m_lc == NULL) {
LogMessage("DMR Slot %u: unable to decode the LC", m_slotNo); 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); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -156,8 +155,7 @@ void CDMRSlot::writeModem(unsigned char *data)
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -176,8 +174,7 @@ void CDMRSlot::writeModem(unsigned char *data)
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Set the Data Sync to be from the BS // Set the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_EOT; data[0U] = TAG_EOT;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -211,14 +208,13 @@ void CDMRSlot::writeModem(unsigned char *data)
m_frames = dataHeader.getBlocks(); 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 // Regenerate the Slot Type
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; 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); 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) { } else if (dataType == DT_CSBK) {
CCSBK csbk(data + 2U); CDMRCSBK csbk(data + 2U);
// if (!csbk.isValid()) { // if (!csbk.isValid()) {
// LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo); // LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo);
// return; // return;
@ -263,8 +259,7 @@ void CDMRSlot::writeModem(unsigned char *data)
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -292,8 +287,7 @@ void CDMRSlot::writeModem(unsigned char *data)
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
m_frames--; m_frames--;
@ -316,8 +310,7 @@ void CDMRSlot::writeModem(unsigned char *data)
} else if (audioSync) { } else if (audioSync) {
if (m_state == RS_RELAYING_RF_AUDIO) { if (m_state == RS_RELAYING_RF_AUDIO) {
// Convert the Audio Sync to be from the BS // Convert the Audio Sync to be from the BS
CDMRSync sync; CSync::addDMRAudioSync(data + 2U);
sync.addAudioSync(data + 2U);
unsigned char fid = m_lc->getFID(); unsigned char fid = m_lc->getFID();
if (fid == FID_ETSI || fid == FID_DMRA) if (fid == FID_ETSI || fid == FID_DMRA)
@ -337,7 +330,7 @@ void CDMRSlot::writeModem(unsigned char *data)
m_state = RS_LATE_ENTRY; m_state = RS_LATE_ENTRY;
} }
} else { } else {
CEMB emb; CDMREMB emb;
emb.putData(data + 2U); emb.putData(data + 2U);
if (m_state == RS_RELAYING_RF_AUDIO) { 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 // Create a dummy start frame to replace the received frame
unsigned char start[DMR_FRAME_LENGTH_BYTES + 2U]; unsigned char start[DMR_FRAME_LENGTH_BYTES + 2U];
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(start + 2U);
CFullLC fullLC; CDMRFullLC fullLC;
fullLC.encode(*m_lc, start + 2U, DT_VOICE_LC_HEADER); fullLC.encode(*m_lc, start + 2U, DT_VOICE_LC_HEADER);
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_VOICE_LC_HEADER); slotType.setDataType(DT_VOICE_LC_HEADER);
slotType.getData(start + 2U); slotType.getData(start + 2U);
@ -468,13 +460,12 @@ void CDMRSlot::writeEndOfTransmission(bool writeEnd)
// Create a dummy start end frame // Create a dummy start end frame
unsigned char data[DMR_FRAME_LENGTH_BYTES + 2U]; unsigned char data[DMR_FRAME_LENGTH_BYTES + 2U];
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
CFullLC fullLC; CDMRFullLC fullLC;
fullLC.encode(*m_lc, data + 2U, DT_TERMINATOR_WITH_LC); fullLC.encode(*m_lc, data + 2U, DT_TERMINATOR_WITH_LC);
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_TERMINATOR_WITH_LC); slotType.setDataType(DT_TERMINATOR_WITH_LC);
slotType.getData(data + 2U); slotType.getData(data + 2U);
@ -512,7 +503,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (m_state == RS_RELAYING_NETWORK_AUDIO) if (m_state == RS_RELAYING_NETWORK_AUDIO)
return; return;
CFullLC fullLC; CDMRFullLC fullLC;
m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); m_lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER);
if (m_lc == NULL) { if (m_lc == NULL) {
LogMessage("DMR Slot %u, bad LC received from the network", m_slotNo); 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 // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_VOICE_LC_HEADER); slotType.setDataType(DT_VOICE_LC_HEADER);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -562,14 +552,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
return; return;
// Regenerate the Slot Type // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_VOICE_PI_HEADER); slotType.setDataType(DT_VOICE_PI_HEADER);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -584,14 +573,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
return; return;
// Regenerate the Slot Type // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_TERMINATOR_WITH_LC); slotType.setDataType(DT_TERMINATOR_WITH_LC);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_EOT; data[0U] = TAG_EOT;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -626,17 +614,16 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
m_frames = dataHeader.getBlocks(); 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 // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.setDataType(DT_DATA_HEADER); slotType.setDataType(DT_DATA_HEADER);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; 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); 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) { } else if (dataType == DT_VOICE_SYNC) {
if (m_state == RS_LISTENING) { 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(); m_timeoutTimer.start();
@ -703,8 +690,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
} }
// Convert the Audio Sync to be from the BS // Convert the Audio Sync to be from the BS
CDMRSync sync; CSync::addDMRAudioSync(data + 2U);
sync.addAudioSync(data + 2U);
writeQueue(data); writeQueue(data);
@ -760,7 +746,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
writeFile(data); writeFile(data);
#endif #endif
} else if (dataType == DT_CSBK) { } else if (dataType == DT_CSBK) {
CCSBK csbk(data + 2U); CDMRCSBK csbk(data + 2U);
// if (!csbk.isValid()) { // if (!csbk.isValid()) {
// LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo); // LogMessage("DMR Slot %u: unable to decode the CSBK", m_slotNo);
// return; // return;
@ -776,14 +762,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
case CSBKO_NACKRSP: case CSBKO_NACKRSP:
case CSBKO_PRECCSBK: { case CSBKO_PRECCSBK: {
// Regenerate the Slot Type // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.putData(data + 2U); slotType.putData(data + 2U);
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
data[0U] = TAG_DATA; data[0U] = TAG_DATA;
data[1U] = 0x00U; data[1U] = 0x00U;
@ -808,14 +793,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
return; return;
// Regenerate the Slot Type // Regenerate the Slot Type
CSlotType slotType; CDMRSlotType slotType;
slotType.putData(data + 2U); slotType.putData(data + 2U);
slotType.setColorCode(m_colorCode); slotType.setColorCode(m_colorCode);
slotType.getData(data + 2U); slotType.getData(data + 2U);
// Convert the Data Sync to be from the BS // Convert the Data Sync to be from the BS
CDMRSync sync; CSync::addDMRDataSync(data + 2U);
sync.addDataSync(data + 2U);
m_frames--; 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()); 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(modem != NULL);
assert(display != 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); ::memcpy(m_idle, DMR_IDLE_DATA, DMR_FRAME_LENGTH_BYTES + 2U);
// Generate the Slot Type for the Idle frame // Generate the Slot Type for the Idle frame
CSlotType slotType; CDMRSlotType slotType;
slotType.setColorCode(colorCode); slotType.setColorCode(colorCode);
slotType.setDataType(DT_IDLE); slotType.setDataType(DT_IDLE);
slotType.getData(m_idle + 2U); 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]; unsigned char sLC[9U];
CShortLC shortLC; CDMRShortLC shortLC;
shortLC.encode(lc, sLC); shortLC.encode(lc, sLC);
m_modem->writeDMRShortLC(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); ::memcpy(data, DMR_SILENCE_DATA, DMR_FRAME_LENGTH_BYTES + 2U);
if (n == 0U) { if (n == 0U) {
CDMRSync sync; CSync::addDMRAudioSync(data + 2U);
sync.addAudioSync(data + 2U);
} else { } else {
// Set the Embedded LC to 0x00 // Set the Embedded LC to 0x00
::memset(data + 2U + 13U, 0x00U, 5U); ::memset(data + 2U + 13U, 0x00U, 5U);

View File

@ -19,19 +19,19 @@
#if !defined(DMRSlot_H) #if !defined(DMRSlot_H)
#define DMRSlot_H #define DMRSlot_H
#include "HomebrewDMRIPSC.h" #include "DMREmbeddedLC.h"
#include "StopWatch.h" #include "StopWatch.h"
#include "EmbeddedLC.h"
#include "RingBuffer.h" #include "RingBuffer.h"
#include "AMBEFEC.h" #include "AMBEFEC.h"
#include "DMRSlot.h" #include "DMRSlot.h"
#include "DMRData.h" #include "DMRData.h"
#include "Display.h" #include "Display.h"
#include "Defines.h" #include "Defines.h"
#include "DMRIPSC.h"
#include "DMREMB.h"
#include "Timer.h" #include "Timer.h"
#include "Modem.h" #include "Modem.h"
#include "EMB.h" #include "DMRLC.h"
#include "LC.h"
class CDMRSlot { class CDMRSlot {
public: public:
@ -46,14 +46,14 @@ public:
void clock(unsigned int ms); 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: private:
unsigned int m_slotNo; unsigned int m_slotNo;
CRingBuffer<unsigned char> m_queue; CRingBuffer<unsigned char> m_queue;
RPT_STATE m_state; RPT_STATE m_state;
CEmbeddedLC m_embeddedLC; CDMREmbeddedLC m_embeddedLC;
CLC* m_lc; CDMRLC* m_lc;
unsigned char m_seqNo; unsigned char m_seqNo;
unsigned char m_n; unsigned char m_n;
CTimer m_networkWatchdog; CTimer m_networkWatchdog;
@ -66,12 +66,12 @@ private:
unsigned int m_bits; unsigned int m_bits;
unsigned int m_errs; unsigned int m_errs;
unsigned char* m_lastFrame; unsigned char* m_lastFrame;
CEMB m_lastEMB; CDMREMB m_lastEMB;
FILE* m_fp; FILE* m_fp;
static unsigned int m_colorCode; static unsigned int m_colorCode;
static CModem* m_modem; static CModem* m_modem;
static CHomebrewDMRIPSC* m_network; static CDMRIPSC* m_network;
static IDisplay* m_display; static IDisplay* m_display;
static bool m_duplex; static bool m_duplex;

92
DMRSlotType.cpp Normal file
View File

@ -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 <cstdio>
#include <cassert>
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;
}

View File

@ -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 * 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 * 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. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(SLOTTYPE_H) #if !defined(DMRSLOTTYPE_H)
#define SLOTTYPE_H #define DMRSLOTTYPE_H
class CSlotType class CDMRSlotType
{ {
public: public:
CSlotType(); CDMRSlotType();
~CSlotType(); ~CDMRSlotType();
void putData(const unsigned char* data); void putData(const unsigned char* data);
void getData(unsigned char* data) const; void getData(unsigned char* data) const;

100
EMB.cpp
View File

@ -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 <cstdio>
#include <cassert>
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;
}

View File

@ -446,7 +446,7 @@ bool CMMDVMHost::createDMRNetwork()
LogInfo(" Address: %s", address.c_str()); LogInfo(" Address: %s", address.c_str());
LogInfo(" Port: %u", port); 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(); std::string callsign = m_conf.getCallsign();
unsigned int rxFrequency = m_conf.getRxFrequency(); unsigned int rxFrequency = m_conf.getRxFrequency();

View File

@ -19,8 +19,8 @@
#if !defined(MMDVMHOST_H) #if !defined(MMDVMHOST_H)
#define MMDVMHOST_H #define MMDVMHOST_H
#include "HomebrewDMRIPSC.h"
#include "DStarNetwork.h" #include "DStarNetwork.h"
#include "DMRIPSC.h"
#include "Display.h" #include "Display.h"
#include "Timer.h" #include "Timer.h"
#include "Modem.h" #include "Modem.h"
@ -37,16 +37,16 @@ public:
int run(); int run();
private: private:
CConf m_conf; CConf m_conf;
CModem* m_modem; CModem* m_modem;
CDStarNetwork* m_dstarNetwork; CDStarNetwork* m_dstarNetwork;
CHomebrewDMRIPSC* m_dmrNetwork; CDMRIPSC* m_dmrNetwork;
IDisplay* m_display; IDisplay* m_display;
unsigned char m_mode; unsigned char m_mode;
CTimer m_modeTimer; CTimer m_modeTimer;
bool m_dstarEnabled; bool m_dstarEnabled;
bool m_dmrEnabled; bool m_dmrEnabled;
bool m_ysfEnabled; bool m_ysfEnabled;
void readParams(); void readParams();
bool createModem(); bool createModem();

View File

@ -150,28 +150,29 @@
<ClInclude Include="BPTC19696.h" /> <ClInclude Include="BPTC19696.h" />
<ClInclude Include="Conf.h" /> <ClInclude Include="Conf.h" />
<ClInclude Include="CRC.h" /> <ClInclude Include="CRC.h" />
<ClInclude Include="CSBK.h" />
<ClInclude Include="Defines.h" /> <ClInclude Include="Defines.h" />
<ClInclude Include="Display.h" /> <ClInclude Include="Display.h" />
<ClInclude Include="DMRControl.h" /> <ClInclude Include="DMRControl.h" />
<ClInclude Include="DMRCSBK.h" />
<ClInclude Include="DMRData.h" /> <ClInclude Include="DMRData.h" />
<ClInclude Include="DMRDataHeader.h" /> <ClInclude Include="DMRDataHeader.h" />
<ClInclude Include="DMRDefines.h" /> <ClInclude Include="DMRDefines.h" />
<ClInclude Include="DMREMB.h" />
<ClInclude Include="DMREmbeddedLC.h" />
<ClInclude Include="DMRFullLC.h" />
<ClInclude Include="DMRIPSC.h" />
<ClInclude Include="DMRLC.h" />
<ClInclude Include="DMRShortLC.h" />
<ClInclude Include="DMRSlot.h" /> <ClInclude Include="DMRSlot.h" />
<ClInclude Include="DMRSync.h" /> <ClInclude Include="DMRSlotType.h" />
<ClInclude Include="DStarControl.h" /> <ClInclude Include="DStarControl.h" />
<ClInclude Include="DStarDefines.h" /> <ClInclude Include="DStarDefines.h" />
<ClInclude Include="DStarHeader.h" /> <ClInclude Include="DStarHeader.h" />
<ClInclude Include="DStarNetwork.h" /> <ClInclude Include="DStarNetwork.h" />
<ClInclude Include="DStarSlowData.h" /> <ClInclude Include="DStarSlowData.h" />
<ClInclude Include="EMB.h" />
<ClInclude Include="EmbeddedLC.h" />
<ClInclude Include="FullLC.h" />
<ClInclude Include="Golay2087.h" /> <ClInclude Include="Golay2087.h" />
<ClInclude Include="Golay24128.h" /> <ClInclude Include="Golay24128.h" />
<ClInclude Include="Hamming.h" /> <ClInclude Include="Hamming.h" />
<ClInclude Include="HomebrewDMRIPSC.h" />
<ClInclude Include="LC.h" />
<ClInclude Include="Log.h" /> <ClInclude Include="Log.h" />
<ClInclude Include="MMDVMHost.h" /> <ClInclude Include="MMDVMHost.h" />
<ClInclude Include="Modem.h" /> <ClInclude Include="Modem.h" />
@ -181,9 +182,8 @@
<ClInclude Include="RS129.h" /> <ClInclude Include="RS129.h" />
<ClInclude Include="SerialController.h" /> <ClInclude Include="SerialController.h" />
<ClInclude Include="SHA256.h" /> <ClInclude Include="SHA256.h" />
<ClInclude Include="ShortLC.h" />
<ClInclude Include="SlotType.h" />
<ClInclude Include="StopWatch.h" /> <ClInclude Include="StopWatch.h" />
<ClInclude Include="Sync.h" />
<ClInclude Include="TFTSerial.h" /> <ClInclude Include="TFTSerial.h" />
<ClInclude Include="Timer.h" /> <ClInclude Include="Timer.h" />
<ClInclude Include="UDPSocket.h" /> <ClInclude Include="UDPSocket.h" />
@ -199,25 +199,26 @@
<ClCompile Include="BPTC19696.cpp" /> <ClCompile Include="BPTC19696.cpp" />
<ClCompile Include="Conf.cpp" /> <ClCompile Include="Conf.cpp" />
<ClCompile Include="CRC.cpp" /> <ClCompile Include="CRC.cpp" />
<ClCompile Include="CSBK.cpp" />
<ClCompile Include="Display.cpp" /> <ClCompile Include="Display.cpp" />
<ClCompile Include="DMRControl.cpp" /> <ClCompile Include="DMRControl.cpp" />
<ClCompile Include="DMRCSBK.cpp" />
<ClCompile Include="DMRData.cpp" /> <ClCompile Include="DMRData.cpp" />
<ClCompile Include="DMRDataHeader.cpp" /> <ClCompile Include="DMRDataHeader.cpp" />
<ClCompile Include="DMREMB.cpp" />
<ClCompile Include="DMREmbeddedLC.cpp" />
<ClCompile Include="DMRFullLC.cpp" />
<ClCompile Include="DMRIPSC.cpp" />
<ClCompile Include="DMRLC.cpp" />
<ClCompile Include="DMRShortLC.cpp" />
<ClCompile Include="DMRSlot.cpp" /> <ClCompile Include="DMRSlot.cpp" />
<ClCompile Include="DMRSync.cpp" /> <ClCompile Include="DMRSlotType.cpp" />
<ClCompile Include="DStarControl.cpp" /> <ClCompile Include="DStarControl.cpp" />
<ClCompile Include="DStarHeader.cpp" /> <ClCompile Include="DStarHeader.cpp" />
<ClCompile Include="DStarNetwork.cpp" /> <ClCompile Include="DStarNetwork.cpp" />
<ClCompile Include="DStarSlowData.cpp" /> <ClCompile Include="DStarSlowData.cpp" />
<ClCompile Include="EMB.cpp" />
<ClCompile Include="EmbeddedLC.cpp" />
<ClCompile Include="FullLC.cpp" />
<ClCompile Include="Golay2087.cpp" /> <ClCompile Include="Golay2087.cpp" />
<ClCompile Include="Golay24128.cpp" /> <ClCompile Include="Golay24128.cpp" />
<ClCompile Include="Hamming.cpp" /> <ClCompile Include="Hamming.cpp" />
<ClCompile Include="HomebrewDMRIPSC.cpp" />
<ClCompile Include="LC.cpp" />
<ClCompile Include="Log.cpp" /> <ClCompile Include="Log.cpp" />
<ClCompile Include="MMDVMHost.cpp" /> <ClCompile Include="MMDVMHost.cpp" />
<ClCompile Include="Modem.cpp" /> <ClCompile Include="Modem.cpp" />
@ -226,9 +227,8 @@
<ClCompile Include="RS129.cpp" /> <ClCompile Include="RS129.cpp" />
<ClCompile Include="SerialController.cpp" /> <ClCompile Include="SerialController.cpp" />
<ClCompile Include="SHA256.cpp" /> <ClCompile Include="SHA256.cpp" />
<ClCompile Include="ShortLC.cpp" />
<ClCompile Include="SlotType.cpp" />
<ClCompile Include="StopWatch.cpp" /> <ClCompile Include="StopWatch.cpp" />
<ClCompile Include="Sync.cpp" />
<ClCompile Include="TFTSerial.cpp" /> <ClCompile Include="TFTSerial.cpp" />
<ClCompile Include="Timer.cpp" /> <ClCompile Include="Timer.cpp" />
<ClCompile Include="UDPSocket.cpp" /> <ClCompile Include="UDPSocket.cpp" />

View File

@ -20,9 +20,6 @@
<ClInclude Include="CRC.h"> <ClInclude Include="CRC.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CSBK.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Defines.h"> <ClInclude Include="Defines.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -41,21 +38,9 @@
<ClInclude Include="DMRSlot.h"> <ClInclude Include="DMRSlot.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="DMRSync.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DStarDefines.h"> <ClInclude Include="DStarDefines.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="EMB.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EmbeddedLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FullLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Golay2087.h"> <ClInclude Include="Golay2087.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -65,12 +50,6 @@
<ClInclude Include="Hamming.h"> <ClInclude Include="Hamming.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="HomebrewDMRIPSC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Log.h"> <ClInclude Include="Log.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -98,12 +77,6 @@
<ClInclude Include="SHA256.h"> <ClInclude Include="SHA256.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ShortLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SlotType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StopWatch.h"> <ClInclude Include="StopWatch.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -152,6 +125,33 @@
<ClInclude Include="YSFFICH.h"> <ClInclude Include="YSFFICH.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="DMRCSBK.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Sync.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMREMB.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMREmbeddedLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMRFullLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMRIPSC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMRLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMRShortLC.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DMRSlotType.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="BPTC19696.cpp"> <ClCompile Include="BPTC19696.cpp">
@ -163,9 +163,6 @@
<ClCompile Include="CRC.cpp"> <ClCompile Include="CRC.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CSBK.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Display.cpp"> <ClCompile Include="Display.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -178,18 +175,6 @@
<ClCompile Include="DMRSlot.cpp"> <ClCompile Include="DMRSlot.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="DMRSync.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EMB.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EmbeddedLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FullLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Golay2087.cpp"> <ClCompile Include="Golay2087.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -199,12 +184,6 @@
<ClCompile Include="Hamming.cpp"> <ClCompile Include="Hamming.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="HomebrewDMRIPSC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Log.cpp"> <ClCompile Include="Log.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -229,12 +208,6 @@
<ClCompile Include="SHA256.cpp"> <ClCompile Include="SHA256.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ShortLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SlotType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StopWatch.cpp"> <ClCompile Include="StopWatch.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -277,5 +250,32 @@
<ClCompile Include="YSFFICH.cpp"> <ClCompile Include="YSFFICH.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="DMRCSBK.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Sync.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMREMB.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMREmbeddedLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMRFullLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMRIPSC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMRLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMRShortLC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DMRSlotType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,10 +5,9 @@ LIBS =
LDFLAGS = -g LDFLAGS = -g
OBJECTS = \ 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 \ 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 \
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 \ 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 \
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 \ 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
YSFEcho.o YSFFICH.o
all: MMDVMHost all: MMDVMHost

View File

@ -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 <cstdio>
#include <cassert>
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;
}

View File

@ -16,22 +16,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "DMRSync.h" #include "Sync.h"
#include "DMRDefines.h" #include "DMRDefines.h"
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
CDMRSync::CDMRSync() void CSync::addDMRDataSync(unsigned char* data)
{
}
CDMRSync::~CDMRSync()
{
}
void CDMRSync::addDataSync(unsigned char* data) const
{ {
assert(data != NULL); 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]; 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); assert(data != NULL);

View File

@ -16,18 +16,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(DMRSYNC_H) #if !defined(SYNC_H)
#define DMRSYNC_H #define SYNC_H
class CDMRSync class CSync
{ {
public: public:
CDMRSync(); static void addDMRDataSync(unsigned char* data);
~CDMRSync(); static void addDMRAudioSync(unsigned char* data);
void addDataSync(unsigned char* data) const;
void addAudioSync(unsigned char* data) const;
private: private:
}; };