From 945d79a3caababddadae17470c98f76f051ab7c9 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 15 Feb 2016 20:36:05 +0000 Subject: [PATCH] Allow for the disabling of individual slots from the network. --- Conf.cpp | 16 ++++++++++++++++ Conf.h | 4 ++++ DMRIPSC.cpp | 17 ++++++++++++++++- DMRIPSC.h | 4 +++- MMDVM.ini | 2 ++ MMDVMHost.cpp | 6 +++++- 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index a42405c..7264a39 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -85,6 +85,8 @@ m_dmrNetworkAddress(), m_dmrNetworkPort(0U), m_dmrNetworkPassword(), m_dmrNetworkDebug(false), +m_dmrNetworkSlot1(true), +m_dmrNetworkSlot2(true), m_fusionNetworkEnabled(false), m_fusionNetworkAddress(), m_fusionNetworkPort(0U), @@ -241,6 +243,10 @@ bool CConf::read() m_dmrNetworkPassword = value; else if (::strcmp(key, "Debug") == 0) m_dmrNetworkDebug = ::atoi(value) == 1; + else if (::strcmp(key, "Slot1") == 0) + m_dmrNetworkSlot1 = ::atoi(value) == 1; + else if (::strcmp(key, "Slot2") == 0) + m_dmrNetworkSlot2 = ::atoi(value) == 1; } else if (section == SECTION_FUSION_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fusionNetworkEnabled = ::atoi(value) == 1; @@ -476,6 +482,16 @@ bool CConf::getDMRNetworkDebug() const return m_dmrNetworkDebug; } +bool CConf::getDMRNetworkSlot1() const +{ + return m_dmrNetworkSlot1; +} + +bool CConf::getDMRNetworkSlot2() const +{ + return m_dmrNetworkSlot2; +} + bool CConf::getFusionNetworkEnabled() const { return m_fusionNetworkEnabled; diff --git a/Conf.h b/Conf.h index d01cd19..a35f043 100644 --- a/Conf.h +++ b/Conf.h @@ -89,6 +89,8 @@ public: unsigned int getDMRNetworkPort() const; std::string getDMRNetworkPassword() const; bool getDMRNetworkDebug() const; + bool getDMRNetworkSlot1() const; + bool getDMRNetworkSlot2() const; // The System Fusion Network section bool getFusionNetworkEnabled() const; @@ -152,6 +154,8 @@ private: unsigned int m_dmrNetworkPort; std::string m_dmrNetworkPassword; bool m_dmrNetworkDebug; + bool m_dmrNetworkSlot1; + bool m_dmrNetworkSlot2; bool m_fusionNetworkEnabled; std::string m_fusionNetworkAddress; diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index 8187168..f7291e8 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -30,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 53U; -CDMRIPSC::CDMRIPSC(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, bool slot1, bool slot2) : m_address(), m_port(port), m_id(NULL), @@ -40,6 +40,8 @@ m_software(software), m_version(version), m_socket(), m_enabled(false), +m_slot1(slot1), +m_slot2(slot2), m_status(DISCONNECTED), m_retryTimer(1000U, 10U), m_timeoutTimer(1000U, 600U), @@ -159,6 +161,12 @@ bool CDMRIPSC::read(CDMRData& data) unsigned int slotNo = (m_buffer[15U] & 0x80U) == 0x80U ? 2U : 1U; + // Individual slot disabling + if (slotNo == 1U && !m_slot1) + return false; + if (slotNo == 2U && !m_slot2) + return false; + FLCO flco = (m_buffer[15U] & 0x40U) == 0x40U ? FLCO_USER_USER : FLCO_GROUP; data.setSeqNo(seqNo); @@ -215,6 +223,13 @@ bool CDMRIPSC::write(const CDMRData& data) ::memcpy(buffer + 11U, m_id, 4U); unsigned int slotNo = data.getSlotNo(); + + // Individual slot disabling + if (slotNo == 1U && !m_slot1) + return false; + if (slotNo == 2U && !m_slot2) + return false; + buffer[15U] = slotNo == 1U ? 0x00U : 0x80U; FLCO flco = data.getFLCO(); diff --git a/DMRIPSC.h b/DMRIPSC.h index 244c41e..da8a16c 100644 --- a/DMRIPSC.h +++ b/DMRIPSC.h @@ -30,7 +30,7 @@ class CDMRIPSC { public: - CDMRIPSC(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, bool slot1, bool slot2); ~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); @@ -59,6 +59,8 @@ private: const char* m_version; CUDPSocket m_socket; bool m_enabled; + bool m_slot1; + bool m_slot2; enum STATUS { DISCONNECTED, diff --git a/MMDVM.ini b/MMDVM.ini index ebc45c8..c358a8d 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -59,6 +59,8 @@ Enable=1 Address=44.131.4.1 Port=62031 Password=PASSWORD +Slot1=1 +Slot2=1 Debug=1 [System Fusion Network] diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2a551c9..007e860 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -441,12 +441,16 @@ bool CMMDVMHost::createDMRNetwork() unsigned int id = m_conf.getDMRId(); std::string password = m_conf.getDMRNetworkPassword(); bool debug = m_conf.getDMRNetworkDebug(); + bool slot1 = m_conf.getDMRNetworkSlot1(); + bool slot2 = m_conf.getDMRNetworkSlot2(); LogInfo("DMR Network Parameters"); LogInfo(" Address: %s", address.c_str()); LogInfo(" Port: %u", port); + LogInfo(" Slot 1: %s", slot1 ? "enabled" : "disabled"); + LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); - m_dmrNetwork = new CDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug); + m_dmrNetwork = new CDMRIPSC(address, port, id, password, VERSION, "MMDVM", debug, slot1, slot2); std::string callsign = m_conf.getCallsign(); unsigned int rxFrequency = m_conf.getRxFrequency();