improve rssi handling on link loss for spektrum srxl

This commit is contained in:
warhog 2019-02-05 09:34:22 +01:00
parent af84f9e99d
commit 33c5e465a6
2 changed files with 25 additions and 8 deletions

View File

@ -107,21 +107,35 @@ static int8_t dBm2range (int8_t dBm) {
void spektrumHandleRSSI(volatile uint8_t spekFrame[]) {
#ifdef USE_SPEKTRUM_REAL_RSSI
static int8_t spek_last_rssi = SPEKTRUM_RSSI_MAX;
static uint8_t spek_fade_count = 0;
// Fetch RSSI
if (srxlEnabled) {
// Real RSSI reported omly by SRXL Telemetry Rx, in dBm.
// Real RSSI reported only by SRXL Telemetry Rx, in dBm.
int8_t rssi = spekFrame[0];
if (rssi <= SPEKTRUM_RSSI_FADE_LIMIT ) {
// If Rx reports -100 dBm or less, it is a fade out and frame loss.
// If it is a temporary fade, real RSSI will come back in the next frame, in that case.
// we should not report 0% back as OSD keeps a "minimum RSSI" value. Instead keep last good report
// If it is a total link loss, failsafe will kick in.
// We could count the fades here, but currentlly to no use
// If Rx reports -100 dBm or less, it is a fade out and frame
// loss.
// If it is a temporary fade, real RSSI will come back in the
// next frame, in that case
// we should not report 0% back as OSD keeps a "minimum RSSI"
// value. Instead keep last good report.
// If it is a total link loss, failsafe will kick in.
// The number of fades are counted and if it is equal or above
// SPEKTRUM_RSSI_LINK_LOSS_FADES a link loss is assumed and
// RSSI is set to Spektrums minimum RSSI value.
// Ignore report and Keep last known good value
rssi = spek_last_rssi;
spek_fade_count++;
if (spek_fade_count < SPEKTRUM_RSSI_LINK_LOSS_FADES) {
// Ignore report and keep last known good value
rssi = spek_last_rssi;
} else {
// Link loss assumed, set RSSI to minimum value
rssi = SPEKTRUM_RSSI_MIN;
}
} else {
spek_fade_count = 0;
}
if(rssi_channel != 0) {

View File

@ -28,6 +28,9 @@
#define SPEKTRUM_MAX_FADE_PER_SEC 40
#define SPEKTRUM_FADE_REPORTS_PER_SEC 2
// Number of fade outs counted as a link loss
#define SPEKTRUM_RSSI_LINK_LOSS_FADES 5
typedef struct dbm_table_s
{
int8_t dBm;