Skip to content

Commit

Permalink
Final modem refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Feb 17, 2021
1 parent 279afb7 commit e291096
Show file tree
Hide file tree
Showing 30 changed files with 3,159 additions and 3,314 deletions.
4 changes: 2 additions & 2 deletions CASTInfo.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018,2020,2021 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
Expand All @@ -21,7 +21,7 @@
static bool networkInfoInitialized = false;
static unsigned char passCounter = 0;

CCASTInfo::CCASTInfo(IModem* modem) :
CCASTInfo::CCASTInfo(CModem* modem) :
CDisplay(),
m_modem(modem),
m_ipaddress()
Expand Down
7 changes: 4 additions & 3 deletions CASTInfo.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018,2020,2021 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
Expand All @@ -25,10 +25,11 @@

#include "NetworkInfo.h"
#include "Modem.h"

class CCASTInfo : public CDisplay
{
public:
CCASTInfo(IModem* modem);
CCASTInfo(CModem* modem);
virtual ~CCASTInfo();

virtual bool open();
Expand Down Expand Up @@ -67,7 +68,7 @@ class CCASTInfo : public CDisplay
virtual void clearCWInt();

private:
IModem* m_modem;
CModem* m_modem;
std::string m_ipaddress;
};

Expand Down
4 changes: 2 additions & 2 deletions DMRControl.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX
* Copyright (C) 2015-2021 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
Expand All @@ -21,7 +21,7 @@
#include <cassert>
#include <algorithm>

CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, IModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM_TYPES ovcm) :
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM_TYPES ovcm) :
m_colorCode(colorCode),
m_modem(modem),
m_network(network),
Expand Down
6 changes: 3 additions & 3 deletions DMRControl.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021 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
Expand Down Expand Up @@ -31,7 +31,7 @@

class CDMRControl {
public:
CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, IModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM_TYPES ovcm);
CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM_TYPES ovcm);
~CDMRControl();

bool processWakeup(const unsigned char* data);
Expand All @@ -50,7 +50,7 @@ class CDMRControl {

private:
unsigned int m_colorCode;
IModem* m_modem;
CModem* m_modem;
IDMRNetwork* m_network;
CDMRSlot m_slot1;
CDMRSlot m_slot2;
Expand Down
6 changes: 3 additions & 3 deletions DMRSlot.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX
* Copyright (C) 2015-2021 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
Expand Down Expand Up @@ -37,7 +37,7 @@ unsigned int CDMRSlot::m_colorCode = 0U;
bool CDMRSlot::m_embeddedLCOnly = false;
bool CDMRSlot::m_dumpTAData = true;

IModem* CDMRSlot::m_modem = NULL;
CModem* CDMRSlot::m_modem = NULL;
IDMRNetwork* CDMRSlot::m_network = NULL;
CDisplay* CDMRSlot::m_display = NULL;
bool CDMRSlot::m_duplex = true;
Expand Down Expand Up @@ -1896,7 +1896,7 @@ void CDMRSlot::writeQueueNet(const unsigned char *data)
m_queue.addData(data, len);
}

void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, IModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM_TYPES ovcm)
void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM_TYPES ovcm)
{
assert(modem != NULL);
assert(display != NULL);
Expand Down
6 changes: 3 additions & 3 deletions DMRSlot.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021 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
Expand Down Expand Up @@ -62,7 +62,7 @@ class CDMRSlot {

void enable(bool enabled);

static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, IModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM_TYPES ovcm);
static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM_TYPES ovcm);

