diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index 06ea06b..0849734 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 500U; const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; -CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi) : +CDMRIPSC::CDMRIPSC(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType) : m_address(), m_port(port), m_id(NULL), @@ -44,6 +44,7 @@ m_enabled(false), m_slot1(slot1), m_slot2(slot2), m_rssi(rssi), +m_hwType(hwType), m_status(WAITING_CONNECT), m_retryTimer(1000U, 10U), m_timeoutTimer(1000U, 60U), @@ -461,8 +462,19 @@ bool CDMRIPSC::writeConfig() else if (!m_slot1 && m_slot2) slots = '2'; } else { - software = "MMDVM_DVMega"; slots = '4'; + + switch (m_hwType) { + case HWT_MMDVM: + software = "MMDVM_DMO"; + break; + case HWT_DVMEGA: + software = "MMDVM_DVMega"; + break; + default: + software = "MMDVM_Unknown"; + break; + } } char buffer[400U]; diff --git a/DMRIPSC.h b/DMRIPSC.h index af93a94..5e630a8 100644 --- a/DMRIPSC.h +++ b/DMRIPSC.h @@ -23,6 +23,7 @@ #include "Timer.h" #include "RingBuffer.h" #include "DMRData.h" +#include "Defines.h" #include #include @@ -30,7 +31,7 @@ class CDMRIPSC { public: - CDMRIPSC(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi); + CDMRIPSC(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType); ~CDMRIPSC(); void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url); @@ -62,6 +63,7 @@ private: bool m_slot1; bool m_slot2; bool m_rssi; + HW_TYPE m_hwType; enum STATUS { WAITING_CONNECT, diff --git a/Defines.h b/Defines.h index c3c8941..c4a1419 100644 --- a/Defines.h +++ b/Defines.h @@ -31,6 +31,12 @@ const unsigned char TAG_DATA = 0x01U; const unsigned char TAG_LOST = 0x02U; const unsigned char TAG_EOT = 0x03U; +enum HW_TYPE { + HWT_MMDVM, + HWT_DVMEGA, + HWT_UNKNOWN +}; + enum RPT_RF_STATE { RS_RF_LISTENING, RS_RF_LATE_ENTRY, diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 5809338..7a3d335 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -759,6 +759,7 @@ bool CMMDVMHost::createDMRNetwork() bool slot1 = m_conf.getDMRNetworkSlot1(); bool slot2 = m_conf.getDMRNetworkSlot2(); bool rssi = m_conf.getDMRNetworkRSSI(); + HW_TYPE hwType = m_modem->getHWType(); LogInfo("DMR Network Parameters"); LogInfo(" Address: %s", address.c_str()); @@ -771,7 +772,7 @@ bool CMMDVMHost::createDMRNetwork() LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); LogInfo(" RSSI: %s", rssi ? "enabled" : "disabled"); - m_dmrNetwork = new CDMRIPSC(address, port, local, id, password, m_duplex, VERSION, debug, slot1, slot2, rssi); + m_dmrNetwork = new CDMRIPSC(address, port, local, id, password, m_duplex, VERSION, debug, slot1, slot2, rssi, hwType); unsigned int rxFrequency = m_conf.getRxFrequency(); unsigned int txFrequency = m_conf.getTxFrequency(); diff --git a/Modem.cpp b/Modem.cpp index 3c155a0..73e85c3 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -19,7 +19,6 @@ #include "DStarDefines.h" #include "DMRDefines.h" #include "YSFDefines.h" -#include "Defines.h" #include "Thread.h" #include "Modem.h" #include "Utils.h" @@ -117,7 +116,8 @@ m_dmrSpace2(0U), m_ysfSpace(0U), m_tx(false), m_lockout(false), -m_error(false) +m_error(false), +m_hwType(HWT_UNKNOWN) { assert(!port.empty()); @@ -741,6 +741,11 @@ bool CModem::readVersion() CThread::sleep(10U); RESP_TYPE_MMDVM resp = getResponse(); if (resp == RTM_OK && m_buffer[2U] == MMDVM_GET_VERSION) { + if (::memcmp(m_buffer + 4U, "MMDVM", 5U) == 0) + m_hwType = HWT_MMDVM; + else if (::memcmp(m_buffer + 4U, "DVMEGA", 6U) == 0) + m_hwType = HWT_DVMEGA; + LogInfo("MMDVM protocol version: %u, description: %.*s", m_buffer[3U], m_length - 4U, m_buffer + 4U); return true; } @@ -1016,6 +1021,11 @@ RESP_TYPE_MMDVM CModem::getResponse() } } +HW_TYPE CModem::getHWType() const +{ + return m_hwType; +} + bool CModem::setMode(unsigned char mode) { unsigned char buffer[4U]; diff --git a/Modem.h b/Modem.h index 1438b01..3348c9a 100644 --- a/Modem.h +++ b/Modem.h @@ -21,6 +21,7 @@ #include "SerialController.h" #include "RingBuffer.h" +#include "Defines.h" #include "Timer.h" #include @@ -71,6 +72,8 @@ public: bool sendCWId(const std::string& callsign); + HW_TYPE getHWType() const; + void clock(unsigned int ms); void close(); @@ -117,6 +120,7 @@ private: bool m_tx; bool m_lockout; bool m_error; + HW_TYPE m_hwType; bool readVersion(); bool readStatus();