diff --git a/AX25Control.cpp b/AX25Control.cpp index c9fd750..bd60c9c 100644 --- a/AX25Control.cpp +++ b/AX25Control.cpp @@ -16,6 +16,8 @@ #include "Utils.h" #include "Log.h" +#if defined(USE_AX25) + #include #include #include @@ -28,13 +30,13 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04 #define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) -CAX25Control::CAX25Control(CAX25Network* network, bool trace) : +CAX25Control::CAX25Control(CAX25Network* network, bool trace, CRSSIInterpolator* rssiMapper) : m_network(network), m_trace(trace), m_rssiMapper(rssiMapper), m_enabled(true) { - assert(rssiMapper != NULL); + assert(rssiMapper != nullptr); } CAX25Control::~CAX25Control() @@ -203,8 +205,8 @@ void CAX25Control::decode(const unsigned char* data, unsigned int length) void CAX25Control::decodeJSON(const char* source, const unsigned char* data, unsigned int length, int rssi) { - assert(source != NULL); - assert(data != NULL); + assert(source != nullptr); + assert(data != nullptr); assert(length >= 15U); nlohmann::json json; @@ -375,7 +377,7 @@ bool CAX25Control::decodeAddress(const unsigned char* data, std::string& text, b bool CAX25Control::decodeAddressJSON(const unsigned char* data, std::string& text, bool& isDigi) const { - assert(data != NULL); + assert(data != nullptr); text.clear(); @@ -402,4 +404,3 @@ bool CAX25Control::decodeAddressJSON(const unsigned char* data, std::string& tex } #endif - diff --git a/AX25Network.cpp b/AX25Network.cpp index 613d05f..77ee176 100644 --- a/AX25Network.cpp +++ b/AX25Network.cpp @@ -52,9 +52,9 @@ bool CAX25Network::open() bool CAX25Network::write(const unsigned char* data, unsigned int length) { - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); - assert(m_mqtt != NULL); + assert(m_mqtt != nullptr); if (!m_enabled) return true; @@ -95,7 +95,7 @@ bool CAX25Network::write(const unsigned char* data, unsigned int length) unsigned int CAX25Network::read(unsigned char* data, unsigned int length) { - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_buffer.isEmpty()) @@ -153,7 +153,7 @@ unsigned int CAX25Network::read(unsigned char* data, unsigned int length) void CAX25Network::setData(const unsigned char* data, unsigned int length) { - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); m_mutex.lock(); diff --git a/Conf.cpp b/Conf.cpp index 2d74831..5789fd0 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -27,77 +27,77 @@ const int BUFFER_SIZE = 500; -enum SECTION { - SECTION_NONE, - SECTION_GENERAL, - SECTION_INFO, - SECTION_LOG, - SECTION_MQTT, - SECTION_CWID, +enum class SECTION { + NONE, + GENERAL, + INFO, + LOG, + MQTT, + CWID, #if defined(USE_DMR) || defined(USE_P25) - SECTION_DMRID_LOOKUP, + DMRID_LOOKUP, #endif #if defined(USE_NXDN) - SECTION_NXDNID_LOOKUP, + NXDNID_LOOKUP, #endif - SECTION_MODEM, - SECTION_TRANSPARENT, + MODEM, + TRANSPARENT, #if defined(USE_DSTAR) - SECTION_DSTAR, + DSTAR, #endif #if defined(USE_DMR) - SECTION_DMR, + DMR, #endif #if defined(USE_YSF) - SECTION_FUSION, + FUSION, #endif #if defined(USE_P25) - SECTION_P25, + P25, #endif #if defined(USE_NXDN) - SECTION_NXDN, + NXDN, #endif #if defined(USE_M17) - SECTION_M17, + M17, #endif #if defined(USE_POCSAG) - SECTION_POCSAG, + POCSAG, #endif #if defined(USE_FM) - SECTION_FM, + FM, #endif #if defined(USE_AX25) - SECTION_AX25, + AX25, #endif #if defined(USE_DSTAR) - SECTION_DSTAR_NETWORK, + DSTAR_NETWORK, #endif #if defined(USE_DMR) - SECTION_DMR_NETWORK, + DMR_NETWORK, #endif #if defined(USE_YSF) - SECTION_FUSION_NETWORK, + FUSION_NETWORK, #endif #if defined(USE_P25) - SECTION_P25_NETWORK, + P25_NETWORK, #endif #if defined(USE_NXDN) - SECTION_NXDN_NETWORK, + NXDN_NETWORK, #endif #if defined(USE_M17) - SECTION_M17_NETWORK, + M17_NETWORK, #endif #if defined(USE_POCSAG) - SECTION_POCSAG_NETWORK, + POCSAG_NETWORK, #endif #if defined(USE_FM) - SECTION_FM_NETWORK, + FM_NETWORK, #endif #if defined(USE_AX25) - SECTION_AX25_NETWORK, + AX25_NETWORK, #endif - SECTION_LOCK_FILE, - SECTION_REMOTE_CONTROL + LOCK_FILE, + REMOTE_CONTROL }; CConf::CConf(const std::string& file) : @@ -212,7 +212,8 @@ m_dmrTXHang(4U), #endif m_dmrModeHang(10U), #if defined(USE_DMR) -m_dmrOVCM(DMR_OVCM_OFF), +m_dmrOVCM(DMR_OVCM::OFF), +m_dmrProtect(false), #endif #if defined(USE_YSF) m_fusionEnabled(false), @@ -434,94 +435,94 @@ bool CConf::read() else if (::strncmp(buffer, "[Info]", 6U) == 0) section = SECTION::INFO; else if (::strncmp(buffer, "[Log]", 5U) == 0) - section = SECTION_LOG; + section = SECTION::LOG; else if (::strncmp(buffer, "[MQTT]", 6U) == 0) - section = SECTION_MQTT; + section = SECTION::MQTT; else if (::strncmp(buffer, "[CW Id]", 7U) == 0) - section = SECTION_CWID; + section = SECTION::CWID; #if defined(USE_DMR) || defined(USE_P25) else if (::strncmp(buffer, "[DMR Id Lookup]", 15U) == 0) - section = SECTION_DMRID_LOOKUP; + section = SECTION::DMRID_LOOKUP; #endif #if defined(USE_NXDN) else if (::strncmp(buffer, "[NXDN Id Lookup]", 16U) == 0) - section = SECTION_NXDNID_LOOKUP; + section = SECTION::NXDNID_LOOKUP; #endif else if (::strncmp(buffer, "[Modem]", 7U) == 0) section = SECTION::MODEM; else if (::strncmp(buffer, "[Transparent Data]", 18U) == 0) - section = SECTION_TRANSPARENT; + section = SECTION::TRANSPARENT; #if defined(USE_DSTAR) else if (::strncmp(buffer, "[D-Star]", 8U) == 0) - section = SECTION_DSTAR; + section = SECTION::DSTAR; #endif #if defined(USE_DMR) else if (::strncmp(buffer, "[DMR]", 5U) == 0) - section = SECTION_DMR; + section = SECTION::DMR; #endif #if defined(USE_YSF) else if (::strncmp(buffer, "[System Fusion]", 15U) == 0) - section = SECTION_FUSION; + section = SECTION::FUSION; #endif #if defined(USE_P25) else if (::strncmp(buffer, "[P25]", 5U) == 0) - section = SECTION_P25; + section = SECTION::P25; #endif #if defined(USE_NXDN) else if (::strncmp(buffer, "[NXDN]", 6U) == 0) - section = SECTION_NXDN; + section = SECTION::NXDN; #endif #if defined(USE_M17) else if (::strncmp(buffer, "[M17]", 5U) == 0) - section = SECTION_M17; + section = SECTION::M17; #endif #if defined(USE_POCSAG) else if (::strncmp(buffer, "[POCSAG]", 8U) == 0) - section = SECTION_POCSAG; + section = SECTION::POCSAG; #endif #if defined(USE_FM) else if (::strncmp(buffer, "[FM]", 4U) == 0) - section = SECTION_FM; + section = SECTION::FM; #endif #if defined(USE_AX25) else if (::strncmp(buffer, "[AX.25]", 7U) == 0) - section = SECTION_AX25; + section = SECTION::AX25; #endif #if defined(USE_DSTAR) else if (::strncmp(buffer, "[D-Star Network]", 16U) == 0) - section = SECTION_DSTAR_NETWORK; + section = SECTION::DSTAR_NETWORK; #endif #if defined(USE_DMR) else if (::strncmp(buffer, "[DMR Network]", 13U) == 0) - section = SECTION_DMR_NETWORK; + section = SECTION::DMR_NETWORK; #endif #if defined(USE_YSF) else if (::strncmp(buffer, "[System Fusion Network]", 23U) == 0) - section = SECTION_FUSION_NETWORK; + section = SECTION::FUSION_NETWORK; #endif #if defined(USE_P25) else if (::strncmp(buffer, "[P25 Network]", 13U) == 0) - section = SECTION_P25_NETWORK; + section = SECTION::P25_NETWORK; #endif #if defined(USE_NXDN) else if (::strncmp(buffer, "[NXDN Network]", 14U) == 0) - section = SECTION_NXDN_NETWORK; + section = SECTION::NXDN_NETWORK; #endif #if defined(USE_M17) else if (::strncmp(buffer, "[M17 Network]", 13U) == 0) - section = SECTION_M17_NETWORK; + section = SECTION::M17_NETWORK; #endif #if defined(USE_POCSAG) else if (::strncmp(buffer, "[POCSAG Network]", 16U) == 0) - section = SECTION_POCSAG_NETWORK; + section = SECTION::POCSAG_NETWORK; #endif #if defined(USE_FM) else if (::strncmp(buffer, "[FM Network]", 12U) == 0) - section = SECTION_FM_NETWORK; + section = SECTION::FM_NETWORK; #endif #if defined(USE_AX25) else if (::strncmp(buffer, "[AX.25 Network]", 15U) == 0) - section = SECTION_AX25_NETWORK; + section = SECTION::AX25_NETWORK; #endif else if (::strncmp(buffer, "[Lock File]", 11U) == 0) section = SECTION::LOCK_FILE; @@ -598,12 +599,12 @@ bool CConf::read() m_description = value; else if (::strcmp(key, "URL") == 0) m_url = value; - } else if (section == SECTION_LOG) { + } else if (section == SECTION::LOG) { if (::strcmp(key, "MQTTLevel") == 0) m_logMQTTLevel = (unsigned int)::atoi(value); else if (::strcmp(key, "DisplayLevel") == 0) m_logDisplayLevel = (unsigned int)::atoi(value); - } else if (section == SECTION_MQTT) { + } else if (section == SECTION::MQTT) { if (::strcmp(key, "Host") == 0) m_mqttHost = value; else if (::strcmp(key, "Port") == 0) @@ -618,7 +619,7 @@ bool CConf::read() m_mqttUsername = value; else if (::strcmp(key, "Password") == 0) m_mqttPassword = value; - } else if (section == SECTION_CWID) { + } else if (section == SECTION::CWID) { if (::strcmp(key, "Enable") == 0) m_cwIdEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Time") == 0) @@ -630,20 +631,20 @@ bool CConf::read() m_cwIdCallsign = value; } #if defined(USE_DMR) || defined(USE_P25) - } else if (section == SECTION_DMRID_LOOKUP) { + } else if (section == SECTION::DMRID_LOOKUP) { if (::strcmp(key, "File") == 0) m_dmrIdLookupFile = value; else if (::strcmp(key, "Time") == 0) m_dmrIdLookupTime = (unsigned int)::atoi(value); #endif #if defined(USE_NXDN) - } else if (section == SECTION_NXDNID_LOOKUP) { + } else if (section == SECTION::NXDNID_LOOKUP) { if (::strcmp(key, "File") == 0) m_nxdnIdLookupFile = value; else if (::strcmp(key, "Time") == 0) m_nxdnIdLookupTime = (unsigned int)::atoi(value); #endif - } else if (section == SECTION_MODEM) { + } else if (section == SECTION::MODEM) { if (::strcmp(key, "Protocol") == 0) m_modemProtocol = value; else if (::strcmp(key, "UARTPort") == 0) @@ -746,7 +747,7 @@ bool CConf::read() else if (::strcmp(key, "SendFrameType") == 0) m_transparentSendFrameType = (unsigned int)::atoi(value); #if defined(USE_DSTAR) - } else if (section == SECTION_DSTAR) { + } else if (section == SECTION::DSTAR) { if (::strcmp(key, "Enable") == 0) m_dstarEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Module") == 0) { @@ -797,7 +798,7 @@ bool CConf::read() } else if (section == SECTION::DMR) { #endif #if defined(USE_DMR) - } else if (section == SECTION_DMR) { + } else if (section == SECTION::DMR) { if (::strcmp(key, "Enable") == 0) m_dmrEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Beacons") == 0) @@ -881,10 +882,11 @@ bool CConf::read() m_dmrOVCM = DMR_OVCM::OFF; break; } - } + } else if (::strcmp(key, "Protect") == 0) + m_dmrProtect = ::atoi(value) == 1; #endif #if defined(USE_YSF) - } else if (section == SECTION_FUSION) { + } else if (section == SECTION::FUSION) { if (::strcmp(key, "Enable") == 0) m_fusionEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LowDeviation") == 0) @@ -899,7 +901,7 @@ bool CConf::read() m_fusionModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_P25) - } else if (section == SECTION_P25) { + } else if (section == SECTION::P25) { if (::strcmp(key, "Enable") == 0) m_p25Enabled = ::atoi(value) == 1; else if (::strcmp(key, "Id") == 0) @@ -918,7 +920,7 @@ bool CConf::read() m_p25ModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_NXDN) - } else if (section == SECTION_NXDN) { + } else if (section == SECTION::NXDN) { if (::strcmp(key, "Enable") == 0) m_nxdnEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Id") == 0) @@ -935,7 +937,7 @@ bool CConf::read() m_nxdnModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_M17) - } else if (section == SECTION_M17) { + } else if (section == SECTION::M17) { if (::strcmp(key, "Enable") == 0) m_m17Enabled = ::atoi(value) == 1; else if (::strcmp(key, "CAN") == 0) @@ -950,14 +952,14 @@ bool CConf::read() m_m17ModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_POCSAG) - } else if (section == SECTION_POCSAG) { + } else if (section == SECTION::POCSAG) { if (::strcmp(key, "Enable") == 0) m_pocsagEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Frequency") == 0) m_pocsagFrequency = (unsigned int)::atoi(value); #endif #if defined(USE_FM) - } else if (section == SECTION_FM) { + } else if (section == SECTION::FM) { if (::strcmp(key, "Enable") == 0) m_fmEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Callsign") == 0) { @@ -1045,7 +1047,7 @@ bool CConf::read() m_fmModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_AX25) - } else if (section == SECTION_AX25) { + } else if (section == SECTION::AX25) { if (::strcmp(key, "Enable") == 0) m_ax25Enabled = ::atoi(value) == 1; else if (::strcmp(key, "TXDelay") == 0) @@ -1060,7 +1062,7 @@ bool CConf::read() m_ax25Trace = ::atoi(value) == 1; #endif #if defined(USE_DSTAR) - } else if (section == SECTION_DSTAR_NETWORK) { + } else if (section == SECTION::DSTAR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dstarNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "GatewayAddress") == 0) @@ -1077,7 +1079,7 @@ bool CConf::read() m_dstarNetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_DMR) - } else if (section == SECTION_DMR_NETWORK) { + } else if (section == SECTION::DMR_NETWORK) { if (::strcmp(key, "Enable") == 0) m_dmrNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "GatewayAddress") == 0) @@ -1100,7 +1102,7 @@ bool CConf::read() m_dmrNetworkModeHang = (unsigned int)::atoi(value); #endif #if defined(USE_YSF) - } else if (section == SECTION_FUSION_NETWORK) { + } else if (section == SECTION::FUSION_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fusionNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) @@ -1117,7 +1119,7 @@ bool CConf::read() m_fusionNetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_P25) - } else if (section == SECTION_P25_NETWORK) { + } else if (section == SECTION::P25_NETWORK) { if (::strcmp(key, "Enable") == 0) m_p25NetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "GatewayAddress") == 0) @@ -1134,7 +1136,7 @@ bool CConf::read() m_p25NetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_NXDN) - } else if (section == SECTION_NXDN_NETWORK) { + } else if (section == SECTION::NXDN_NETWORK) { if (::strcmp(key, "Enable") == 0) m_nxdnNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) @@ -1151,7 +1153,7 @@ bool CConf::read() m_nxdnNetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_M17) - } else if (section == SECTION_M17_NETWORK) { + } else if (section == SECTION::M17_NETWORK) { if (::strcmp(key, "Enable") == 0) m_m17NetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) @@ -1168,7 +1170,7 @@ bool CConf::read() m_m17NetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_POCSAG) - } else if (section == SECTION_POCSAG_NETWORK) { + } else if (section == SECTION::POCSAG_NETWORK) { if (::strcmp(key, "Enable") == 0) m_pocsagNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) @@ -1185,7 +1187,7 @@ bool CConf::read() m_pocsagNetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_FM) - } else if (section == SECTION_FM_NETWORK) { + } else if (section == SECTION::FM_NETWORK) { if (::strcmp(key, "Enable") == 0) m_fmNetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "LocalAddress") == 0) @@ -1210,13 +1212,13 @@ bool CConf::read() m_fmNetworkDebug = ::atoi(value) == 1; #endif #if defined(USE_AX25) - } else if (section == SECTION_AX25_NETWORK) { + } else if (section == SECTION::AX25_NETWORK) { if (::strcmp(key, "Enable") == 0) m_ax25NetworkEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Debug") == 0) m_ax25NetworkDebug = ::atoi(value) == 1; #endif - } else if (section == SECTION_LOCK_FILE) { + } else if (section == SECTION::LOCK_FILE) { if (::strcmp(key, "Enable") == 0) m_lockFileEnabled = ::atoi(value) == 1; else if (::strcmp(key, "File") == 0) @@ -1748,6 +1750,11 @@ DMR_OVCM CConf::getDMROVCM() const { return m_dmrOVCM; } + +bool CConf::getDMRProtect() const +{ + return m_dmrProtect; +} #endif #if defined(USE_YSF) diff --git a/Conf.h b/Conf.h index 6574599..c6230ff 100644 --- a/Conf.h +++ b/Conf.h @@ -150,7 +150,7 @@ public: std::vector getDStarWhiteList() const; bool getDStarAckReply() const; unsigned int getDStarAckTime() const; - DSTAR_ACK_MESSAGE getDStarAckMessage() const; + DSTAR_ACK getDStarAckMessage() const; bool getDStarErrorReply() const; bool getDStarRemoteGateway() const; unsigned int getDStarModeHang() const; @@ -175,7 +175,8 @@ public: unsigned int getDMRCallHang() const; unsigned int getDMRTXHang() const; unsigned int getDMRModeHang() const; - DMR_OVCM_TYPES getDMROVCM() const; + DMR_OVCM getDMROVCM() const; + bool getDMRProtect() const; #endif #if defined(USE_YSF) @@ -480,7 +481,7 @@ private: std::vector m_dstarWhiteList; bool m_dstarAckReply; unsigned int m_dstarAckTime; - DSTAR_ACK_MESSAGE m_dstarAckMessage; + DSTAR_ACK m_dstarAckMessage; bool m_dstarErrorReply; bool m_dstarRemoteGateway; #endif @@ -508,7 +509,8 @@ private: #endif unsigned int m_dmrModeHang; #if defined(USE_DMR) - DMR_OVCM_TYPES m_dmrOVCM; + DMR_OVCM m_dmrOVCM; + bool m_dmrProtect; #endif #if defined(USE_YSF) diff --git a/DMRControl.cpp b/DMRControl.cpp index 1c166ba..88bab80 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -22,7 +22,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, 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& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM ovcm, bool protect) : m_colorCode(colorCode), m_modem(modem), m_network(network), @@ -31,14 +31,14 @@ m_slot2(2U, timeout), m_lookup(lookup) { assert(id != 0U); - assert(modem != NULL); - assert(lookup != NULL); - assert(rssi != NULL); + assert(modem != nullptr); + assert(lookup != nullptr); + assert(rssi != nullptr); // Load black and white lists to DMRAccessControl CDMRAccessControl::init(blacklist, whitelist, slot1TGWhitelist, slot2TGWhitelist, selfOnly, prefixes, id); - CDMRSlot::init(colorCode, embeddedLCOnly, dumpTAData, callHang, modem, network, duplex, m_lookup, rssi, jitter, ovcm); + CDMRSlot::init(colorCode, embeddedLCOnly, dumpTAData, callHang, modem, network, duplex, m_lookup, rssi, jitter, ovcm, protect); } CDMRControl::~CDMRControl() diff --git a/DMRControl.h b/DMRControl.h index 62dbaca..fa63039 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -34,7 +34,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, 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& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM ovcm, bool protect); ~CDMRControl(); bool processWakeup(const unsigned char* data); diff --git a/DMRDefines.h b/DMRDefines.h index 2f38874..639b737 100644 --- a/DMRDefines.h +++ b/DMRDefines.h @@ -117,7 +117,7 @@ enum class FLCO { TALKER_ALIAS_BLOCK1 = 5, TALKER_ALIAS_BLOCK2 = 6, TALKER_ALIAS_BLOCK3 = 7, - GINFO = 8 + GPS_INFO = 8 }; #endif diff --git a/DMREmbeddedData.h b/DMREmbeddedData.h index f761a40..8ce65d8 100644 --- a/DMREmbeddedData.h +++ b/DMREmbeddedData.h @@ -23,6 +23,8 @@ #include "Defines.h" #include "DMRLC.h" +#if defined(USE_DMR) + enum class LC_STATE { NONE, FIRST, @@ -64,4 +66,3 @@ private: #endif #endif - diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 80b814a..19808fd 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -37,7 +37,7 @@ m_addressStr(address), m_addr(), m_addrLen(0U), m_port(port), -m_id(NULL), +m_id(nullptr), m_duplex(duplex), m_version(version), m_debug(debug), @@ -46,8 +46,8 @@ m_enabled(false), m_slot1(slot1), m_slot2(slot2), m_hwType(hwType), -m_buffer(NULL), -m_streamId(NULL), +m_buffer(nullptr), +m_streamId(nullptr), m_rxData(1000U, "DMR Network"), m_beacon(false), m_random(), @@ -154,7 +154,7 @@ bool CDMRNetwork::read(CDMRData& data) if (slotNo == 2U && !m_slot2) return false; - FLCO flco = (m_buffer[15U] & 0x40U) == 0x40U ? FLCO_USER_USER : FLCO_GROUP; + FLCO flco = (m_buffer[15U] & 0x40U) == 0x40U ? FLCO::USER_USER : FLCO::GROUP; data.setSeqNo(seqNo); data.setSlotNo(slotNo); @@ -217,7 +217,7 @@ bool CDMRNetwork::write(const CDMRData& data) buffer[15U] = slotNo == 1U ? 0x00U : 0x80U; FLCO flco = data.getFLCO(); - buffer[15U] |= flco == FLCO_GROUP ? 0x00U : 0x40U; + buffer[15U] |= flco == FLCO::GROUP ? 0x00U : 0x40U; unsigned int slotIndex = slotNo - 1U; @@ -346,16 +346,16 @@ bool CDMRNetwork::writeConfig() slots = '2'; switch (m_hwType) { - case HWT_MMDVM: + case HW_TYPE::MMDVM: software = "MMDVM"; break; - case HWT_MMDVM_HS: + case HW_TYPE::MMDVM_HS: software = "MMDVM_MMDVM_HS"; break; - case HWT_MMDVM_HS_DUAL_HAT: + case HW_TYPE::MMDVM_HS_DUAL_HAT: software = "MMDVM_MMDVM_HS_Dual_Hat"; break; - case HWT_NANO_HOTSPOT: + case HW_TYPE::NANO_HOTSPOT: software = "MMDVM_Nano_hotSPOT"; break; default: @@ -366,37 +366,37 @@ bool CDMRNetwork::writeConfig() slots = '4'; switch (m_hwType) { - case HWT_MMDVM: + case HW_TYPE::MMDVM: software = "MMDVM_DMO"; break; - case HWT_DVMEGA: + case HW_TYPE::DVMEGA: software = "MMDVM_DVMega"; break; - case HWT_MMDVM_ZUMSPOT: + case HW_TYPE::MMDVM_ZUMSPOT: software = "MMDVM_ZUMspot"; break; - case HWT_MMDVM_HS_HAT: + case HW_TYPE::MMDVM_HS_HAT: software = "MMDVM_MMDVM_HS_Hat"; break; - case HWT_MMDVM_HS_DUAL_HAT: + case HW_TYPE::MMDVM_HS_DUAL_HAT: software = "MMDVM_MMDVM_HS_Dual_Hat"; break; - case HWT_NANO_HOTSPOT: + case HW_TYPE::NANO_HOTSPOT: software = "MMDVM_Nano_hotSPOT"; break; - case HWT_NANO_DV: + case HW_TYPE::NANO_DV: software = "MMDVM_Nano_DV"; break; - case HWT_D2RG_MMDVM_HS: + case HW_TYPE::D2RG_MMDVM_HS: software = "MMDVM_D2RG_MMDVM_HS"; break; - case HWT_MMDVM_HS: + case HW_TYPE::MMDVM_HS: software = "MMDVM_MMDVM_HS"; break; - case HWT_OPENGD77_HS: + case HW_TYPE::OPENGD77_HS: software = "MMDVM_OpenGD77_HS"; break; - case HWT_SKYBRIDGE: + case HW_TYPE::SKYBRIDGE: software = "MMDVM_SkyBridge"; break; default: @@ -431,7 +431,7 @@ bool CDMRNetwork::wantsBeacon() bool CDMRNetwork::write(const unsigned char* data, unsigned int length) { - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_debug) diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 3072462..f661283 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -39,8 +39,8 @@ unsigned int CDMRSlot::m_colorCode = 0U; bool CDMRSlot::m_embeddedLCOnly = false; bool CDMRSlot::m_dumpTAData = true; -CModem* CDMRSlot::m_modem = NULL; -CDMRNetwork* CDMRSlot::m_network = NULL; +CModem* CDMRSlot::m_modem = nullptr; +CDMRNetwork* CDMRSlot::m_network = nullptr; bool CDMRSlot::m_duplex = true; CDMRLookup* CDMRSlot::m_lookup = nullptr; unsigned int CDMRSlot::m_hangCount = 3U * 17U; @@ -148,7 +148,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!m_enabled) return false; - if (data[0U] == TAG_LOST && m_rfState == RS_RF_AUDIO) { + if ((data[0U] == TAG_LOST) && (m_rfState == RPT_RF_STATE::AUDIO)) { unsigned int srcId = m_rfLC->getSrcId(); unsigned int dstId = m_rfLC->getDstId(); std::string src = m_lookup->find(srcId); @@ -156,10 +156,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) FLCO flco = m_rfLC->getFLCO(); if (m_rssi != 0) { - LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCountTotal); + LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCountTotal); writeJSONRF("lost", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); } else { - LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); + LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); } @@ -172,14 +172,14 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) } } - if (data[0U] == TAG_LOST && m_rfState == RS_RF_DATA) { + if ((data[0U] == TAG_LOST) && (m_rfState == RPT_RF_STATE::DATA)) { unsigned int srcId = m_rfLC->getSrcId(); unsigned int dstId = m_rfLC->getDstId(); std::string src = m_lookup->find(srcId); std::string dst = m_lookup->find(dstId); FLCO flco = m_rfLC->getFLCO(); - LogMessage("DMR Slot %u, RF data transmission lost from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); + LogMessage("DMR Slot %u, RF data transmission lost from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str()); writeJSONRF("lost"); writeEndRF(); return false; @@ -250,7 +250,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateSrcId(srcId)) { LogMessage("DMR Slot %u, RF user %u rejected", m_slotNo, srcId); - writeJSONRF("rejected", srcId, src, flco == FLCO_GROUP, dstId); + writeJSONRF("rejected", srcId, src, flco == FLCO::GROUP, dstId); delete lc; m_rfState = RPT_RF_STATE::LISTENING; return false; @@ -258,7 +258,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateTGId(m_slotNo, flco == FLCO::GROUP, dstId)) { LogMessage("DMR Slot %u, RF user %u rejected for using TG %u", m_slotNo, srcId, dstId); - writeJSONRF("rejected", srcId, src, flco == FLCO_GROUP, dstId); + writeJSONRF("rejected", srcId, src, flco == FLCO::GROUP, dstId); delete lc; m_rfState = RPT_RF_STATE::LISTENING; return false; @@ -323,14 +323,14 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfState = RPT_RF_STATE::AUDIO; - if (m_netState == RS_NET_IDLE) { - setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE); + if (m_netState == RPT_NET_STATE::IDLE) { + setShortLC(m_slotNo, dstId, flco, ACTIVITY_TYPE::VOICE); writeJSONRSSI(); writeJSONBER(); } - LogMessage("DMR Slot %u, received RF voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); - writeJSONRF("start", srcId, src, flco == FLCO_GROUP, dstId); + LogMessage("DMR Slot %u, received RF voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str()); + writeJSONRF("start", srcId, src, flco == FLCO::GROUP, dstId); return true; } else if (dataType == DT_VOICE_PI_HEADER) { @@ -393,10 +393,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) FLCO flco = m_rfLC->getFLCO(); if (m_rssi != 0) { - LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); + LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); writeJSONRF("end", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); } else { - LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); + LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); } @@ -425,14 +425,14 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateSrcId(srcId)) { LogMessage("DMR Slot %u, RF user %u rejected", m_slotNo, srcId); writeJSONRF("rejected", srcId, src, gi, dstId); - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; return false; } if (!CDMRAccessControl::validateTGId(m_slotNo, gi, dstId)) { LogMessage("DMR Slot %u, RF user %u rejected for using TG %u", m_slotNo, srcId, dstId); writeJSONRF("rejected", srcId, src, gi, dstId); - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; return false; } @@ -459,8 +459,8 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfState = RPT_RF_STATE::DATA; - if (m_netState == RS_NET_IDLE) { - setShortLC(m_slotNo, dstId, gi ? FLCO_GROUP : FLCO_USER_USER, ACTIVITY_DATA); + if (m_netState == RPT_NET_STATE::IDLE) { + setShortLC(m_slotNo, dstId, gi ? FLCO::GROUP : FLCO::USER_USER, ACTIVITY_TYPE::DATA); writeJSONRSSI(); } @@ -500,14 +500,14 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateSrcId(srcId)) { LogMessage("DMR Slot %u, RF user %u rejected", m_slotNo, srcId); writeJSONRF("rejected", srcId, src, gi, dstId); - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; return false; } if (!CDMRAccessControl::validateTGId(m_slotNo, gi, dstId)) { LogMessage("DMR Slot %u, RF user %u rejected for using TG %u", m_slotNo, srcId, dstId); writeJSONRF("rejected", srcId, src, gi, dstId); - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; return false; } } @@ -568,8 +568,8 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) } // If data preamble, signal its existence - if (m_netState == RS_NET_IDLE && csbko == CSBKO_PRECCSBK && csbk.getDataContent()) { - setShortLC(m_slotNo, dstId, gi ? FLCO_GROUP : FLCO_USER_USER, ACTIVITY_DATA); + if ((m_netState == RPT_NET_STATE::IDLE) && (csbko == CSBKO::PRECCSBK) && csbk.getDataContent()) { + setShortLC(m_slotNo, dstId, gi ? FLCO::GROUP : FLCO::USER_USER, ACTIVITY_TYPE::DATA); writeJSONRSSI(); } @@ -721,7 +721,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) // CUtils::dump(1U, text, data, 9U); break; - case FLCO::GINFO: + case FLCO::GPS_INFO: if (m_dumpTAData) { ::sprintf(text, "DMR Slot %u, Embedded GPS Info", m_slotNo); CUtils::dump(1U, text, data, 9U); @@ -885,7 +885,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateSrcId(srcId)) { LogMessage("DMR Slot %u, RF user %u rejected", m_slotNo, srcId); - writeJSONRF("rejected", srcId, src, flco == FLCO_GROUP, dstId); + writeJSONRF("rejected", srcId, src, flco == FLCO::GROUP, dstId); delete lc; m_rfState = RPT_RF_STATE::LISTENING; return false; @@ -893,7 +893,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) if (!CDMRAccessControl::validateTGId(m_slotNo, flco == FLCO::GROUP, dstId)) { LogMessage("DMR Slot %u, RF user %u rejected for using TG %u", m_slotNo, srcId, dstId); - writeJSONRF("rejected", srcId, src, flco == FLCO_GROUP, dstId); + writeJSONRF("rejected", srcId, src, flco == FLCO::GROUP, dstId); delete lc; m_rfState = RPT_RF_STATE::LISTENING; return false; @@ -994,14 +994,14 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) m_rfState = RPT_RF_STATE::AUDIO; - if (m_netState == RS_NET_IDLE) { - setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE); + if (m_netState == RPT_NET_STATE::IDLE) { + setShortLC(m_slotNo, dstId, flco, ACTIVITY_TYPE::VOICE); writeJSONRSSI(); writeJSONBER(); } - LogMessage("DMR Slot %u, received RF late entry from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); - writeJSONRF("late_entry", srcId, src, flco == FLCO_GROUP, dstId); + LogMessage("DMR Slot %u, received RF late entry from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str()); + writeJSONRF("late_entry", srcId, src, flco == FLCO::GROUP, dstId); return true; } @@ -1030,7 +1030,7 @@ void CDMRSlot::writeEndRF(bool writeEnd) { m_rfState = RPT_RF_STATE::LISTENING; - if (m_netState == RS_NET_IDLE) + if (m_netState == RPT_NET_STATE::IDLE) setShortLC(m_slotNo, 0U); if (writeEnd) { @@ -1121,7 +1121,7 @@ void CDMRSlot::writeEndNet(bool writeEnd) m_netN = 0U; delete m_netLC; - m_netLC = NULL; + m_netLC = nullptr; } void CDMRSlot::writeNetwork(const CDMRData& dmrData) @@ -1224,8 +1224,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) class CUserDBentry cn; m_lookup->findWithName(srcId, &cn); - LogMessage("DMR Slot %u, received network voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); - writeJSONNet("start", srcId, src, flco == FLCO_GROUP, dstId); + LogMessage("DMR Slot %u, received network voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str()); + writeJSONNet("start", srcId, src, flco == FLCO::GROUP, dstId); } else if (dataType == DT_VOICE_PI_HEADER) { if (m_netState != RPT_NET_STATE::AUDIO) { CDMRLC* lc = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); @@ -1290,8 +1290,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) class CUserDBentry cn; m_lookup->findWithName(srcId, &cn); - LogMessage("DMR Slot %u, received network late entry from %s to %s%s", m_slotNo, src.c_str(), m_netLC->getFLCO() == FLCO_GROUP ? "TG " : "", dst.c_str()); - writeJSONNet("late_entry", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId); + LogMessage("DMR Slot %u, received network late entry from %s to %s%s", m_slotNo, src.c_str(), m_netLC->getFLCO() == FLCO::GROUP ? "TG " : "", dst.c_str()); + writeJSONNet("late_entry", srcId, src, m_netLC->getFLCO() == FLCO::GROUP, dstId); } // Regenerate the Slot Type @@ -1351,7 +1351,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // We've received the voice header and terminator haven't we? m_netFrames += 2U; - LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); + LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeJSONNet("end", float(m_netFrames) / 16.667F, float(m_netLost * 100U) / float(m_netFrames), float(m_netErrs * 100U) / float(m_netBits)); writeEndNet(); } else if (dataType == DT_DATA_HEADER) { @@ -1481,8 +1481,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) class CUserDBentry cn; m_lookup->findWithName(srcId, &cn); - LogMessage("DMR Slot %u, received network late entry from %s to %s%s", m_slotNo, src.c_str(), m_netLC->getFLCO() == FLCO_GROUP ? "TG " : "", dst.c_str()); - writeJSONNet("late_entry", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId); + LogMessage("DMR Slot %u, received network late entry from %s to %s%s", m_slotNo, src.c_str(), m_netLC->getFLCO() == FLCO::GROUP ? "TG " : "", dst.c_str()); + writeJSONNet("late_entry", srcId, src, m_netLC->getFLCO() == FLCO::GROUP, dstId); } if (m_netState == RPT_NET_STATE::AUDIO) { @@ -1552,7 +1552,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) // ::sprintf(text, "DMR Slot %u, Embedded LC", m_slotNo); // CUtils::dump(1U, text, data, 9U); break; - case FLCO::GINFO: + case FLCO::GPS_INFO: if (m_dumpTAData) { ::sprintf(text, "DMR Slot %u, Embedded GPS Info", m_slotNo); CUtils::dump(1U, text, data, 9U); @@ -1771,10 +1771,10 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) } // If data preamble, signal its existence - if (csbko == CSBKO_PRECCSBK && csbk.getDataContent()) - setShortLC(m_slotNo, dstId, gi ? FLCO_GROUP : FLCO_USER_USER, ACTIVITY_DATA); + if ((csbko == CSBKO::PRECCSBK) && csbk.getDataContent()) + setShortLC(m_slotNo, dstId, gi ? FLCO::GROUP : FLCO::USER_USER, ACTIVITY_TYPE::DATA); } else if (dataType == DT_RATE_12_DATA || dataType == DT_RATE_34_DATA || dataType == DT_RATE_1_DATA) { - if (m_netState != RS_NET_DATA || m_netFrames == 0U) { + if ((m_netState != RPT_NET_STATE::DATA) || (m_netFrames == 0U)) { writeEndNet(); return; } @@ -2008,11 +2008,11 @@ 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, 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, CDMRNetwork* network, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM ovcm, bool protect) { - assert(modem != NULL); - assert(lookup != NULL); - assert(rssiMapper != NULL); + assert(modem != nullptr); + assert(lookup != nullptr); + assert(rssiMapper != nullptr); m_colorCode = colorCode; m_embeddedLCOnly = embeddedLCOnly; @@ -2309,7 +2309,7 @@ void CDMRSlot::writeJSONBER() void CDMRSlot::writeJSONText(const unsigned char* text) { - assert(text != NULL); + assert(text != nullptr); nlohmann::json json; @@ -2324,7 +2324,7 @@ void CDMRSlot::writeJSONText(const unsigned char* text) void CDMRSlot::writeJSONRF(const char* action) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2335,7 +2335,7 @@ void CDMRSlot::writeJSONRF(const char* action) void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2346,8 +2346,8 @@ void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::st void CDMRSlot::writeJSONRF(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); - assert(desc != NULL); + assert(action != nullptr); + assert(desc != nullptr); nlohmann::json json; @@ -2360,7 +2360,7 @@ void CDMRSlot::writeJSONRF(const char* action, const char* desc, unsigned int sr void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2373,7 +2373,7 @@ void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::st void CDMRSlot::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2387,7 +2387,7 @@ void CDMRSlot::writeJSONRF(const char* action, float duration, float ber) void CDMRSlot::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2408,7 +2408,7 @@ void CDMRSlot::writeJSONRF(const char* action, float duration, float ber, int mi void CDMRSlot::writeJSONNet(const char* action) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2419,7 +2419,7 @@ void CDMRSlot::writeJSONNet(const char* action) void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2430,8 +2430,8 @@ void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::s void CDMRSlot::writeJSONNet(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); - assert(desc != NULL); + assert(action != nullptr); + assert(desc != nullptr); nlohmann::json json; @@ -2444,7 +2444,7 @@ void CDMRSlot::writeJSONNet(const char* action, const char* desc, unsigned int s void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2457,7 +2457,7 @@ void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::s void CDMRSlot::writeJSONNet(const char* action, float duration, float loss, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -2472,7 +2472,7 @@ void CDMRSlot::writeJSONNet(const char* action, float duration, float loss, floa void CDMRSlot::writeJSON(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["action"] = action; @@ -2481,8 +2481,8 @@ void CDMRSlot::writeJSON(nlohmann::json& json, const char* action) void CDMRSlot::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(source != NULL); - assert(action != NULL); + assert(source != nullptr); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["source"] = source; diff --git a/DMRSlot.h b/DMRSlot.h index e48b2ae..efeafd7 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -65,7 +65,7 @@ public: void enable(bool enabled); - static void init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, CDMRNetwork* network, 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, CDMRNetwork* network, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM ovcm, bool protect); private: unsigned int m_slotNo; @@ -159,7 +159,7 @@ private: bool insertSilence(const unsigned char* data, unsigned char seqNo); void insertSilence(unsigned int count); - static void setShortLC(unsigned int slotNo, unsigned int id, FLCO flco = FLCO_GROUP, ACTIVITY_TYPE type = ACTIVITY_NONE); + static void setShortLC(unsigned int slotNo, unsigned int id, FLCO flco = FLCO::GROUP, ACTIVITY_TYPE type = ACTIVITY_TYPE::NONE); void writeJSONRSSI(); void writeJSONBER(); diff --git a/DStarControl.cpp b/DStarControl.cpp index 99e57ab..c17df2a 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -39,9 +39,9 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my) return true; } -CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK_MESSAGE ackMessage, bool errorReply, const std::vector& blackList, const std::vector& whiteList, CDStarNetwork* network, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : -m_callsign(NULL), -m_gateway(NULL), +CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK ackMessage, bool errorReply, const std::vector& blackList, const std::vector& whiteList, CDStarNetwork* network, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : +m_callsign(nullptr), +m_gateway(nullptr), m_selfOnly(selfOnly), m_ackReply(ackReply), m_ackMessage(ackMessage), @@ -76,7 +76,6 @@ m_fec(), m_rfBits(1U), m_netBits(1U), m_rfErrs(0U), -m_netErrs(0U), m_lastFrame(nullptr), m_lastFrameValid(false), m_rssiMapper(rssiMapper), @@ -91,7 +90,7 @@ m_bitErrsAccum(0U), m_bitsCount(0U), m_enabled(true) { - assert(rssiMapper != NULL); + assert(rssiMapper != nullptr); m_callsign = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; m_gateway = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; @@ -238,7 +237,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) // Is this a transmission destined for a repeater? if (!header.isRepeater()) { LogMessage("D-Star, non repeater RF header received from %8.8s", my1); - m_rfState = RS_RF_INVALID; + m_rfState = RPT_RF_STATE::INVALID; writeJSONRF("invalid", my1, my2, your); return true; } @@ -246,21 +245,21 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) // Is it for us? if (::memcmp(rpt1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) { LogMessage("D-Star, received RF header for wrong repeater (%8.8s) from %8.8s", rpt1, my1); - m_rfState = RS_RF_INVALID; + m_rfState = RPT_RF_STATE::INVALID; writeJSONRF("invalid", my1, my2, your); return true; } if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) { LogMessage("D-Star, invalid access attempt from %8.8s", my1); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", my1, my2, your); return true; } if (!m_selfOnly && std::find_if(m_blackList.begin(), m_blackList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_blackList.end()) { LogMessage("D-Star, invalid access attempt from %8.8s", my1); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", my1, my2, your); return true; } @@ -312,7 +311,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) m_rfState = RPT_RF_STATE::AUDIO; - if (m_netState == RS_NET_IDLE) + if (m_netState == RPT_NET_STATE::IDLE) writeJSONRSSI(); LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your); @@ -395,9 +394,13 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) } if (m_rfState == RPT_RF_STATE::DATA) { + if (m_rfN == 0U) + writeJSONRSSI(); + LogDebug("D-Star, fast data sequence no. %u", m_rfN); - m_rfBits += 48U; + m_bitsCount += 48U; + m_rfBits += 48U; m_rfFrames++; if (m_net) @@ -419,9 +422,8 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) m_rfN = (m_rfN + 1U) % 21U; } else if (m_rfState == RPT_RF_STATE::AUDIO) { - // Send the RSSI data to the display if (m_rfN == 0U) - m_display->writeDStarRSSI(m_rssi); + writeJSONRSSI(); unsigned int errors = 0U; if (::memcmp(data + 1U, DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) == 0) { @@ -486,7 +488,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) // Is this a transmission destined for a repeater? if (!m_rfHeader.isRepeater()) { LogMessage("D-Star, non repeater RF header received from %8.8s", my1); - m_rfState = RS_RF_INVALID; + m_rfState = RPT_RF_STATE::INVALID; writeJSONRF("invalid", my1, my2, your); return true; } @@ -494,21 +496,21 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) // Is it for us? if (::memcmp(rpt1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) { LogMessage("D-Star, received RF header for wrong repeater (%8.8s) from %8.8s", rpt1, my1); - m_rfState = RS_RF_INVALID; + m_rfState = RPT_RF_STATE::INVALID; writeJSONRF("invalid", my1, my2, your); return true; } if (m_selfOnly && ::memcmp(my1, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH - 1U) != 0 && !(std::find_if(m_whiteList.begin(), m_whiteList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_whiteList.end())) { LogMessage("D-Star, invalid access attempt from %8.8s", my1); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", my1, my2, your); return true; } if (!m_selfOnly && std::find_if(m_blackList.begin(), m_blackList.end(), std::bind(CallsignCompare, std::placeholders::_1, my1)) != m_blackList.end()) { LogMessage("D-Star, invalid access attempt from %8.8s", my1); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", my1, my2, your); return true; } @@ -590,7 +592,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len) m_rfN = (m_rfN + 1U) % 21U; - if (m_netState == RS_NET_IDLE) { + if (m_netState == RPT_NET_STATE::IDLE) { writeJSONRSSI(); writeJSONBER(); } @@ -626,7 +628,7 @@ void CDStarControl::writeEndRF() m_rfTimeoutTimer.stop(); - if (m_netState == RS_NET_IDLE) { + if (m_netState == RPT_NET_STATE::IDLE) { m_ackTimer.start(); if (m_network != nullptr) @@ -707,12 +709,12 @@ void CDStarControl::writeNetwork() writeQueueHeaderNet(data); - m_netState = RS_NET_AUDIO; + m_netState = RPT_NET_STATE::AUDIO; LINK_STATUS status = LINK_STATUS::NONE; unsigned char reflector[DSTAR_LONG_CALLSIGN_LENGTH]; m_network->getStatus(status, reflector); - if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) { + if ((status == LINK_STATUS::LINKED_DEXTRA) || (status == LINK_STATUS::LINKED_DPLUS) || (status == LINK_STATUS::LINKED_DCS) || (status == LINK_STATUS::LINKED_CCS) || (status == LINK_STATUS::LINKED_LOOPBACK)) { LogMessage("D-Star, received network header from %8.8s/%4.4s to %8.8s via %8.8s", my1, my2, your, reflector); writeJSONNet("start", my1, my2, your, reflector); } else { @@ -763,7 +765,7 @@ void CDStarControl::writeNetwork() } if (m_netState == RPT_NET_STATE::AUDIO) { - unsigned char n = data[1U]; + m_netN = data[1U]; unsigned int errors = 0U; if (::memcmp(data + 2U, DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) != 0) { @@ -774,13 +776,11 @@ void CDStarControl::writeNetwork() data[1U] = TAG_DATA; // Insert silence and reject if in the past - bool ret = insertSilence(data + 1U, n); + bool ret = insertSilence(data + 1U, m_netN); if (!ret) return; - m_netBits += 48U; - - m_netN = n; + m_netBits += 48U; // Regenerate the sync if (m_netN == 0U) { @@ -795,9 +795,6 @@ void CDStarControl::writeNetwork() m_packetTimer.start(); m_netFrames++; -#if defined(DUMP_DSTAR) - writeFile(data + 1U, length - 1U); -#endif writeQueueDataNet(data + 1U); } @@ -827,7 +824,8 @@ void CDStarControl::writeNetwork() m_packetTimer.start(); m_netFrames++; - writeQueueDataNet(data + 1U); + writeQueueDataNet(data + 1U); + } } else { CUtils::dump("D-Star, unknown data from network", data, DSTAR_FRAME_LENGTH_BYTES + 1U); } @@ -1163,7 +1161,7 @@ void CDStarControl::sendAck() } else { ::sprintf(text, "BER:%.1f%% %ddBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / int(m_rssiCountTotal)); } - } else if (m_ackMessage == DSTAR_ACK_SMETER && m_rssi != 0) { + } else if ((m_ackMessage == DSTAR_ACK::SMETER) && (m_rssi != 0U)) { const int RSSI_S1 = -141; const int RSSI_S9 = -93; @@ -1242,7 +1240,7 @@ void CDStarControl::sendError() } else { ::sprintf(text, "BER:%.1f%% %ddBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / int(m_rssiCountTotal)); } - } else if (m_ackMessage == DSTAR_ACK_SMETER && m_rssi != 0) { + } else if ((m_ackMessage == DSTAR_ACK::SMETER) && (m_rssi != 0U)) { const int RSSI_S1 = -141; const int RSSI_S9 = -93; @@ -1355,7 +1353,7 @@ void CDStarControl::writeJSONBER() void CDStarControl::writeJSONText(const unsigned char* text) { - assert(text != NULL); + assert(text != nullptr); nlohmann::json json; @@ -1369,10 +1367,10 @@ void CDStarControl::writeJSONText(const unsigned char* text) void CDStarControl::writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your) { - assert(action != NULL); - assert(my1 != NULL); - assert(my2 != NULL); - assert(your != NULL); + assert(action != nullptr); + assert(my1 != nullptr); + assert(my2 != nullptr); + assert(your != nullptr); nlohmann::json json; @@ -1390,7 +1388,7 @@ void CDStarControl::writeJSONRF(const char* action, const unsigned char* my1, co void CDStarControl::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1401,7 +1399,7 @@ void CDStarControl::writeJSONRF(const char* action, float duration, float ber) void CDStarControl::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1419,10 +1417,10 @@ void CDStarControl::writeJSONRF(const char* action, float duration, float ber, i void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* reflector) { - assert(action != NULL); - assert(my1 != NULL); - assert(my2 != NULL); - assert(your != NULL); + assert(action != nullptr); + assert(my1 != nullptr); + assert(my2 != nullptr); + assert(your != nullptr); nlohmann::json json; @@ -1435,7 +1433,7 @@ void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, c json["source"] = "network"; json["action"] = action; - if (reflector != NULL) + if (reflector != nullptr) json["reflector"] = convertBuffer(reflector, DSTAR_LONG_CALLSIGN_LENGTH); WriteJSON("D-Star", json); @@ -1443,7 +1441,7 @@ void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, c void CDStarControl::writeJSONNet(const char* action, float duration, float loss) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1459,7 +1457,7 @@ void CDStarControl::writeJSONNet(const char* action, float duration, float loss) void CDStarControl::writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1471,7 +1469,7 @@ void CDStarControl::writeJSONRF(nlohmann::json& json, const char* action, float std::string CDStarControl::convertBuffer(const unsigned char* buffer, unsigned int length) const { - assert(buffer != NULL); + assert(buffer != nullptr); std::string callsign((char*)buffer, length); diff --git a/DStarControl.h b/DStarControl.h index 35f99a8..ae82dad 100644 --- a/DStarControl.h +++ b/DStarControl.h @@ -40,7 +40,7 @@ class CDStarControl { public: - CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK_MESSAGE ackMessage, bool errorReply, const std::vector& blackList, const std::vector& whiteList, CDStarNetwork* network, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper); + CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK ackMessage, bool errorReply, const std::vector& blackList, const std::vector& whiteList, CDStarNetwork* network, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper); ~CDStarControl(); bool writeModem(unsigned char* data, unsigned int len); @@ -125,7 +125,7 @@ private: void writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your); void writeJSONRF(const char* action, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI); - void writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* reflector = NULL); + void writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* reflector = nullptr); void writeJSONNet(const char* action, float duration, float loss); void writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber); diff --git a/FMControl.cpp b/FMControl.cpp index 7848bb0..0401693 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -60,7 +60,7 @@ m_filterStage3(nullptr) { assert(txAudioGain > 0.0F); assert(rxAudioGain > 0.0F); - assert(rssiMapper != NULL); + assert(rssiMapper != nullptr); m_preEmphasis = new CIIRDirectForm1Filter(8.315375384336983F, -7.03334621603483F,0.0F,1.0F, 0.282029168302153F,0.0F, PREEMPHASIS_GAIN_DB); m_deEmphasis = new CIIRDirectForm1Filter(0.07708787090460224F, 0.07708787090460224F,0.0F, 1.0F, -0.8458242581907955F,0.0F, DEEMPHASIS_GAIN_DB); @@ -121,7 +121,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) return true; } - if (m_network == NULL) + if (m_network == nullptr) return true; if (data[0U] == TAG_EOT) @@ -235,7 +235,7 @@ void CFMControl::enable(bool enabled) void CFMControl::writeJSON(const char* state) { - assert(state != NULL); + assert(state != nullptr); nlohmann::json json; diff --git a/FMNetwork.cpp b/FMNetwork.cpp index 523f3e7..45d5563 100644 --- a/FMNetwork.cpp +++ b/FMNetwork.cpp @@ -184,7 +184,7 @@ void CFMNetwork::clock(unsigned int ms) return; // Check if the data is for us - if (!CUDPSocket::match(addr, m_addr, IMT_ADDRESS_AND_PORT)) { + if (!CUDPSocket::match(addr, m_addr, IPMATCHTYPE::ADDRESS_AND_PORT)) { LogMessage("FM packet received from an invalid source"); return; } diff --git a/Log.cpp b/Log.cpp index d824af6..222d18e 100644 --- a/Log.cpp +++ b/Log.cpp @@ -33,7 +33,7 @@ #include #include -CMQTTConnection* m_mqtt = NULL; +CMQTTConnection* m_mqtt = nullptr; static unsigned int m_mqttLevel = 2U; @@ -49,10 +49,10 @@ void LogInitialise(unsigned int displayLevel, unsigned int mqttLevel) void LogFinalise() { - if (m_mqtt != NULL) { + if (m_mqtt != nullptr) { m_mqtt->close(); delete m_mqtt; - m_mqtt = NULL; + m_mqtt = nullptr; } } @@ -82,7 +82,7 @@ void Log(unsigned int level, const char* fmt, ...) va_end(vl); - if (m_mqtt != NULL && level >= m_mqttLevel && m_mqttLevel != 0U) + if (m_mqtt != nullptr && level >= m_mqttLevel && m_mqttLevel != 0U) m_mqtt->publish("log", buffer); if (level >= m_displayLevel && m_displayLevel != 0U) { @@ -96,7 +96,7 @@ void Log(unsigned int level, const char* fmt, ...) void WriteJSON(const std::string& topLevel, nlohmann::json& json) { - if (m_mqtt != NULL) { + if (m_mqtt != nullptr) { nlohmann::json top; top[topLevel] = json; diff --git a/M17Control.cpp b/M17Control.cpp index c9e0364..ea8f9f0 100644 --- a/M17Control.cpp +++ b/M17Control.cpp @@ -104,7 +104,7 @@ m_bitsCount(0U), m_bitErrsAccum(0U), m_enabled(true) { - assert(rssiMapper != NULL); + assert(rssiMapper != nullptr); m_rfText = new char[4U * M17_META_LENGTH_BYTES]; m_netText = new char[4U * M17_META_LENGTH_BYTES]; @@ -125,7 +125,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) unsigned char type = data[0U]; - if (type == TAG_LOST && (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA_AUDIO)) { + if (type == TAG_LOST && (m_rfState == RPT_RF_STATE::AUDIO || m_rfState == RPT_RF_STATE::DATA_AUDIO)) { if (m_rssi != 0U) { LogMessage("M17, transmission lost from %s to %s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_source.c_str(), m_dest.c_str(), float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); writeJSONRF("lost", float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); @@ -291,7 +291,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) } } - if ((m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA_AUDIO) && data[0U] == TAG_DATA) { + if (((m_rfState == RPT_RF_STATE::AUDIO) || (m_rfState == RPT_RF_STATE::DATA_AUDIO)) && (data[0U] == TAG_DATA)) { // Keep looking at the running LSF in case of changed META field data unsigned int lich1, lich2, lich3, lich4; bool valid1 = CGolay24128::decode24128(data + 2U + M17_SYNC_LENGTH_BYTES + 0U, lich1); @@ -441,7 +441,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) return true; } - if ((m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA_AUDIO) && data[0U] == TAG_EOT) { + if (((m_rfState == RPT_RF_STATE::AUDIO) || (m_rfState == RPT_RF_STATE::DATA_AUDIO)) && (data[0U] == TAG_EOT)) { if (m_duplex) { unsigned char rfData[M17_FRAME_LENGTH_BYTES + 2U]; @@ -524,8 +524,8 @@ void CM17Control::writeEndRF() m_rfCollectingLSF.reset(); m_rfCollectedLSF.reset(); - if (m_netState == RS_NET_IDLE) { - if (m_network != NULL) + if (m_netState == RPT_NET_STATE::IDLE) { + if (m_network != nullptr) m_network->reset(); } } @@ -542,7 +542,7 @@ void CM17Control::writeEndNet() m_netLSF.reset(); - if (m_network != NULL) + if (m_network != nullptr) m_network->reset(); } @@ -587,17 +587,17 @@ void CM17Control::writeNetwork() switch (dataType) { case M17_DATA_TYPE_DATA: LogMessage("M17, received network data transmission from %s to %s", m_source.c_str(), m_dest.c_str()); - m_netState = RS_NET_DATA; + m_netState = RPT_NET_STATE::DATA; writeJSONNet("start", m_netState, m_source, m_dest); break; case M17_DATA_TYPE_VOICE: LogMessage("M17, received network voice transmission from %s to %s", m_source.c_str(), m_dest.c_str()); - m_netState = RS_NET_AUDIO; + m_netState = RPT_NET_STATE::AUDIO; writeJSONNet("start", m_netState, m_source, m_dest); break; case M17_DATA_TYPE_VOICE_DATA: LogMessage("M17, received network voice + data transmission from %s to %s", m_source.c_str(), m_dest.c_str()); - m_netState = RS_NET_DATA_AUDIO; + m_netState = RPT_NET_STATE::DATA_AUDIO; writeJSONNet("start", m_netState, m_source, m_dest); break; default: @@ -768,8 +768,8 @@ bool CM17Control::processRFHeader(bool lateEntry) unsigned char type = m_rfCurrentNetLSF.getEncryptionType(); if (type != M17_ENCRYPTION_TYPE_NONE) { LogMessage("M17, access attempt with encryption from %s to %s", m_source.c_str(), m_dest.c_str()); - m_rfState = RS_RF_REJECTED; - writeJSONRF("rejected", RS_RF_AUDIO, m_source, m_dest); + m_rfState = RPT_RF_STATE::REJECTED; + writeJSONRF("rejected", RPT_RF_STATE::AUDIO, m_source, m_dest); return true; } } @@ -778,8 +778,8 @@ bool CM17Control::processRFHeader(bool lateEntry) bool ret = checkCallsign(m_source); if (!ret) { LogMessage("M17, invalid access attempt from %s to %s", m_source.c_str(), m_dest.c_str()); - m_rfState = RS_RF_REJECTED; - writeJSONRF("rejected", RS_RF_AUDIO, m_source, m_dest); + m_rfState = RPT_RF_STATE::REJECTED; + writeJSONRF("rejected", RPT_RF_STATE::AUDIO, m_source, m_dest); return true; } } @@ -788,17 +788,17 @@ bool CM17Control::processRFHeader(bool lateEntry) switch (dataType) { case M17_DATA_TYPE_DATA: LogMessage("M17, received RF%sdata transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str()); - m_rfState = RS_RF_DATA; + m_rfState = RPT_RF_STATE::DATA; writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest); break; case M17_DATA_TYPE_VOICE: LogMessage("M17, received RF%svoice transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str()); - m_rfState = RS_RF_AUDIO; + m_rfState = RPT_RF_STATE::AUDIO; writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest); break; case M17_DATA_TYPE_VOICE_DATA: LogMessage("M17, received RF%svoice + data transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str()); - m_rfState = RS_RF_DATA_AUDIO; + m_rfState = RPT_RF_STATE::DATA_AUDIO; writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest); break; default: @@ -947,7 +947,7 @@ bool CM17Control::checkCallsign(const std::string& callsign) const bool CM17Control::isBusy() const { - return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; + return (m_rfState != RPT_RF_STATE::LISTENING) || (m_netState != RPT_NET_STATE::IDLE); } void CM17Control::enable(bool enabled) @@ -956,12 +956,12 @@ void CM17Control::enable(bool enabled) m_queue.clear(); // Reset the RF section - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; m_rfTimeoutTimer.stop(); // Reset the networking section - m_netState = RS_NET_IDLE; + m_netState = RPT_NET_STATE::IDLE; m_netTimeoutTimer.stop(); m_networkWatchdog.stop(); @@ -1009,7 +1009,7 @@ void CM17Control::writeJSONBER() void CM17Control::writeJSONText(const char* text) { - assert(text != NULL); + assert(text != nullptr); nlohmann::json json; @@ -1023,7 +1023,7 @@ void CM17Control::writeJSONText(const char* text) void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1034,7 +1034,7 @@ void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std: void CM17Control::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1045,7 +1045,7 @@ void CM17Control::writeJSONRF(const char* action, float duration, float ber) void CM17Control::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1063,7 +1063,7 @@ void CM17Control::writeJSONRF(const char* action, float duration, float ber, int void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1074,7 +1074,7 @@ void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const st void CM17Control::writeJSONNet(const char* action, float duration) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1087,7 +1087,7 @@ void CM17Control::writeJSONNet(const char* action, float duration) void CM17Control::writeJSONRF(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1096,7 +1096,7 @@ void CM17Control::writeJSONRF(nlohmann::json& json, const char* action) void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1106,15 +1106,14 @@ void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_S json["source"] = "rf"; json["action"] = action; - switch (state) - { - case RS_RF_AUDIO: + switch (state) { + case RPT_RF_STATE::AUDIO: json["traffic_type"] = "audio"; break; - case RS_RF_DATA_AUDIO: + case RPT_RF_STATE::DATA_AUDIO: json["traffic_type"] = "audio_data"; break; - case RS_RF_DATA: + case RPT_RF_STATE::DATA: json["traffic_type"] = "data"; break; default: @@ -1124,7 +1123,7 @@ void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_S void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); writeJSONRF(json, action); @@ -1134,7 +1133,7 @@ void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, float du void CM17Control::writeJSONNet(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1143,7 +1142,7 @@ void CM17Control::writeJSONNet(nlohmann::json& json, const char* action) void CM17Control::writeJSONNet(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1153,15 +1152,14 @@ void CM17Control::writeJSONNet(nlohmann::json& json, const char* action, RPT_NET json["source"] = "network"; json["action"] = action; - switch (state) - { - case RS_NET_AUDIO: + switch (state) { + case RPT_NET_STATE::AUDIO: json["traffic_type"] = "audio"; break; - case RS_NET_DATA_AUDIO: + case RPT_NET_STATE::DATA_AUDIO: json["traffic_type"] = "audio_data"; break; - case RS_NET_DATA: + case RPT_NET_STATE::DATA: json["traffic_type"] = "data"; break; default: diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 30a705a..d94ad3e 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -71,7 +71,7 @@ static void sigHandler(int signum) } #endif -static CMMDVMHost* host = NULL; +static CMMDVMHost* host = nullptr; const char* HEADER1 = "This software is for use on amateur radio networks only,"; const char* HEADER2 = "it is to be used for educational purposes only. Its use on"; @@ -112,7 +112,7 @@ int main(int argc, char** argv) ret = host->run(); delete host; - host = NULL; + host = nullptr; switch (m_signal) { case 0: @@ -140,60 +140,60 @@ int main(int argc, char** argv) CMMDVMHost::CMMDVMHost(const std::string& confFile) : m_conf(confFile), -m_modem(NULL), +m_modem(nullptr), #if defined(USE_DSTAR) -m_dstar(NULL), +m_dstar(nullptr), #endif #if defined(USE_DMR) -m_dmr(NULL), +m_dmr(nullptr), #endif #if defined(USE_YSF) -m_ysf(NULL), +m_ysf(nullptr), #endif #if defined(USE_P25) -m_p25(NULL), +m_p25(nullptr), #endif #if defined(USE_NXDN) -m_nxdn(NULL), +m_nxdn(nullptr), #endif #if defined(USE_M17) -m_m17(NULL), +m_m17(nullptr), #endif #if defined(USE_POCSAG) -m_pocsag(NULL), +m_pocsag(nullptr), #endif #if defined(USE_FM) -m_fm(NULL), +m_fm(nullptr), #endif #if defined(USE_AX25) -m_ax25(NULL), +m_ax25(nullptr), #endif #if defined(USE_DSTAR) -m_dstarNetwork(NULL), +m_dstarNetwork(nullptr), #endif #if defined(USE_DMR) -m_dmrNetwork(NULL), +m_dmrNetwork(nullptr), #endif #if defined(USE_YSF) -m_ysfNetwork(NULL), +m_ysfNetwork(nullptr), #endif #if defined(USE_P25) -m_p25Network(NULL), +m_p25Network(nullptr), #endif #if defined(USE_NXDN) -m_nxdnNetwork(NULL), +m_nxdnNetwork(nullptr), #endif #if defined(USE_M17) -m_m17Network(NULL), +m_m17Network(nullptr), #endif #if defined(USE_POCSAG) -m_pocsagNetwork(NULL), +m_pocsagNetwork(nullptr), #endif #if defined(USE_FM) -m_fmNetwork(NULL), +m_fmNetwork(nullptr), #endif #if defined(USE_AX25) -m_ax25Network(NULL), +m_ax25Network(nullptr), #endif m_mode(MODE_IDLE), #if defined(USE_DSTAR) @@ -259,20 +259,20 @@ m_fmEnabled(false), m_ax25Enabled(false), m_cwIdTime(0U), #if defined(USE_DMR) || defined(USE_P25) -m_dmrLookup(NULL), +m_dmrLookup(nullptr), #endif #if defined(USE_NXDN) -m_nxdnLookup(NULL), +m_nxdnLookup(nullptr), #endif m_callsign(), m_id(0U), m_cwCallsign(), m_lockFileEnabled(false), m_lockFileName(), -m_remoteControl(NULL), +m_remoteControl(nullptr), m_fixedMode(false), m_serialTimer(1000U, 0U, 210U), // 252 bytes at 9600 bps -m_serialBuffer(NULL), +m_serialBuffer(nullptr), m_serialStart(0U), m_serialLength(0U) { @@ -373,7 +373,7 @@ int CMMDVMHost::run() if (!ret) { ::fprintf(stderr, "MMDVMHost: unable to start the MQTT Publisher\n"); delete m_mqtt; - m_mqtt = NULL; + m_mqtt = nullptr; } #if !defined(_WIN32) && !defined(_WIN64) @@ -659,7 +659,7 @@ int CMMDVMHost::run() #endif #if defined(USE_DMR) - DMR_BEACONS dmrBeacons = DMR_BEACONS_OFF; + DMR_BEACONS dmrBeacons = DMR_BEACONS::OFF; CTimer dmrBeaconIntervalTimer(1000U); CTimer dmrBeaconDurationTimer(1000U); @@ -756,7 +756,7 @@ int CMMDVMHost::run() break; } - m_dmr = new CDMRControl(id, colorCode, callHang, selfOnly, embeddedLCOnly, dumpTAData, prefixes, blackList, whiteList, slot1TGWhiteList, slot2TGWhiteList, m_timeout, m_modem, m_dmrNetwork, m_duplex, m_dmrLookup, rssi, jitter, ovcm); + m_dmr = new CDMRControl(id, colorCode, callHang, selfOnly, embeddedLCOnly, dumpTAData, prefixes, blackList, whiteList, slot1TGWhiteList, slot2TGWhiteList, m_timeout, m_modem, m_dmrNetwork, m_duplex, m_dmrLookup, rssi, jitter, ovcm, protect); m_dmrTXTimer.setTimeout(txHang); } @@ -1137,7 +1137,7 @@ int CMMDVMHost::run() } #if defined(USE_DSTAR) - if (m_dstar != NULL) { + if (m_dstar != nullptr) { ret = m_modem->hasDStarSpace(); if (ret) { len = m_dstar->readModem(data); @@ -1158,7 +1158,7 @@ int CMMDVMHost::run() #endif #if defined(USE_DMR) - if (m_dmr != NULL) { + if (m_dmr != nullptr) { ret = m_modem->hasDMRSpace1(); if (ret) { len = m_dmr->readModemSlot1(data); @@ -1206,7 +1206,7 @@ int CMMDVMHost::run() #endif #if defined(USE_YSF) - if (m_ysf != NULL) { + if (m_ysf != nullptr) { ret = m_modem->hasYSFSpace(); if (ret) { len = m_ysf->readModem(data); @@ -1227,7 +1227,7 @@ int CMMDVMHost::run() #endif #if defined(USE_P25) - if (m_p25 != NULL) { + if (m_p25 != nullptr) { ret = m_modem->hasP25Space(); if (ret) { len = m_p25->readModem(data); @@ -1248,7 +1248,7 @@ int CMMDVMHost::run() #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) { + if (m_nxdn != nullptr) { ret = m_modem->hasNXDNSpace(); if (ret) { len = m_nxdn->readModem(data); @@ -1269,7 +1269,7 @@ int CMMDVMHost::run() #endif #if defined(USE_M17) - if (m_m17 != NULL) { + if (m_m17 != nullptr) { ret = m_modem->hasM17Space(); if (ret) { len = m_m17->readModem(data); @@ -1290,7 +1290,7 @@ int CMMDVMHost::run() #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) { + if (m_pocsag != nullptr) { ret = m_modem->hasPOCSAGSpace(); if (ret) { len = m_pocsag->readModem(data); @@ -1311,7 +1311,7 @@ int CMMDVMHost::run() #endif #if defined(USE_FM) - if (m_fm != NULL) { + if (m_fm != nullptr) { unsigned int space = m_modem->getFMSpace(); if (space > 0U) { len = m_fm->readModem(data, space); @@ -1332,7 +1332,7 @@ int CMMDVMHost::run() #endif #if defined(USE_AX25) - if (m_ax25 != NULL) { + if (m_ax25 != nullptr) { ret = m_modem->hasAX25Space(); if (ret) { len = m_ax25->readModem(data); @@ -1388,79 +1388,79 @@ int CMMDVMHost::run() if (m_reload) { #if defined(USE_DMR) || defined(USE_P25) - if (m_dmrLookup != NULL) + if (m_dmrLookup != nullptr) m_dmrLookup->reload(); #endif #if defined(USE_NXDN) - if (m_nxdnLookup != NULL) + if (m_nxdnLookup != nullptr) m_nxdnLookup->reload(); #endif m_reload = false; } #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->clock(); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->clock(); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->clock(ms); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->clock(ms); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->clock(ms); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->clock(ms); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->clock(ms); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->clock(ms); #endif #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->clock(ms); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->clock(ms); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->clock(ms); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->clock(ms); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->clock(ms); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->clock(ms); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->clock(ms); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->clock(ms); #endif m_cwIdTimer.clock(ms); @@ -1541,11 +1541,11 @@ int CMMDVMHost::run() setMode(MODE_QUIT); #if defined(USE_DMR) || defined(USE_P25) - if (m_dmrLookup != NULL) + if (m_dmrLookup != nullptr) m_dmrLookup->stop(); #endif #if defined(USE_NXDN) - if (m_nxdnLookup != NULL) + if (m_nxdnLookup != nullptr) m_nxdnLookup->stop(); #endif @@ -1553,63 +1553,63 @@ int CMMDVMHost::run() writeJSONMessage("Closing network connections"); #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) { + if (m_dstarNetwork != nullptr) { m_dstarNetwork->close(); delete m_dstarNetwork; } #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) { + if (m_dmrNetwork != nullptr) { m_dmrNetwork->close(true); delete m_dmrNetwork; } #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) { + if (m_ysfNetwork != nullptr) { m_ysfNetwork->close(); delete m_ysfNetwork; } #endif #if defined(USE_P25) - if (m_p25Network != NULL) { + if (m_p25Network != nullptr) { m_p25Network->close(); delete m_p25Network; } #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) { + if (m_nxdnNetwork != nullptr) { m_nxdnNetwork->close(); delete m_nxdnNetwork; } #endif #if defined(USE_M17) - if (m_m17Network != NULL) { + if (m_m17Network != nullptr) { m_m17Network->close(); delete m_m17Network; } #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) { + if (m_pocsagNetwork != nullptr) { m_pocsagNetwork->close(); delete m_pocsagNetwork; } #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) { + if (m_fmNetwork != nullptr) { m_fmNetwork->close(); delete m_fmNetwork; } #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) { + if (m_ax25Network != nullptr) { m_ax25Network->close(); delete m_ax25Network; } @@ -1659,7 +1659,7 @@ int CMMDVMHost::run() m_modem->close(); delete m_modem; - if (m_mqtt != NULL) { + if (m_mqtt != nullptr) { m_mqtt->close(); delete m_mqtt; } @@ -2358,7 +2358,7 @@ void CMMDVMHost::readParams() void CMMDVMHost::setMode(unsigned char mode) { - assert(m_modem != NULL); + assert(m_modem != nullptr); switch (mode) { #if defined(USE_DSTAR) @@ -2366,69 +2366,69 @@ void CMMDVMHost::setMode(unsigned char mode) if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(true); #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(true); #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_DSTAR); @@ -2442,71 +2442,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_DMR) case MODE_DMR: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(true); #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(true); #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_DMR); @@ -2524,71 +2524,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_YSF) case MODE_YSF: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(true); #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(true); #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_YSF); @@ -2602,71 +2602,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_P25) case MODE_P25: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(true); #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(true); #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_P25); @@ -2680,71 +2680,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_NXDN) case MODE_NXDN: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(true); #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(true); #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_NXDN); @@ -2758,71 +2758,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_M17) case MODE_M17: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(true); #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(true); #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_M17); @@ -2836,71 +2836,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_POCSAG) case MODE_POCSAG: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(true); #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(true); #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif m_modem->setMode(MODE_POCSAG); @@ -2914,71 +2914,71 @@ void CMMDVMHost::setMode(unsigned char mode) #if defined(USE_FM) case MODE_FM: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(true); #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(true); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(true); #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(true); #endif #if defined(USE_DMR) @@ -2998,75 +2998,75 @@ void CMMDVMHost::setMode(unsigned char mode) case MODE_LOCKOUT: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif #if defined(USE_DMR) @@ -3086,75 +3086,75 @@ void CMMDVMHost::setMode(unsigned char mode) case MODE_ERROR: LogMessage("Mode set to Error"); #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(false); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(false); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(false); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(false); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(false); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(false); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(false); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(false); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(false); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(false); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(false); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(false); #endif #if defined(USE_DMR) @@ -3172,75 +3172,75 @@ void CMMDVMHost::setMode(unsigned char mode) default: #if defined(USE_DSTAR) - if (m_dstarNetwork != NULL) + if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(true); #endif #if defined(USE_DMR) - if (m_dmrNetwork != NULL) + if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(true); #endif #if defined(USE_YSF) - if (m_ysfNetwork != NULL) + if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(true); #endif #if defined(USE_P25) - if (m_p25Network != NULL) + if (m_p25Network != nullptr) m_p25Network->enable(true); #endif #if defined(USE_NXDN) - if (m_nxdnNetwork != NULL) + if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(true); #endif #if defined(USE_M17) - if (m_m17Network != NULL) + if (m_m17Network != nullptr) m_m17Network->enable(true); #endif #if defined(USE_POCSAG) - if (m_pocsagNetwork != NULL) + if (m_pocsagNetwork != nullptr) m_pocsagNetwork->enable(true); #endif #if defined(USE_FM) - if (m_fmNetwork != NULL) + if (m_fmNetwork != nullptr) m_fmNetwork->enable(true); #endif #if defined(USE_AX25) - if (m_ax25Network != NULL) + if (m_ax25Network != nullptr) m_ax25Network->enable(true); #endif #if defined(USE_DSTAR) - if (m_dstar != NULL) + if (m_dstar != nullptr) m_dstar->enable(true); #endif #if defined(USE_DMR) - if (m_dmr != NULL) + if (m_dmr != nullptr) m_dmr->enable(true); #endif #if defined(USE_YSF) - if (m_ysf != NULL) + if (m_ysf != nullptr) m_ysf->enable(true); #endif #if defined(USE_P25) - if (m_p25 != NULL) + if (m_p25 != nullptr) m_p25->enable(true); #endif #if defined(USE_NXDN) - if (m_nxdn != NULL) + if (m_nxdn != nullptr) m_nxdn->enable(true); #endif #if defined(USE_M17) - if (m_m17 != NULL) + if (m_m17 != nullptr) m_m17->enable(true); #endif #if defined(USE_POCSAG) - if (m_pocsag != NULL) + if (m_pocsag != nullptr) m_pocsag->enable(true); #endif #if defined(USE_FM) - if (m_fm != NULL) + if (m_fm != nullptr) m_fm->enable(true); #endif #if defined(USE_AX25) - if (m_ax25 != NULL) + if (m_ax25 != nullptr) m_ax25->enable(true); #endif #if defined(USE_DMR) @@ -3290,7 +3290,7 @@ void CMMDVMHost::remoteControl(const std::string& commandString) REMOTE_COMMAND command = m_remoteControl->getCommand(commandString); switch (command) { - case REMOTE_COMMAND::MODE_IDLE: + case REMOTE_COMMAND::MODE_IDLE: m_fixedMode = false; setMode(MODE_IDLE); break; @@ -3299,170 +3299,170 @@ void CMMDVMHost::remoteControl(const std::string& commandString) setMode(MODE_LOCKOUT); break; #if defined(USE_DSTAR) - case RCD_MODE_DSTAR: - if (m_dstar != NULL) + case REMOTE_COMMAND::MODE_DSTAR: + if (m_dstar != nullptr) processModeCommand(MODE_DSTAR, m_dstarRFModeHang); break; #endif #if defined(USE_DMR) - case RCD_MODE_DMR: - if (m_dmr != NULL) + case REMOTE_COMMAND::MODE_DMR: + if (m_dmr != nullptr) processModeCommand(MODE_DMR, m_dmrRFModeHang); break; #endif #if defined(USE_YSF) - case RCD_MODE_YSF: - if (m_ysf != NULL) + case REMOTE_COMMAND::MODE_YSF: + if (m_ysf != nullptr) processModeCommand(MODE_YSF, m_ysfRFModeHang); break; #endif #if defined(USE_P25) - case RCD_MODE_P25: - if (m_p25 != NULL) + case REMOTE_COMMAND::MODE_P25: + if (m_p25 != nullptr) processModeCommand(MODE_P25, m_p25RFModeHang); break; #endif #if defined(USE_NXDN) - case RCD_MODE_NXDN: - if (m_nxdn != NULL) + case REMOTE_COMMAND::MODE_NXDN: + if (m_nxdn != nullptr) processModeCommand(MODE_NXDN, m_nxdnRFModeHang); break; #endif #if defined(USE_M17) - case RCD_MODE_M17: - if (m_m17 != NULL) + case REMOTE_COMMAND::MODE_M17: + if (m_m17 != nullptr) processModeCommand(MODE_M17, m_m17RFModeHang); break; #endif #if defined(USE_FM) - case RCD_MODE_FM: + case REMOTE_COMMAND::MODE_FM: if (m_fmEnabled) processModeCommand(MODE_FM, 0); break; #endif #if defined(USE_DSTAR) - case RCD_ENABLE_DSTAR: - if (m_dstar != NULL && !m_dstarEnabled) + case REMOTE_COMMAND::ENABLE_DSTAR: + if (m_dstar != nullptr && !m_dstarEnabled) processEnableCommand(m_dstarEnabled, true); if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(true); break; #endif #if defined(USE_DMR) - case RCD_ENABLE_DMR: - if (m_dmr != NULL && !m_dmrEnabled) + case REMOTE_COMMAND::ENABLE_DMR: + if (m_dmr != nullptr && !m_dmrEnabled) processEnableCommand(m_dmrEnabled, true); if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(true); break; #endif #if defined(USE_YSF) - case RCD_ENABLE_YSF: - if (m_ysf != NULL && !m_ysfEnabled) + case REMOTE_COMMAND::ENABLE_YSF: + if (m_ysf != nullptr && !m_ysfEnabled) processEnableCommand(m_ysfEnabled, true); if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(true); break; #endif #if defined(USE_P25) - case RCD_ENABLE_P25: - if (m_p25 != NULL && !m_p25Enabled) + case REMOTE_COMMAND::ENABLE_P25: + if (m_p25 != nullptr && !m_p25Enabled) processEnableCommand(m_p25Enabled, true); if (m_p25Network != nullptr) m_p25Network->enable(true); break; #endif #if defined(USE_NXDN) - case RCD_ENABLE_NXDN: - if (m_nxdn != NULL && !m_nxdnEnabled) + case REMOTE_COMMAND::ENABLE_NXDN: + if (m_nxdn != nullptr && !m_nxdnEnabled) processEnableCommand(m_nxdnEnabled, true); if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(true); break; #endif #if defined(USE_M17) - case RCD_ENABLE_M17: - if (m_m17 != NULL && !m_m17Enabled) + case REMOTE_COMMAND::ENABLE_M17: + if (m_m17 != nullptr && !m_m17Enabled) processEnableCommand(m_m17Enabled, true); if (m_m17Network != nullptr) m_m17Network->enable(true); break; #endif #if defined(USE_FM) - case RCD_ENABLE_FM: + case REMOTE_COMMAND::ENABLE_FM: if (!m_fmEnabled) processEnableCommand(m_fmEnabled, true); break; #endif #if defined(USE_AX25) - case RCD_ENABLE_AX25: + case REMOTE_COMMAND::ENABLE_AX25: if (!m_ax25Enabled) processEnableCommand(m_ax25Enabled, true); break; #endif #if defined(USE_DSTAR) - case RCD_DISABLE_DSTAR: - if (m_dstar != NULL && m_dstarEnabled) + case REMOTE_COMMAND::DISABLE_DSTAR: + if (m_dstar != nullptr && m_dstarEnabled) processEnableCommand(m_dstarEnabled, false); if (m_dstarNetwork != nullptr) m_dstarNetwork->enable(false); break; #endif #if defined(USE_DMR) - case RCD_DISABLE_DMR: - if (m_dmr != NULL && m_dmrEnabled) + case REMOTE_COMMAND::DISABLE_DMR: + if (m_dmr != nullptr && m_dmrEnabled) processEnableCommand(m_dmrEnabled, false); if (m_dmrNetwork != nullptr) m_dmrNetwork->enable(false); break; #endif #if defined(USE_YSF) - case RCD_DISABLE_YSF: - if (m_ysf != NULL && m_ysfEnabled) + case REMOTE_COMMAND::DISABLE_YSF: + if (m_ysf != nullptr && m_ysfEnabled) processEnableCommand(m_ysfEnabled, false); if (m_ysfNetwork != nullptr) m_ysfNetwork->enable(false); break; #endif #if defined(USE_P25) - case RCD_DISABLE_P25: - if (m_p25 != NULL && m_p25Enabled) + case REMOTE_COMMAND::DISABLE_P25: + if (m_p25 != nullptr && m_p25Enabled) processEnableCommand(m_p25Enabled, false); if (m_p25Network != nullptr) m_p25Network->enable(false); break; #endif #if defined(USE_NXDN) - case RCD_DISABLE_NXDN: - if (m_nxdn != NULL && m_nxdnEnabled) + case REMOTE_COMMAND::DISABLE_NXDN: + if (m_nxdn != nullptr && m_nxdnEnabled) processEnableCommand(m_nxdnEnabled, false); if (m_nxdnNetwork != nullptr) m_nxdnNetwork->enable(false); break; #endif #if defined(USE_M17) - case RCD_DISABLE_M17: - if (m_m17 != NULL && m_m17Enabled) + case REMOTE_COMMAND::DISABLE_M17: + if (m_m17 != nullptr && m_m17Enabled) processEnableCommand(m_m17Enabled, false); if (m_m17Network != nullptr) m_m17Network->enable(false); break; #endif #if defined(USE_FM) - case RCD_DISABLE_FM: + case REMOTE_COMMAND::DISABLE_FM: if (m_fmEnabled) processEnableCommand(m_fmEnabled, false); break; #endif #if defined(USE_AX25) - case RCD_DISABLE_AX25: + case REMOTE_COMMAND::DISABLE_AX25: if (m_ax25Enabled) processEnableCommand(m_ax25Enabled, false); break; #endif #if defined(USE_POCSAG) - case RCD_PAGE: - if (m_pocsag != NULL) { + case REMOTE_COMMAND::PAGE: + if (m_pocsag != nullptr) { unsigned int ric = m_remoteControl->getArgUInt(0U); std::string text; for (unsigned int i = 1U; i < m_remoteControl->getArgCount(); i++) { @@ -3504,7 +3504,7 @@ void CMMDVMHost::remoteControl(const std::string& commandString) } break; #endif - case RCD_CW: + case REMOTE_COMMAND::CW: setMode(MODE_IDLE); // Force the modem to go idle so that we can send the CW text. if (!m_modem->hasTX()) { std::string cwtext; @@ -3559,22 +3559,22 @@ void CMMDVMHost::buildNetworkStatusString(std::string &str) str = ""; #if defined(USE_DSTAR) - str += std::string("dstar:") + (((m_dstarNetwork == NULL) || !m_dstarEnabled) ? "n/a" : (m_dstarNetwork->isConnected() ? "conn" : "disc")); + str += std::string("dstar:") + (((m_dstarNetwork == nullptr) || !m_dstarEnabled) ? "n/a" : (m_dstarNetwork->isConnected() ? "conn" : "disc")); #endif #if defined(USE_DMR) - str += std::string(" dmr:") + (((m_dmrNetwork == NULL) || !m_dmrEnabled) ? "n/a" : (m_dmrNetwork->isConnected() ? "conn" : "disc")); + str += std::string(" dmr:") + (((m_dmrNetwork == nullptr) || !m_dmrEnabled) ? "n/a" : (m_dmrNetwork->isConnected() ? "conn" : "disc")); #endif #if defined(USE_YSF) - str += std::string(" ysf:") + (((m_ysfNetwork == NULL) || !m_ysfEnabled) ? "n/a" : (m_ysfNetwork->isConnected() ? "conn" : "disc")); + str += std::string(" ysf:") + (((m_ysfNetwork == nullptr) || !m_ysfEnabled) ? "n/a" : (m_ysfNetwork->isConnected() ? "conn" : "disc")); #endif #if defined(USE_P25) - str += std::string(" p25:") + (((m_p25Network == NULL) || !m_p25Enabled) ? "n/a" : (m_p25Network->isConnected() ? "conn" : "disc")); + str += std::string(" p25:") + (((m_p25Network == nullptr) || !m_p25Enabled) ? "n/a" : (m_p25Network->isConnected() ? "conn" : "disc")); #endif #if defined(USE_NXDN) - str += std::string(" nxdn:") + (((m_nxdnNetwork == NULL) || !m_nxdnEnabled) ? "n/a" : (m_nxdnNetwork->isConnected() ? "conn" : "disc")); + str += std::string(" nxdn:") + (((m_nxdnNetwork == nullptr) || !m_nxdnEnabled) ? "n/a" : (m_nxdnNetwork->isConnected() ? "conn" : "disc")); #endif #if defined(USE_M17) - str += std::string(" m17:") + (((m_m17Network == NULL) || !m_m17Enabled) ? "n/a" : (m_m17Network->isConnected() ? "conn" : "disc")); + str += std::string(" m17:") + (((m_m17Network == nullptr) || !m_m17Enabled) ? "n/a" : (m_m17Network->isConnected() ? "conn" : "disc")); #endif #if defined(USE_FM) str += std::string(" fm:") + (m_fmEnabled ? "conn" : "n/a"); @@ -3611,22 +3611,22 @@ void CMMDVMHost::buildNetworkHostsString(std::string &str) str += std::string("dstar:\"") + ((dstarReflector.length() == 0) ? "NONE" : dstarReflector) + "\""; #endif #if defined(USE_DMR) - str += std::string(" dmr:\"") + ((m_dmrEnabled && (m_dmrNetwork != NULL)) ? m_conf.getDMRNetworkGatewayAddress() : "NONE") + "\""; + str += std::string(" dmr:\"") + ((m_dmrEnabled && (m_dmrNetwork != nullptr)) ? m_conf.getDMRNetworkGatewayAddress() : "NONE") + "\""; #endif #if defined(USE_YSF) - str += std::string(" ysf:\"") + ((m_ysfEnabled && (m_ysfNetwork != NULL)) ? m_conf.getFusionNetworkGatewayAddress() : "NONE") + "\""; + str += std::string(" ysf:\"") + ((m_ysfEnabled && (m_ysfNetwork != nullptr)) ? m_conf.getFusionNetworkGatewayAddress() : "NONE") + "\""; #endif #if defined(USE_P25) - str += std::string(" p25:\"") + ((m_p25Enabled && (m_p25Network != NULL)) ? m_conf.getP25GatewayAddress() : "NONE") + "\""; + str += std::string(" p25:\"") + ((m_p25Enabled && (m_p25Network != nullptr)) ? m_conf.getP25GatewayAddress() : "NONE") + "\""; #endif #if defined(USE_NXDN) - str += std::string(" nxdn:\"") + ((m_nxdnEnabled && (m_nxdnNetwork != NULL)) ? m_conf.getNXDNGatewayAddress() : "NONE") + "\""; + str += std::string(" nxdn:\"") + ((m_nxdnEnabled && (m_nxdnNetwork != nullptr)) ? m_conf.getNXDNGatewayAddress() : "NONE") + "\""; #endif #if defined(USE_M17) - str += std::string(" m17:\"") + ((m_m17Enabled && (m_m17Network != NULL)) ? m_conf.getM17GatewayAddress() : "NONE") + "\""; + str += std::string(" m17:\"") + ((m_m17Enabled && (m_m17Network != nullptr)) ? m_conf.getM17GatewayAddress() : "NONE") + "\""; #endif #if defined(USE_FM) - str += std::string(" fm:\"") + ((m_fmEnabled && (m_fmNetwork != NULL)) ? m_conf.getFMGatewayAddress() : "NONE") + "\""; + str += std::string(" fm:\"") + ((m_fmEnabled && (m_fmNetwork != nullptr)) ? m_conf.getFMGatewayAddress() : "NONE") + "\""; #endif } @@ -3652,8 +3652,8 @@ void CMMDVMHost::writeJSONMessage(const std::string& message) void CMMDVMHost::writeSerial(const unsigned char* message, unsigned int length) { - assert(m_modem != NULL); - assert(message != NULL); + assert(m_modem != nullptr); + assert(message != nullptr); if (length <= 252U) { // Simple case of a short message, send it immediately to the modem @@ -3672,9 +3672,9 @@ void CMMDVMHost::writeSerial(const unsigned char* message, unsigned int length) #if defined(USE_AX25) void CMMDVMHost::writeAX25(const unsigned char* message, unsigned int length) { - assert(host != NULL); - assert(message != NULL); - assert(m_ax25Network != NULL); + assert(host != nullptr); + assert(message != nullptr); + assert(m_ax25Network != nullptr); m_ax25Network->setData(message, length); } @@ -3682,16 +3682,16 @@ void CMMDVMHost::writeAX25(const unsigned char* message, unsigned int length) void CMMDVMHost::onCommand(const unsigned char* command, unsigned int length) { - assert(host != NULL); - assert(command != NULL); + assert(host != nullptr); + assert(command != nullptr); host->remoteControl(std::string((char*)command, length)); } void CMMDVMHost::onDisplay(const unsigned char* message, unsigned int length) { - assert(host != NULL); - assert(message != NULL); + assert(host != nullptr); + assert(message != nullptr); host->writeSerial(message, length); } @@ -3699,8 +3699,8 @@ void CMMDVMHost::onDisplay(const unsigned char* message, unsigned int length) #if defined(USE_AX25) void CMMDVMHost::onAX25(const unsigned char* message, unsigned int length) { - assert(host != NULL); - assert(message != NULL); + assert(host != nullptr); + assert(message != nullptr); host->writeAX25(message, length); } diff --git a/MQTTConnection.cpp b/MQTTConnection.cpp index beb3e4f..2e7c8c6 100644 --- a/MQTTConnection.cpp +++ b/MQTTConnection.cpp @@ -33,7 +33,7 @@ m_password(password), m_subs(subs), m_keepalive(keepalive), m_qos(qos), -m_mosq(NULL), +m_mosq(nullptr), m_connected(false) { assert(!host.empty()); @@ -51,8 +51,8 @@ CMQTTConnection::~CMQTTConnection() bool CMQTTConnection::open() { - m_mosq = ::mosquitto_new(NULL, true, this); - if (m_mosq == NULL) { + m_mosq = ::mosquitto_new(nullptr, true, this); + if (m_mosq == nullptr) { ::fprintf(stderr, "MQTT Error newing: Out of memory.\n"); return false; } @@ -68,7 +68,7 @@ bool CMQTTConnection::open() int rc = ::mosquitto_connect(m_mosq, m_host.c_str(), m_port, m_keepalive); if (rc != MOSQ_ERR_SUCCESS) { ::mosquitto_destroy(m_mosq); - m_mosq = NULL; + m_mosq = nullptr; ::fprintf(stderr, "MQTT Error connecting: %s\n", ::mosquitto_strerror(rc)); return false; } @@ -77,7 +77,7 @@ bool CMQTTConnection::open() if (rc != MOSQ_ERR_SUCCESS) { ::mosquitto_disconnect(m_mosq); ::mosquitto_destroy(m_mosq); - m_mosq = NULL; + m_mosq = nullptr; ::fprintf(stderr, "MQTT Error loop starting: %s\n", ::mosquitto_strerror(rc)); return false; } @@ -87,38 +87,38 @@ bool CMQTTConnection::open() bool CMQTTConnection::publish(const char* topic, const char* text) { - assert(topic != NULL); - assert(text != NULL); + assert(topic != nullptr); + assert(text != nullptr); return publish(topic, (unsigned char*)text, (unsigned int)::strlen(text)); } bool CMQTTConnection::publish(const char* topic, const std::string& text) { - assert(topic != NULL); + assert(topic != nullptr); return publish(topic, (unsigned char*)text.c_str(), (unsigned int)text.size()); } bool CMQTTConnection::publish(const char* topic, const unsigned char* data, unsigned int len) { - assert(topic != NULL); - assert(data != NULL); + assert(topic != nullptr); + assert(data != nullptr); if (!m_connected) return false; - if (::strchr(topic, '/') == NULL) { + if (::strchr(topic, '/') == nullptr) { char topicEx[100U]; ::sprintf(topicEx, "%s/%s", m_name.c_str(), topic); - int rc = ::mosquitto_publish(m_mosq, NULL, topicEx, len, data, static_cast(m_qos), false); + int rc = ::mosquitto_publish(m_mosq, nullptr, topicEx, len, data, static_cast(m_qos), false); if (rc != MOSQ_ERR_SUCCESS) { ::fprintf(stderr, "MQTT Error publishing: %s\n", ::mosquitto_strerror(rc)); return false; } } else { - int rc = ::mosquitto_publish(m_mosq, NULL, topic, len, data, static_cast(m_qos), false); + int rc = ::mosquitto_publish(m_mosq, nullptr, topic, len, data, static_cast(m_qos), false); if (rc != MOSQ_ERR_SUCCESS) { ::fprintf(stderr, "MQTT Error publishing: %s\n", ::mosquitto_strerror(rc)); return false; @@ -130,17 +130,17 @@ bool CMQTTConnection::publish(const char* topic, const unsigned char* data, unsi void CMQTTConnection::close() { - if (m_mosq != NULL) { + if (m_mosq != nullptr) { ::mosquitto_disconnect(m_mosq); ::mosquitto_destroy(m_mosq); - m_mosq = NULL; + m_mosq = nullptr; } } void CMQTTConnection::onConnect(mosquitto* mosq, void* obj, int rc) { - assert(mosq != NULL); - assert(obj != NULL); + assert(mosq != nullptr); + assert(obj != nullptr); ::fprintf(stdout, "MQTT: on_connect: %s\n", ::mosquitto_connack_string(rc)); if (rc != 0) { @@ -158,13 +158,13 @@ void CMQTTConnection::onConnect(mosquitto* mosq, void* obj, int rc) char topicEx[100U]; ::sprintf(topicEx, "%s/%s", p->m_name.c_str(), topic.c_str()); - rc = ::mosquitto_subscribe(mosq, NULL, topicEx, static_cast(p->m_qos)); + rc = ::mosquitto_subscribe(mosq, nullptr, topicEx, static_cast(p->m_qos)); if (rc != MOSQ_ERR_SUCCESS) { ::fprintf(stderr, "MQTT: error subscribing to %s - %s\n", topicEx, ::mosquitto_strerror(rc)); ::mosquitto_disconnect(mosq); } } else { - rc = ::mosquitto_subscribe(mosq, NULL, topic.c_str(), static_cast(p->m_qos)); + rc = ::mosquitto_subscribe(mosq, nullptr, topic.c_str(), static_cast(p->m_qos)); if (rc != MOSQ_ERR_SUCCESS) { ::fprintf(stderr, "MQTT: error subscribing to %s - %s\n", topic.c_str(), ::mosquitto_strerror(rc)); ::mosquitto_disconnect(mosq); @@ -175,9 +175,9 @@ void CMQTTConnection::onConnect(mosquitto* mosq, void* obj, int rc) void CMQTTConnection::onSubscribe(mosquitto* mosq, void* obj, int mid, int qosCount, const int* grantedQOS) { - assert(mosq != NULL); - assert(obj != NULL); - assert(grantedQOS != NULL); + assert(mosq != nullptr); + assert(obj != nullptr); + assert(grantedQOS != nullptr); for (int i = 0; i < qosCount; i++) ::fprintf(stdout, "MQTT: on_subscribe: %d:%d\n", i, grantedQOS[i]); @@ -185,9 +185,9 @@ void CMQTTConnection::onSubscribe(mosquitto* mosq, void* obj, int mid, int qosCo void CMQTTConnection::onMessage(mosquitto* mosq, void* obj, const mosquitto_message* message) { - assert(mosq != NULL); - assert(obj != NULL); - assert(message != NULL); + assert(mosq != nullptr); + assert(obj != nullptr); + assert(message != nullptr); CMQTTConnection* p = static_cast(obj); @@ -206,8 +206,8 @@ void CMQTTConnection::onMessage(mosquitto* mosq, void* obj, const mosquitto_mess void CMQTTConnection::onDisconnect(mosquitto* mosq, void* obj, int rc) { - assert(mosq != NULL); - assert(obj != NULL); + assert(mosq != nullptr); + assert(obj != nullptr); ::fprintf(stdout, "MQTT: on_disconnect: %s\n", ::mosquitto_reason_string(rc)); diff --git a/MQTTConnection.h b/MQTTConnection.h index 0e985df..ecd8143 100644 --- a/MQTTConnection.h +++ b/MQTTConnection.h @@ -24,15 +24,15 @@ #include #include -enum MQTT_QOS { - MQTT_QOS_AT_MODE_ONCE = 0U, - MQTT_QOS_AT_LEAST_ONCE = 1U, - MQTT_QOS_EXACTLY_ONCE = 2U +enum class MQTT_QOS { + AT_MODE_ONCE = 0U, + AT_LEAST_ONCE = 1U, + EXACTLY_ONCE = 2U }; class CMQTTConnection { public: - CMQTTConnection(const std::string& host, unsigned short port, const std::string& name, const bool authEnabled, const std::string& username, const std::string& password, const std::vector>& subs, unsigned int keepalive, MQTT_QOS qos = MQTT_QOS_EXACTLY_ONCE); + CMQTTConnection(const std::string& host, unsigned short port, const std::string& name, const bool authEnabled, const std::string& username, const std::string& password, const std::vector>& subs, unsigned int keepalive, MQTT_QOS qos = MQTT_QOS::EXACTLY_ONCE); ~CMQTTConnection(); bool open(); diff --git a/Modem.cpp b/Modem.cpp index 17f20c7..0ff2551 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -318,7 +318,7 @@ m_cd(false), m_lockout(false), m_error(false), m_mode(MODE_IDLE), -m_hwType(HWT_UNKNOWN), +m_hwType(HW_TYPE::UNKNOWN), #if defined(USE_AX25) m_ax25RXTwist(0), m_ax25TXDelay(300U), @@ -1610,7 +1610,7 @@ unsigned int CModem::readTransparentData(unsigned char* data) unsigned int CModem::readSerialData(unsigned char* data) { - assert(data != NULL); + assert(data != nullptr); if (m_rxSerialData.isEmpty()) return 0U; @@ -2368,7 +2368,7 @@ bool CModem::readVersion() LogInfo("MMDVM protocol version: 1, description: %.*s", m_length - 4U, m_buffer + 4U); m_capabilities1 = CAP1_DSTAR | CAP1_DMR | CAP1_YSF | CAP1_P25 | CAP1_NXDN; m_capabilities2 = CAP2_POCSAG; - if (::strstr((char*)(m_buffer + 4U), "v1.6.") != NULL) + if (::strstr((char*)(m_buffer + 4U), "v1.6.") != nullptr) m_capabilities1 |= CAP1_M17; break; diff --git a/NXDNControl.cpp b/NXDNControl.cpp index 8095a01..842f675 100644 --- a/NXDNControl.cpp +++ b/NXDNControl.cpp @@ -79,8 +79,8 @@ m_bitsCount(0U), m_bitErrsAccum(0U), m_enabled(true) { - assert(lookup != NULL); - assert(rssiMapper != NULL); + assert(lookup != nullptr); + assert(rssiMapper != nullptr); } CNXDNControl::~CNXDNControl() @@ -289,7 +289,7 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_rfTimeoutTimer.start(); - m_rfState = RS_RF_AUDIO; + m_rfState = RPT_RF_STATE::AUDIO; m_minRSSI = m_rssi; m_maxRSSI = m_rssi; @@ -401,7 +401,7 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne m_rfTimeoutTimer.start(); - m_rfState = RS_RF_AUDIO; + m_rfState = RPT_RF_STATE::AUDIO; m_minRSSI = m_rssi; m_maxRSSI = m_rssi; @@ -625,7 +625,7 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data) m_rfLayer3 = layer3; m_rfFrames = 0U; - m_rfState = RS_RF_DATA; + m_rfState = RPT_RF_STATE::DATA; } if (m_rfState != RPT_RF_STATE::DATA) @@ -715,8 +715,8 @@ void CNXDNControl::writeEndRF() m_rfTimeoutTimer.stop(); - if (m_netState == RS_NET_IDLE) { - if (m_network != NULL) + if (m_netState == RPT_NET_STATE::IDLE) { + if (m_network != nullptr) m_network->reset(); } @@ -733,7 +733,7 @@ void CNXDNControl::writeEndNet() m_networkWatchdog.stop(); m_packetTimer.stop(); - if (m_network != NULL) + if (m_network != nullptr) m_network->reset(); } @@ -1075,7 +1075,7 @@ void CNXDNControl::scrambler(unsigned char* data) const bool CNXDNControl::isBusy() const { - return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; + return (m_rfState != RPT_RF_STATE::LISTENING) || (m_netState != RPT_NET_STATE::IDLE); } void CNXDNControl::enable(bool enabled) @@ -1084,7 +1084,7 @@ void CNXDNControl::enable(bool enabled) m_queue.clear(); // Reset the RF section - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; m_rfMask = 0x00U; m_rfLayer3.reset(); @@ -1092,7 +1092,7 @@ void CNXDNControl::enable(bool enabled) m_rfTimeoutTimer.stop(); // Reset the networking section - m_netState = RS_NET_IDLE; + m_netState = RPT_NET_STATE::IDLE; m_netMask = 0x00U; m_netLayer3.reset(); @@ -1147,7 +1147,7 @@ void CNXDNControl::writeJSONBER(unsigned int bits, unsigned int errs) void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1158,7 +1158,7 @@ void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const s void CNXDNControl::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1172,7 +1172,7 @@ void CNXDNControl::writeJSONRF(const char* action, float duration, float ber) void CNXDNControl::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1193,7 +1193,7 @@ void CNXDNControl::writeJSONRF(const char* action, float duration, float ber, in void CNXDNControl::writeJSONNet(const char* action) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1204,7 +1204,7 @@ void CNXDNControl::writeJSONNet(const char* action) void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1215,7 +1215,7 @@ void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, unsigned char frames) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1228,7 +1228,7 @@ void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const void CNXDNControl::writeJSONNet(const char* action, float duration) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1241,7 +1241,7 @@ void CNXDNControl::writeJSONNet(const char* action, float duration) void CNXDNControl::writeJSON(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["action"] = action; @@ -1249,8 +1249,8 @@ void CNXDNControl::writeJSON(nlohmann::json& json, const char* action) void CNXDNControl::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId) { - assert(source != NULL); - assert(action != NULL); + assert(source != nullptr); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["source"] = source; diff --git a/NXDNKenwoodNetwork.cpp b/NXDNKenwoodNetwork.cpp index 1cc3468..e0c8083 100644 --- a/NXDNKenwoodNetwork.cpp +++ b/NXDNKenwoodNetwork.cpp @@ -776,7 +776,7 @@ unsigned int CNXDNKenwoodNetwork::readRTP(unsigned char* data) if (length <= 0) return 0U; - if (!CUDPSocket::match(m_rtpAddr, address, IPMATCHTYPE::IMT_ADDREONLY)) { + if (!CUDPSocket::match(m_rtpAddr, address, IPMATCHTYPE::ADDRESS_ONLY)) { LogMessage("NXDN, RTP packet received from an invalid source"); return 0U; } @@ -804,7 +804,7 @@ unsigned int CNXDNKenwoodNetwork::readRTCP(unsigned char* data) if (length <= 0) return 0U; - if (!CUDPSocket::match(m_rtpAddr, address, IPMATCHTYPE::IMT_ADDREONLY)) { + if (!CUDPSocket::match(m_rtpAddr, address, IPMATCHTYPE::ADDRESS_ONLY)) { LogMessage("NXDN, RTCP packet received from an invalid source"); return 0U; } diff --git a/P25Control.cpp b/P25Control.cpp index 5fbd64d..f70bd3e 100644 --- a/P25Control.cpp +++ b/P25Control.cpp @@ -91,8 +91,8 @@ m_bitsCount(0U), m_bitErrsAccum(0U), m_enabled(true) { - assert(lookup != NULL); - assert(rssiMapper != NULL); + assert(lookup != nullptr); + assert(rssiMapper != nullptr); m_netLDU1 = new unsigned char[9U * 25U]; m_netLDU2 = new unsigned char[9U * 25U]; @@ -153,8 +153,8 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len) return false; } - if (data[0U] == TAG_LOST && m_rfState == RS_RF_DATA) { - m_rfState = RS_RF_LISTENING; + if ((data[0U] == TAG_LOST) && (m_rfState == RPT_RF_STATE::DATA)) { + m_rfState = RPT_RF_STATE::LISTENING; m_rfPDUCount = 0U; m_rfPDUBits = 0U; @@ -1010,7 +1010,7 @@ void CP25Control::createNetHeader() LogMessage("P25, received network transmission from %s to %s%u", source.c_str(), lcf == P25_LCF_GROUP ? "TG " : "", dstId); writeJSONNet("start", srcId, source, lcf == P25_LCF_GROUP, dstId); - m_netState = RS_NET_AUDIO; + m_netState = RPT_NET_STATE::AUDIO; m_netTimeout.start(); m_netFrames = 0U; m_netLost = 0U; @@ -1187,12 +1187,12 @@ void CP25Control::createNetTerminator() m_netTimeout.stop(); m_networkWatchdog.stop(); m_netData.reset(); - m_netState = RS_NET_IDLE; + m_netState = RPT_NET_STATE::IDLE; } bool CP25Control::isBusy() const { - return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; + return (m_rfState != RPT_RF_STATE::LISTENING) || (m_netState != RPT_NET_STATE::IDLE); } void CP25Control::enable(bool enabled) @@ -1201,7 +1201,7 @@ void CP25Control::enable(bool enabled) m_queue.clear(); // Reset the RF section - m_rfState = RS_RF_LISTENING; + m_rfState = RPT_RF_STATE::LISTENING; m_rfTimeout.stop(); m_rfData.reset(); @@ -1209,7 +1209,7 @@ void CP25Control::enable(bool enabled) m_netTimeout.stop(); m_networkWatchdog.stop(); m_netData.reset(); - m_netState = RS_NET_IDLE; + m_netState = RPT_NET_STATE::IDLE; } m_enabled = enabled; @@ -1254,7 +1254,7 @@ void CP25Control::writeJSONBER() void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1265,7 +1265,7 @@ void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std: void CP25Control::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1279,7 +1279,7 @@ void CP25Control::writeJSONRF(const char* action, float duration, float ber) void CP25Control::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1300,7 +1300,7 @@ void CP25Control::writeJSONRF(const char* action, float duration, float ber, int void CP25Control::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1311,7 +1311,7 @@ void CP25Control::writeJSONNet(const char* action, unsigned int srcId, const std void CP25Control::writeJSONNet(const char* action, float duration, float loss) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1325,7 +1325,7 @@ void CP25Control::writeJSONNet(const char* action, float duration, float loss) void CP25Control::writeJSON(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["action"] = action; @@ -1333,8 +1333,8 @@ void CP25Control::writeJSON(nlohmann::json& json, const char* action) void CP25Control::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) { - assert(source != NULL); - assert(action != NULL); + assert(source != nullptr); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["source"] = source; diff --git a/POCSAGControl.cpp b/POCSAGControl.cpp index b1446fc..5e636ff 100644 --- a/POCSAGControl.cpp +++ b/POCSAGControl.cpp @@ -67,7 +67,7 @@ m_output(), m_buffer(), m_ric(0U), m_data(), -m_state(PS_NONE), +m_state(POCSAG_STATE::NONE), m_enabled(true) { } @@ -358,7 +358,7 @@ void CPOCSAGControl::clock(unsigned int ms) if (m_state == POCSAG_STATE::ENDING) { LogMessage("POCSAG, transmitted %u frame(s) of data from %u message(s)", m_frames, m_count); writeJSON("network", 0U, "end"); - m_state = PS_NONE; + m_state = POCSAG_STATE::NONE; } } @@ -533,8 +533,8 @@ void CPOCSAGControl::decodeROT1(const std::string& in, unsigned int start, std:: void CPOCSAGControl::writeJSON(const char* source, unsigned int ric, const char* functional) { - assert(source != NULL); - assert(functional != NULL); + assert(source != nullptr); + assert(functional != nullptr); nlohmann::json json; @@ -548,8 +548,8 @@ void CPOCSAGControl::writeJSON(const char* source, unsigned int ric, const char* void CPOCSAGControl::writeJSON(const char* source, unsigned int ric, const char* functional, const std::string& message) { - assert(source != NULL); - assert(functional != NULL); + assert(source != nullptr); + assert(functional != nullptr); nlohmann::json json; diff --git a/RemoteControl.cpp b/RemoteControl.cpp index 8576f25..1ad9383 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -34,11 +34,11 @@ const unsigned int CW_ARGS = 2U; CRemoteControl::CRemoteControl(CMMDVMHost *host, CMQTTConnection* mqtt) : m_host(host), m_mqtt(mqtt), -m_command(RCD_NONE), +m_command(REMOTE_COMMAND::NONE), m_args() { - assert(host != NULL); - assert(mqtt != NULL); + assert(host != nullptr); + assert(mqtt != nullptr); } CRemoteControl::~CRemoteControl() @@ -47,7 +47,7 @@ CRemoteControl::~CRemoteControl() REMOTE_COMMAND CRemoteControl::getCommand(const std::string& command) { - m_command = RCD_NONE; + m_command = REMOTE_COMMAND::NONE; m_args.clear(); std::string reply = "OK"; @@ -65,163 +65,163 @@ REMOTE_COMMAND CRemoteControl::getCommand(const std::string& command) if (m_args.at(0U) == "mode" && m_args.size() >= SET_MODE_ARGS) { // Mode command is in the form of "mode [|fixed]" if (m_args.at(1U) == "idle") - m_command = RCD_MODE_IDLE; + m_command = REMOTE_COMMAND::MODE_IDLE; else if (m_args.at(1U) == "lockout") - m_command = RCD_MODE_LOCKOUT; + m_command = REMOTE_COMMAND::MODE_LOCKOUT; #if defined(USE_DSTAR) else if (m_args.at(1U) == "d-star") - m_command = RCD_MODE_DSTAR; + m_command = REMOTE_COMMAND::MODE_DSTAR; #endif #if defined(USE_DMR) else if (m_args.at(1U) == "dmr") - m_command = RCD_MODE_DMR; + m_command = REMOTE_COMMAND::MODE_DMR; #endif #if defined(USE_YSF) else if (m_args.at(1U) == "ysf") - m_command = RCD_MODE_YSF; + m_command = REMOTE_COMMAND::MODE_YSF; #endif #if defined(USE_P25) else if (m_args.at(1U) == "p25") - m_command = RCD_MODE_P25; + m_command = REMOTE_COMMAND::MODE_P25; #endif #if defined(USE_NXDN) else if (m_args.at(1U) == "nxdn") - m_command = RCD_MODE_NXDN; + m_command = REMOTE_COMMAND::MODE_NXDN; #endif #if defined(USE_M17) else if (m_args.at(1U) == "m17") - m_command = RCD_MODE_M17; + m_command = REMOTE_COMMAND::MODE_M17; #endif else reply = "KO"; } else if (m_args.at(0U) == "enable" && m_args.size() >= ENABLE_ARGS) { #if defined(USE_DSTAR) if (m_args.at(1U) == "dstar") - m_command = RCD_ENABLE_DSTAR; + m_command = REMOTE_COMMAND::ENABLE_DSTAR; else #endif #if defined(USE_DMR) if (m_args.at(1U) == "dmr") - m_command = RCD_ENABLE_DMR; + m_command = REMOTE_COMMAND::ENABLE_DMR; else #endif #if defined(USE_YSF) if (m_args.at(1U) == "ysf") - m_command = RCD_ENABLE_YSF; + m_command = REMOTE_COMMAND::ENABLE_YSF; else #endif #if defined(USE_P25) if (m_args.at(1U) == "p25") - m_command = RCD_ENABLE_P25; + m_command = REMOTE_COMMAND::ENABLE_P25; else #endif #if defined(USE_NXDN) if (m_args.at(1U) == "nxdn") - m_command = RCD_ENABLE_NXDN; + m_command = REMOTE_COMMAND::ENABLE_NXDN; else #endif #if defined(USE_M17) if (m_args.at(1U) == "m17") - m_command = RCD_ENABLE_M17; + m_command = REMOTE_COMMAND::ENABLE_M17; else #endif #if defined(USE_FM) if (m_args.at(1U) == "fm") - m_command = RCD_ENABLE_FM; + m_command = REMOTE_COMMAND::ENABLE_FM; else #endif #if defined(USE_AX25) if (m_args.at(1U) == "ax25") - m_command = RCD_ENABLE_AX25; + m_command = REMOTE_COMMAND::ENABLE_AX25; else #endif reply = "KO"; } else if (m_args.at(0U) == "disable" && m_args.size() >= DISABLE_ARGS) { #if defined(USE_DSTAR) if (m_args.at(1U) == "dstar") - m_command = RCD_DISABLE_DSTAR; + m_command = REMOTE_COMMAND::DISABLE_DSTAR; else #endif #if defined(USE_DMR) if (m_args.at(1U) == "dmr") - m_command = RCD_DISABLE_DMR; + m_command = REMOTE_COMMAND::DISABLE_DMR; else #endif #if defined(USE_YSF) if (m_args.at(1U) == "ysf") - m_command = RCD_DISABLE_YSF; + m_command = REMOTE_COMMAND::DISABLE_YSF; else #endif #if defined(USE_P25) if (m_args.at(1U) == "p25") - m_command = RCD_DISABLE_P25; + m_command = REMOTE_COMMAND::DISABLE_P25; else #endif #if defined(USE_NXDN) if (m_args.at(1U) == "nxdn") - m_command = RCD_DISABLE_NXDN; + m_command = REMOTE_COMMAND::DISABLE_NXDN; else #endif #if defined(USE_M17) if (m_args.at(1U) == "m17") - m_command = RCD_DISABLE_M17; + m_command = REMOTE_COMMAND::DISABLE_M17; else #endif #if defined(USE_FM) if (m_args.at(1U) == "fm") - m_command = RCD_DISABLE_FM; + m_command = REMOTE_COMMAND::DISABLE_FM; else #endif #if defined(USE_AX25) if (m_args.at(1U) == "ax25") - m_command = RCD_DISABLE_AX25; + m_command = REMOTE_COMMAND::DISABLE_AX25; else #endif reply = "KO"; #if defined(USE_POCSAG) } else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) { // Page command is in the form of "page " - m_command = RCD_PAGE; + m_command = REMOTE_COMMAND::PAGE; } else if (m_args.at(0U) == "page_bcd" && m_args.size() >= PAGE_ARGS) { // BCD page command is in the form of "page_bcd " - m_command = RCD_PAGE_BCD; + m_command = REMOTE_COMMAND::PAGE_BCD; } else if (m_args.at(0U) == "page_a1" && m_args.size() == 2) { // Alert1 page command is in the form of "page_a1 " - m_command = RCD_PAGE_A1; + m_command = REMOTE_COMMAND::PAGE_A1; } else if (m_args.at(0U) == "page_a2" && m_args.size() >= PAGE_ARGS) { // Alert2 page command is in the form of "page_a2 " - m_command = RCD_PAGE_A2; + m_command = REMOTE_COMMAND::PAGE_A2; #endif } else if (m_args.at(0U) == "cw" && m_args.size() >= CW_ARGS) { // CW command is in the form of "cw " - m_command = RCD_CW; + m_command = REMOTE_COMMAND::CW; } else if (m_args.at(0U) == "reload") { // Reload command is in the form of "reload" - m_command = RCD_RELOAD; + m_command = REMOTE_COMMAND::RELOAD; } else if (m_args.at(0U) == "status") { - if (m_host != NULL) { + if (m_host != nullptr) { m_host->buildNetworkStatusString(reply); } else { reply = "KO"; } - m_command = RCD_CONNECTION_STATUS; + m_command = REMOTE_COMMAND::CONNECTION_STATUS; } else if (m_args.at(0U) == "hosts") { - if (m_host != NULL) { + if (m_host != nullptr) { m_host->buildNetworkHostsString(reply); } else { reply = "KO"; } - m_command = RCD_CONFIG_HOSTS; + m_command = REMOTE_COMMAND::CONFIG_HOSTS; } else { reply = "KO"; } char buffer[200U]; - ::snprintf(buffer, 200, "%s remote command of \"%s\" received", ((m_command == RCD_NONE) ? "Invalid" : "Valid"), command.c_str()); + ::snprintf(buffer, 200, "%s remote command of \"%s\" received", ((m_command == REMOTE_COMMAND::NONE) ? "Invalid" : "Valid"), command.c_str()); - if (m_command == RCD_NONE) { + if (m_command == REMOTE_COMMAND::NONE) { m_args.clear(); LogWarning(buffer); } else { @@ -236,35 +236,35 @@ REMOTE_COMMAND CRemoteControl::getCommand(const std::string& command) unsigned int CRemoteControl::getArgCount() const { switch (m_command) { - case RCD_MODE_IDLE: - case RCD_MODE_LOCKOUT: + case REMOTE_COMMAND::MODE_IDLE: + case REMOTE_COMMAND::MODE_LOCKOUT: #if defined(USE_DSTAR) - case RCD_MODE_DSTAR: + case REMOTE_COMMAND::MODE_DSTAR: #endif #if defined(USE_DMR) - case RCD_MODE_DMR: + case REMOTE_COMMAND::MODE_DMR: #endif #if defined(USE_YSF) - case RCD_MODE_YSF: + case REMOTE_COMMAND::MODE_YSF: #endif #if defined(USE_P25) - case RCD_MODE_P25: + case REMOTE_COMMAND::MODE_P25: #endif #if defined(USE_NXDN) - case RCD_MODE_NXDN: + case REMOTE_COMMAND::MODE_NXDN: #endif #if defined(USE_M17) - case RCD_MODE_M17: + case REMOTE_COMMAND::MODE_M17: #endif return (unsigned int)m_args.size() - SET_MODE_ARGS; #if defined(USE_POCSAG) - case RCD_PAGE: - case RCD_PAGE_BCD: - case RCD_PAGE_A1: - case RCD_PAGE_A2: + case REMOTE_COMMAND::PAGE: + case REMOTE_COMMAND::PAGE_BCD: + case REMOTE_COMMAND::PAGE_A1: + case REMOTE_COMMAND::PAGE_A2: return (unsigned int)m_args.size() - 1U; #endif - case RCD_CW: + case REMOTE_COMMAND::CW: return (unsigned int)m_args.size() - 1U; default: return 0U; @@ -274,37 +274,37 @@ unsigned int CRemoteControl::getArgCount() const std::string CRemoteControl::getArgString(unsigned int n) const { switch (m_command) { - case RCD_MODE_IDLE: - case RCD_MODE_LOCKOUT: + case REMOTE_COMMAND::MODE_IDLE: + case REMOTE_COMMAND::MODE_LOCKOUT: #if defined(USE_DSTAR) - case RCD_MODE_DSTAR: + case REMOTE_COMMAND::MODE_DSTAR: #endif #if defined(USE_DMR) - case RCD_MODE_DMR: + case REMOTE_COMMAND::MODE_DMR: #endif #if defined(USE_YSF) - case RCD_MODE_YSF: + case REMOTE_COMMAND::MODE_YSF: #endif #if defined(USE_P25) - case RCD_MODE_P25: + case REMOTE_COMMAND::MODE_P25: #endif #if defined(USE_NXDN) - case RCD_MODE_NXDN: + case REMOTE_COMMAND::MODE_NXDN: #endif #if defined(USE_M17) - case RCD_MODE_M17: + case REMOTE_COMMAND::MODE_M17: #endif n += SET_MODE_ARGS; break; #if defined(USE_POCSAG) - case RCD_PAGE: - case RCD_PAGE_BCD: - case RCD_PAGE_A1: - case RCD_PAGE_A2: + case REMOTE_COMMAND::PAGE: + case REMOTE_COMMAND::PAGE_BCD: + case REMOTE_COMMAND::PAGE_A1: + case REMOTE_COMMAND::PAGE_A2: n += 1U; break; #endif - case RCD_CW: + case REMOTE_COMMAND::CW: n += 1U; break; default: diff --git a/RemoteControl.h b/RemoteControl.h index 5a5871b..691866b 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -29,88 +29,88 @@ class CMMDVMHost; enum class REMOTE_COMMAND { - RCD_NONE, - RCD_MODE_IDLE, - RCD_MODE_LOCKOUT, + NONE, + MODE_IDLE, + MODE_LOCKOUT, #if defined(USE_DSTAR) - RCD_MODE_DSTAR, + MODE_DSTAR, #endif #if defined(USE_DMR) - RCD_MODE_DMR, + MODE_DMR, #endif #if defined(USE_YSF) - RCD_MODE_YSF, + MODE_YSF, #endif #if defined(USE_P25) - RCD_MODE_P25, + MODE_P25, #endif #if defined(USE_NXDN) - RCD_MODE_NXDN, + MODE_NXDN, #endif #if defined(USE_M17) - RCD_MODE_M17, + MODE_M17, #endif #if defined(USE_FM) - RCD_MODE_FM, + MODE_FM, #endif #if defined(USE_DSTAR) - RCD_ENABLE_DSTAR, + ENABLE_DSTAR, #endif #if defined(USE_DMR) - RCD_ENABLE_DMR, + ENABLE_DMR, #endif #if defined(USE_YSF) - RCD_ENABLE_YSF, + ENABLE_YSF, #endif #if defined(USE_P25) - RCD_ENABLE_P25, + ENABLE_P25, #endif #if defined(USE_NXDN) - RCD_ENABLE_NXDN, + ENABLE_NXDN, #endif #if defined(USE_M17) - RCD_ENABLE_M17, + ENABLE_M17, #endif #if defined(USE_FM) - RCD_ENABLE_FM, + ENABLE_FM, #endif #if defined(USE_AX25) - RCD_ENABLE_AX25, + ENABLE_AX25, #endif #if defined(USE_DSTAR) - RCD_DISABLE_DSTAR, + DISABLE_DSTAR, #endif #if defined(USE_DMR) - RCD_DISABLE_DMR, + DISABLE_DMR, #endif #if defined(USE_YSF) - RCD_DISABLE_YSF, + DISABLE_YSF, #endif #if defined(USE_P25) - RCD_DISABLE_P25, + DISABLE_P25, #endif #if defined(USE_NXDN) - RCD_DISABLE_NXDN, + DISABLE_NXDN, #endif #if defined(USE_M17) - RCD_DISABLE_M17, + DISABLE_M17, #endif #if defined(USE_FM) - RCD_DISABLE_FM, + DISABLE_FM, #endif #if defined(USE_AX25) - RCD_DISABLE_AX25, + DISABLE_AX25, #endif #if defined(USE_POCSAG) - RCD_PAGE, - RCD_PAGE_BCD, - RCD_PAGE_A1, - RCD_PAGE_A2, + PAGE, + PAGE_BCD, + PAGE_A1, + PAGE_A2, #endif - RCD_CW, - RCD_RELOAD, - RCD_CONNECTION_STATUS, - RCD_CONFIG_HOSTS + CW, + RELOAD, + CONNECTION_STATUS, + CONFIG_HOSTS }; class CRemoteControl { diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 2ca23de..6b5abcf 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -113,7 +113,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad if (addr1.ss_family != addr2.ss_family) return false; - if (type == IPMATCHTYPE::IMT_ADDREAND_PORT) { + if (type == IPMATCHTYPE::ADDRESS_AND_PORT) { switch (addr1.ss_family) { case AF_INET: struct sockaddr_in *in_1, *in_2; @@ -128,7 +128,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad default: return false; } - } else if (type == IPMATCHTYPE::IMT_ADDREONLY) { + } else if (type == IPMATCHTYPE::ADDRESS_ONLY) { switch (addr1.ss_family) { case AF_INET: struct sockaddr_in *in_1, *in_2; diff --git a/UDPSocket.h b/UDPSocket.h index fc0c422..3f33611 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -37,8 +37,8 @@ #endif enum class IPMATCHTYPE { - IMT_ADDREAND_PORT, - IMT_ADDREONLY + ADDRESS_AND_PORT, + ADDRESS_ONLY }; class CUDPSocket { @@ -61,7 +61,7 @@ public: static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength); static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength, struct addrinfo& hints); - static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::IMT_ADDREAND_PORT); + static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::ADDRESS_AND_PORT); static bool isNone(const sockaddr_storage& addr); diff --git a/Utils.cpp b/Utils.cpp index aa4417f..02b5f87 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -189,7 +189,7 @@ std::string CUtils::createTimestamp() ::sprintf(buffer, "%04u-%02u-%02u %02u:%02u:%02u.%03u", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); #else struct timeval now; - ::gettimeofday(&now, NULL); + ::gettimeofday(&now, nullptr); struct tm* tm = ::gmtime(&now.tv_sec); diff --git a/YSFControl.cpp b/YSFControl.cpp index 61c7aa2..134e4b0 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -27,8 +27,8 @@ const unsigned int RSSI_COUNT = 10U; // 10 * 100ms = 1000ms const unsigned int BER_COUNT = 10U; // 10 * 100ms = 1000ms CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) : -m_callsign(NULL), -m_selfCallsign(NULL), +m_callsign(nullptr), +m_selfCallsign(nullptr), m_selfOnly(selfOnly), m_network(network), m_duplex(duplex), @@ -68,7 +68,7 @@ m_bitsCount(0U), m_bitErrsAccum(0U), m_enabled(true) { - assert(rssiMapper != NULL); + assert(rssiMapper != nullptr); m_rfPayload.setUplink(callsign); m_rfPayload.setDownlink(callsign); @@ -110,7 +110,7 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len) unsigned char type = data[0U]; - if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) { + if ((type == TAG_LOST) && (m_rfState == RPT_RF_STATE::AUDIO)) { if (m_rssi != 0) { LogMessage("YSF, transmission lost from %10.10s to %10.10s, %.1f seconds, BER: %.1f%%, RSSI: %d/%d/%d dBm", m_rfSource, m_rfDest, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); writeJSONRF("lost", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / int(m_rssiCountTotal)); @@ -238,7 +238,7 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data) bool ret = checkCallsign(m_rfSource); if (!ret) { LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", "voice_vw", m_rfSource, dgid); return true; } @@ -406,7 +406,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) bool ret = checkCallsign(m_rfSource); if (!ret) { LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", "voice_dn", m_rfSource, dgid); return true; } @@ -602,7 +602,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data) bool ret = checkCallsign(m_rfSource); if (!ret) { LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", "voice_dn", m_rfSource, dgid); return true; } @@ -707,7 +707,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data) bool ret = checkCallsign(m_rfSource); if (!ret) { LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid); - m_rfState = RS_RF_REJECTED; + m_rfState = RPT_RF_STATE::REJECTED; writeJSONRF("rejected", "data_fr", m_rfSource, dgid); return true; } @@ -871,8 +871,8 @@ void CYSFControl::writeEndRF() m_rfSource = nullptr; m_rfDest = nullptr; - if (m_netState == RS_NET_IDLE) { - if (m_network != NULL) + if (m_netState == RPT_NET_STATE::IDLE) { + if (m_network != nullptr) m_network->reset(); } } @@ -887,7 +887,7 @@ void CYSFControl::writeEndNet() m_netPayload.reset(); - if (m_network != NULL) + if (m_network != nullptr) m_network->reset(); } @@ -1224,9 +1224,9 @@ void CYSFControl::writeJSONBER(unsigned int bits, unsigned int errs) void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid) { - assert(action != NULL); - assert(mode != NULL); - assert(source != NULL); + assert(action != nullptr); + assert(mode != nullptr); + assert(source != nullptr); nlohmann::json json; @@ -1239,7 +1239,7 @@ void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsign void CYSFControl::writeJSONRF(const char* action, float duration, float ber) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1253,7 +1253,7 @@ void CYSFControl::writeJSONRF(const char* action, float duration, float ber) void CYSFControl::writeJSONRF(const char* action, float duration, float ber, int minRSSI, int maxRSSI, int aveRSSI) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1274,9 +1274,9 @@ void CYSFControl::writeJSONRF(const char* action, float duration, float ber, int void CYSFControl::writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, const unsigned char* reflector) { - assert(action != NULL); - assert(source != NULL); - assert(reflector != NULL); + assert(action != nullptr); + assert(source != nullptr); + assert(reflector != nullptr); nlohmann::json json; @@ -1289,7 +1289,7 @@ void CYSFControl::writeJSONNet(const char* action, const unsigned char* source, void CYSFControl::writeJSONNet(const char* action, float duration, unsigned int loss) { - assert(action != NULL); + assert(action != nullptr); nlohmann::json json; @@ -1303,7 +1303,7 @@ void CYSFControl::writeJSONNet(const char* action, float duration, unsigned int void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["action"] = action; @@ -1311,8 +1311,8 @@ void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action) void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid) { - assert(action != NULL); - assert(source != NULL); + assert(action != nullptr); + assert(source != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1325,7 +1325,7 @@ void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const un void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action) { - assert(action != NULL); + assert(action != nullptr); json["timestamp"] = CUtils::createTimestamp(); json["action"] = action; @@ -1333,8 +1333,8 @@ void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action) void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid) { - assert(action != NULL); - assert(source != NULL); + assert(action != nullptr); + assert(source != nullptr); json["timestamp"] = CUtils::createTimestamp(); @@ -1347,7 +1347,7 @@ void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action, const u std::string CYSFControl::convertBuffer(const unsigned char* buffer) const { - assert(buffer != NULL); + assert(buffer != nullptr); std::string callsign((char*)buffer, 10U);