diff --git a/DStarControl.cpp b/DStarControl.cpp index 6c42f36..20ee19f 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -1184,8 +1184,10 @@ void CDStarControl::sendAck() char text[40U]; if (m_ackMessage == DSTAR_ACK_RSSI && m_rssi != 0) { - if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) { + CUtils::removeChar(reflector, ' ');//remove space from reflector so all nicely fits onto 20 chars in case rssi < 99dBm ::sprintf(text, "%-8.8s %.1f%% -%udBm ", reflector, float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); + } else ::sprintf(text, "BER:%.1f%% -%udBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); } @@ -1248,8 +1250,10 @@ void CDStarControl::sendError() char text[40U]; if (m_ackMessage == DSTAR_ACK_RSSI && m_rssi != 0) { - if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) + if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) { + CUtils::removeChar(reflector, ' ');//remove space from reflector so all nicely fits onto 20 chars in case rssi < 99dBm ::sprintf(text, "%-8.8s %.1f%% -%udBm ", reflector, float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); + } else ::sprintf(text, "BER:%.1f%% -%udBm ", float(m_rfErrs * 100U) / float(m_rfBits), m_aveRSSI / m_rssiCount); } diff --git a/Utils.cpp b/Utils.cpp index 49ded13..1c0c06c 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -144,3 +144,17 @@ void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte) byte |= bits[6U] ? 0x40U : 0x00U; byte |= bits[7U] ? 0x80U : 0x00U; } + +void CUtils::removeChar(unsigned char * haystack, char needdle) +{ + unsigned int i = 0; + unsigned int j = 0; + + while (haystack[i] != '\0') { + if (haystack[i] != needdle) + haystack[j++] = haystack[i]; + i++; + } + + haystack[j] = '\0'; +} \ No newline at end of file diff --git a/Utils.h b/Utils.h index ade28c0..8f6abf3 100644 --- a/Utils.h +++ b/Utils.h @@ -30,6 +30,8 @@ public: static void bitsToByteBE(const bool* bits, unsigned char& byte); static void bitsToByteLE(const bool* bits, unsigned char& byte); + static void removeChar(unsigned char * haystack, char needdle); + private: };