From 72bae08c874177cbe7d91938334840a4ac46d3fa Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 10 Apr 2017 17:57:55 +0100 Subject: [PATCH] Add DMR network virtualisation. --- DMRControl.cpp | 2 +- DMRControl.h | 4 ++-- DMRNetwork.cpp | 3 +++ DMRNetwork.h | 48 ++++++++++++++++++++++++++++++++++++------------ DMRSlot.cpp | 4 ++-- DMRSlot.h | 4 ++-- MMDVMHost.h | 2 +- 7 files changed, 47 insertions(+), 20 deletions(-) diff --git a/DMRControl.cpp b/DMRControl.cpp index 291351d..c555ffe 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -21,7 +21,7 @@ #include #include -CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) : +CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) : m_id(id), m_colorCode(colorCode), m_modem(modem), diff --git a/DMRControl.h b/DMRControl.h index acfe072..dad09f1 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -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& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter); + CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter); ~CDMRControl(); bool processWakeup(const unsigned char* data); @@ -48,7 +48,7 @@ private: unsigned int m_id; unsigned int m_colorCode; CModem* m_modem; - CDMRNetwork* m_network; + IDMRNetwork* m_network; CDMRSlot m_slot1; CDMRSlot m_slot2; CDMRLookup* m_lookup; diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 5101fb1..c69ffc7 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -30,6 +30,9 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; +IDMRNetwork::~IDMRNetwork() +{ +} CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType) : m_address(), diff --git a/DMRNetwork.h b/DMRNetwork.h index 325b2ea..ce85222 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -28,29 +28,53 @@ #include #include -class CDMRNetwork -{ +class IDMRNetwork { +public: + virtual ~IDMRNetwork() = 0; + + virtual void setOptions(const std::string& options) = 0; + + virtual 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) = 0; + + virtual bool open() = 0; + + virtual void enable(bool enabled) = 0; + + virtual bool read(CDMRData& data) = 0; + + virtual bool write(const CDMRData& data) = 0; + + virtual bool wantsBeacon() = 0; + + virtual void clock(unsigned int ms) = 0; + + virtual void close() = 0; + +private: +}; + +class CDMRNetwork : public IDMRNetwork { public: CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType); - ~CDMRNetwork(); + virtual ~CDMRNetwork(); - void setOptions(const std::string& options); + virtual void setOptions(const std::string& options); - 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); + virtual 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); - bool open(); + virtual bool open(); - void enable(bool enabled); + virtual void enable(bool enabled); - bool read(CDMRData& data); + virtual bool read(CDMRData& data); - bool write(const CDMRData& data); + virtual bool write(const CDMRData& data); - bool wantsBeacon(); + virtual bool wantsBeacon(); - void clock(unsigned int ms); + virtual void clock(unsigned int ms); - void close(); + virtual void close(); private: in_addr m_address; diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 2bee5bb..3632fef 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -35,7 +35,7 @@ bool CDMRSlot::m_embeddedLCOnly = false; bool CDMRSlot::m_dumpTAData = true; CModem* CDMRSlot::m_modem = NULL; -CDMRNetwork* CDMRSlot::m_network = NULL; +IDMRNetwork* CDMRSlot::m_network = NULL; CDisplay* CDMRSlot::m_display = NULL; bool CDMRSlot::m_duplex = true; CDMRLookup* CDMRSlot::m_lookup = NULL; @@ -1683,7 +1683,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, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter) +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) { assert(modem != NULL); assert(display != NULL); diff --git a/DMRSlot.h b/DMRSlot.h index cde13a9..725e0a6 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -50,7 +50,7 @@ public: void clock(); - static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter); + 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); private: unsigned int m_slotNo; @@ -106,7 +106,7 @@ private: static bool m_dumpTAData; static CModem* m_modem; - static CDMRNetwork* m_network; + static IDMRNetwork* m_network; static CDisplay* m_display; static bool m_duplex; static CDMRLookup* m_lookup; diff --git a/MMDVMHost.h b/MMDVMHost.h index 70868b0..655ed71 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -44,7 +44,7 @@ private: CConf m_conf; CModem* m_modem; CDStarNetwork* m_dstarNetwork; - CDMRNetwork* m_dmrNetwork; + IDMRNetwork* m_dmrNetwork; CYSFNetwork* m_ysfNetwork; CP25Network* m_p25Network; CDisplay* m_display;