From f978a9151952d61de3b4d378c8ef6e8b7014a6e8 Mon Sep 17 00:00:00 2001 From: Luca Marchesano Date: Fri, 14 Sep 2018 12:30:48 +0200 Subject: [PATCH] Add select ack message dstar AckMessage = 0 set BER status AckMessage = 1 set RSSI status --- Conf.cpp | 10 +++++++++- Conf.h | 4 +++- DStarControl.cpp | 35 ++++++++++++++++++++++++++--------- DStarControl.h | 3 ++- MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 9f307e0..13282c5 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -123,6 +123,7 @@ m_dstarSelfOnly(false), m_dstarBlackList(), m_dstarAckReply(true), m_dstarAckTime(750U), +m_dstarAckMessage(false), m_dstarErrorReply(true), m_dstarRemoteGateway(false), m_dstarModeHang(10U), @@ -495,10 +496,12 @@ bool CConf::read() } p = ::strtok(NULL, ",\r\n"); } - } else if (::strcmp(key, "AckReply") == 0) + }else if (::strcmp(key, "AckReply") == 0) m_dstarAckReply = ::atoi(value) == 1; else if (::strcmp(key, "AckTime") == 0) m_dstarAckTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "AckMessage") == 0) + m_dstarAckMessage = ::atoi(value) == 1; else if (::strcmp(key, "ErrorReply") == 0) m_dstarErrorReply = ::atoi(value) == 1; else if (::strcmp(key, "RemoteGateway") == 0) @@ -1105,6 +1108,11 @@ unsigned int CConf::getDStarAckTime() const return m_dstarAckTime; } +bool CConf::getDStarAckMessage() const +{ + return m_dstarAckMessage; +} + bool CConf::getDStarErrorReply() const { return m_dstarErrorReply; diff --git a/Conf.h b/Conf.h index 2cc9cb9..8bc0e67 100644 --- a/Conf.h +++ b/Conf.h @@ -112,6 +112,7 @@ public: std::vector getDStarBlackList() const; bool getDStarAckReply() const; unsigned int getDStarAckTime() const; + bool getDStarAckMessage() const; bool getDStarErrorReply() const; bool getDStarRemoteGateway() const; unsigned int getDStarModeHang() const; @@ -333,8 +334,9 @@ private: std::string m_dstarModule; bool m_dstarSelfOnly; std::vector m_dstarBlackList; - bool m_dstarAckReply; + bool m_dstarAckReply; unsigned int m_dstarAckTime; + bool m_dstarAckMessage; bool m_dstarErrorReply; bool m_dstarRemoteGateway; unsigned int m_dstarModeHang; diff --git a/DStarControl.cpp b/DStarControl.cpp index 6780fb2..cddc9d6 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -36,11 +36,12 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my) // #define DUMP_DSTAR -CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : +CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : m_callsign(NULL), m_gateway(NULL), m_selfOnly(selfOnly), m_ackReply(ackReply), +m_ackMessage(ackMessage), m_errorReply(errorReply), m_remoteGateway(remoteGateway), m_blackList(blackList), @@ -1049,10 +1050,18 @@ void CDStarControl::sendAck() m_network->getStatus(status, reflector); char text[40U]; - if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) - ::sprintf(text, "%-8.8s BER: %.1f%% ", reflector, float(m_rfErrs * 100U) / float(m_rfBits)); - else - ::sprintf(text, "BER: %.1f%% ", float(m_rfErrs * 100U) / float(m_rfBits)); + if (m_ackMessage && m_rssi != 0) { + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + ::sprintf(text, "%-8.8s -%udBm ", reflector, m_aveRSSI / m_rssiCount); + else + ::sprintf(text, "BER:%.1f%% -%udBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); + } + else { + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + ::sprintf(text, "%-8.8s BER: %.1f%% ", reflector, float(m_rfErrs * 100U) / float(m_rfBits)); + else + ::sprintf(text, "BER: %.1f%% ", float(m_rfErrs * 100U) / float(m_rfBits)); + } m_slowData.setText(text); ::memcpy(data, DSTAR_NULL_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U); @@ -1091,10 +1100,18 @@ void CDStarControl::sendError() m_network->getStatus(status, reflector); char text[40U]; - if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) - ::sprintf(text, "%-8.8s BER: %.1f%% ", reflector, float(m_rfErrs * 100U) / float(m_rfBits)); - else - ::sprintf(text, "BER: %.1f%% ", float(m_rfErrs * 100U) / float(m_rfBits)); + if (m_ackMessage && m_rssi != 0) { + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + ::sprintf(text, "%-8.8s -%udBm ", reflector, m_aveRSSI / m_rssiCount); + else + ::sprintf(text, "BER:%.1f%% -%udBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); + } + else { + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + ::sprintf(text, "%-8.8s BER: %.1f%% ", reflector, float(m_rfErrs * 100U) / float(m_rfBits)); + else + ::sprintf(text, "BER: %.1f%% ", float(m_rfErrs * 100U) / float(m_rfBits)); + } m_slowData.setText(text); ::memcpy(data, DSTAR_NULL_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U); diff --git a/DStarControl.h b/DStarControl.h index b47f438..f3efef1 100644 --- a/DStarControl.h +++ b/DStarControl.h @@ -37,7 +37,7 @@ class CDStarControl { public: - CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, 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, bool ackMessage, bool errorReply, const std::vector& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper); ~CDStarControl(); bool writeModem(unsigned char* data, unsigned int len); @@ -52,6 +52,7 @@ private: bool m_selfOnly; bool m_ackReply; bool m_errorReply; + bool m_ackMessage; bool m_remoteGateway; std::vector m_blackList; CDStarNetwork* m_network; diff --git a/MMDVM.ini b/MMDVM.ini index 661e86b..7e94c0e 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -87,6 +87,7 @@ Module=C SelfOnly=0 AckReply=1 AckTime=750 +AckMessage=0 ErrorReply=1 RemoteGateway=0 # ModeHang=10 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index c8fb14d..52e8025 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -390,6 +390,7 @@ int CMMDVMHost::run() std::vector blackList = m_conf.getDStarBlackList(); bool ackReply = m_conf.getDStarAckReply(); unsigned int ackTime = m_conf.getDStarAckTime(); + bool ackMessage = m_conf.getDStarAckMessage(); bool errorReply = m_conf.getDStarErrorReply(); bool remoteGateway = m_conf.getDStarRemoteGateway(); m_dstarRFModeHang = m_conf.getDStarModeHang(); @@ -398,6 +399,7 @@ int CMMDVMHost::run() LogInfo(" Module: %s", module.c_str()); LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); LogInfo(" Ack Reply: %s", ackReply ? "yes" : "no"); + LogInfo(" Ack message: %s", ackMessage ? "RSSI" : "BER"); LogInfo(" Ack Time: %ums", ackTime); LogInfo(" Error Reply: %s", errorReply ? "yes" : "no"); LogInfo(" Remote Gateway: %s", remoteGateway ? "yes" : "no"); @@ -406,7 +408,7 @@ int CMMDVMHost::run() if (blackList.size() > 0U) LogInfo(" Black List: %u", blackList.size()); - dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi); + dstar = new CDStarControl(m_callsign, module, selfOnly, ackReply, ackTime, ackMessage, errorReply, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex, remoteGateway, rssi); } CTimer dmrBeaconIntervalTimer(1000U);