Add RSSI display for all modes.

This commit is contained in:
Jonathan Naylor
2017-01-05 19:15:10 +00:00
parent 8debea45e4
commit af721f89e2
18 changed files with 381 additions and 129 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
// #define DUMP_YSF
CYSFControl::CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway) :
CYSFControl::CYSFControl(const std::string& callsign, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL),
m_network(network),
m_display(display),
@@ -56,9 +56,16 @@ m_lastMR(YSF_MR_NOT_BUSY),
m_netN(0U),
m_rfPayload(),
m_netPayload(),
m_rssiMapper(rssiMapper),
m_rssi(0U),
m_maxRSSI(0U),
m_minRSSI(0U),
m_aveRSSI(0U),
m_rssiCount(0U),
m_fp(NULL)
{
assert(display != NULL);
assert(rssiMapper != NULL);
m_rfPayload.setUplink(callsign);
m_rfPayload.setDownlink(callsign);
@@ -94,7 +101,7 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
unsigned char type = data[0U];
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
LogMessage("YSF, transmission lost, %.1f seconds, BER: %.1f%%", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
LogMessage("YSF, transmission lost, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeEndRF();
return false;
}
@@ -102,6 +109,28 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
if (type == TAG_LOST)
return false;
// Have we got RSSI bytes on the end?
if (len == (YSF_FRAME_LENGTH_BYTES + 4U)) {
uint16_t raw = 0U;
raw |= (data[122U] << 8) & 0xFF00U;
raw |= (data[123U] << 0) & 0x00FFU;
// Convert the raw RSSI to dBm
int rssi = m_rssiMapper->interpolate(raw);
LogDebug("YSF, raw RSSI: %u, reported RSSI: %d dBm", raw, rssi);
// RSSI is always reported as positive
m_rssi = (rssi >= 0) ? rssi : -rssi;
if (m_rssi > m_minRSSI)
m_minRSSI = m_rssi;
if (m_rssi < m_maxRSSI)
m_maxRSSI = m_rssi;
m_aveRSSI += m_rssi;
m_rssiCount++;
}
CYSFFICH fich;
bool valid = fich.decode(data + 2U);
@@ -116,6 +145,11 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
m_rfTimeoutTimer.start();
m_rfPayload.reset();
m_rfState = RS_RF_AUDIO;
m_minRSSI = m_rssi;
m_maxRSSI = m_rssi;
m_aveRSSI = m_rssi;
m_rssiCount = 1U;
#if defined(DUMP_YSF)
openFile();
#endif
@@ -209,7 +243,7 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
m_rfFrames++;
LogMessage("YSF, received RF end of transmission, %.1f seconds, BER: %.1f%%", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
LogMessage("YSF, received RF end of transmission, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeEndRF();
return false;