Allow for the disabling of individual slots from the network.

This commit is contained in:
Jonathan Naylor 2016-02-15 20:36:05 +00:00
parent e47d031818
commit 945d79a3ca
6 changed files with 46 additions and 3 deletions

View file

@ -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;

4
Conf.h
View file

@ -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;

View file

@ -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();

View file

@ -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,

View file

@ -59,6 +59,8 @@ Enable=1
Address=44.131.4.1
Port=62031
Password=PASSWORD
Slot1=1
Slot2=1
Debug=1
[System Fusion Network]

View file

@ -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();