private:
unsigned int m_slotNo;
Expand Down Expand Up @@ -117,7 +117,7 @@ class CDMRSlot {
static bool m_embeddedLCOnly;
static bool m_dumpTAData;

static IModem* m_modem;
static CModem* m_modem;
static IDMRNetwork* m_network;
static CDisplay* m_display;
static bool m_duplex;
Expand Down
2 changes: 1 addition & 1 deletion Display.cpp
Expand Up @@ -535,7 +535,7 @@ int CDisplay::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsig


/* Factory method extracted from MMDVMHost.cpp - BG5HHP */
CDisplay* CDisplay::createDisplay(const CConf& conf, IModem* modem)
CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
{
CDisplay *display = NULL;

Expand Down
6 changes: 3 additions & 3 deletions Display.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2021 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
Expand Down Expand Up @@ -28,7 +28,7 @@
#include <cstdint>

class CConf;
class IModem;
class CModem;

class CDisplay
{
Expand Down Expand Up @@ -86,7 +86,7 @@ class CDisplay

void clock(unsigned int ms);

static CDisplay* createDisplay(const CConf& conf, IModem* modem);
static CDisplay* createDisplay(const CConf& conf, CModem* modem);

protected:
virtual void setIdleInt() = 0;
Expand Down
4 changes: 2 additions & 2 deletions I2CController.h
Expand Up @@ -22,12 +22,12 @@

#if defined(__linux__)

#include "MMDVMModemPort.h"
#include "ModemPort.h"
#include "SerialPort.h"

#include <string>

class CI2CController : public ISerialPort, public IMMDVMModemPort {
class CI2CController : public ISerialPort, public IModemPort {
public:
CI2CController(const std::string& device, unsigned int address = 0x22U);
virtual ~CI2CController();
Expand Down
15 changes: 7 additions & 8 deletions MMDVMHost.cpp
Expand Up @@ -28,7 +28,6 @@
#include "I2CController.h"
#endif
#include "UDPController.h"
#include "MMDVMModem.h"
#include "Version.h"
#include "StopWatch.h"
#include "Defines.h"
Expand Down Expand Up @@ -1407,23 +1406,23 @@ bool CMMDVMHost::createModem()
LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset);
LogInfo(" Use COS as Lockout: %s", useCOSAsLockout ? "yes" : "no");

m_modem = new CMMDVMModem(m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug);
m_modem = new CModem(m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug);

IMMDVMModemPort* modem = NULL;
IModemPort* port = NULL;
if (protocol == "uart")
modem = new CUARTController(uartPort, uartSpeed, true);
port = new CUARTController(uartPort, uartSpeed, true);
else if (protocol == "udp")
modem = new CUDPController(modemAddress, modemPort, localPort);
port = new CUDPController(modemAddress, modemPort, localPort);
#if defined(__linux__)
else if (protocol == "i2c")
modem = new CI2CController(i2cPort, i2cAddress);
port = new CI2CController(i2cPort, i2cAddress);
#endif
else if (protocol == "null")
modem = new CNullController;
port = new CNullController;
else
return false;

m_modem->setModem(modem);
m_modem->setPort(port);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_m17Enabled, m_pocsagEnabled, m_fmEnabled, m_ax25Enabled);
m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, m17TXLevel, pocsagTXLevel, fmTXLevel, ax25TXLevel);
m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency);
Expand Down
4 changes: 2 additions & 2 deletions MMDVMHost.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021 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
Expand Down Expand Up @@ -58,7 +58,7 @@ class CMMDVMHost

private:
CConf m_conf;
IModem* m_modem;
CModem* m_modem;
CDStarControl* m_dstar;
CDMRControl* m_dmr;
CYSFControl* m_ysf;
Expand Down
10 changes: 4 additions & 6 deletions MMDVMHost.vcxproj
Expand Up @@ -203,8 +203,7 @@
<ClInclude Include="M17Network.h" />
<ClInclude Include="M17Utils.h" />
<ClInclude Include="MMDVMHost.h" />
<ClInclude Include="MMDVMModemPort.h" />
<ClInclude Include="Modem.h" />
<ClInclude Include="ModemPort.h" />
<ClInclude Include="ModemSerialPort.h" />
<ClInclude Include="Mutex.h" />
<ClInclude Include="NetworkInfo.h" />
Expand Down Expand Up @@ -245,7 +244,7 @@
<ClInclude Include="RSSIInterpolator.h" />
<ClInclude Include="NXDNSACCH.h" />
<ClInclude Include="UARTController.h" />
<ClInclude Include="MMDVMModem.h" />
<ClInclude Include="Modem.h" />
<ClInclude Include="SerialPort.h" />
<ClInclude Include="SHA256.h" />
<ClInclude Include="StopWatch.h" />
Expand Down Expand Up @@ -313,8 +312,7 @@
<ClCompile Include="M17Network.cpp" />
<ClCompile Include="M17Utils.cpp" />
<ClCompile Include="MMDVMHost.cpp" />
<ClCompile Include="MMDVMModemPort.cpp" />
<ClCompile Include="Modem.cpp" />
<ClCompile Include="ModemPort.cpp" />
<ClCompile Include="ModemSerialPort.cpp" />
<ClCompile Include="Mutex.cpp" />
<ClCompile Include="NetworkInfo.cpp" />
Expand Down Expand Up @@ -351,7 +349,7 @@
<ClCompile Include="RS241213.cpp" />
<ClCompile Include="RSSIInterpolator.cpp" />
<ClCompile Include="UARTController.cpp" />
<ClCompile Include="MMDVMModem.cpp" />
<ClCompile Include="Modem.cpp" />
<ClCompile Include="SerialPort.cpp" />
<ClCompile Include="SHA256.cpp" />
<ClCompile Include="StopWatch.cpp" />
Expand Down
26 changes: 10 additions & 16 deletions MMDVMHost.vcxproj.filters
Expand Up @@ -56,9 +56,6 @@
<ClInclude Include="MMDVMHost.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Modem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NullDisplay.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -335,19 +332,19 @@
<ClInclude Include="SHA256.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MMDVMModem.h">
<ClInclude Include="UARTController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UARTController.h">
<ClInclude Include="UDPController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MMDVMModemPort.h">
<ClInclude Include="NullController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UDPController.h">
<ClInclude Include="Modem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NullController.h">
<ClInclude Include="ModemPort.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down Expand Up @@ -388,9 +385,6 @@
<ClCompile Include="MMDVMHost.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Modem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NullDisplay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -643,19 +637,19 @@
<ClCompile Include="SHA256.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MMDVMModem.cpp">
<ClCompile Include="UARTController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UARTController.cpp">
<ClCompile Include="UDPController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MMDVMModemPort.cpp">
<ClCompile Include="NullController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UDPController.cpp">
<ClCompile Include="Modem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NullController.cpp">
<ClCompile Include="ModemPort.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down

0 comments on commit e291096

Please sign in to comment.