From 20e1491002158830c76894f849a3d40c6e2a2105 Mon Sep 17 00:00:00 2001
From: Lorenz Meier <lm@inf.ethz.ch>
Date: Sun, 20 Jul 2014 21:43:17 +0200
Subject: [PATCH] Decode radio status and emit signal. Not used anywhere yet

---
 src/comm/MAVLinkProtocol.cc | 10 ++++++++++
 src/comm/MAVLinkProtocol.h  | 13 +++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc
index 35b7218a09..ae16ed10ac 100644
--- a/src/comm/MAVLinkProtocol.cc
+++ b/src/comm/MAVLinkProtocol.cc
@@ -308,6 +308,16 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
                 }
             }
 
+            if(message.msgid == MAVLINK_MSG_ID_RADIO_STATUS)
+            {
+                // process telemetry status message
+                mavlink_radio_status_t rstatus;
+                mavlink_msg_radio_status_decode(&message, &rstatus);
+
+                emit radioStatusChanged(link, rstatus.rxerrors, rstatus.fixed, rstatus.rssi, rstatus.remrssi,
+                    rstatus.txbuf, rstatus.noise, rstatus.remnoise);
+            }
+
 #if defined(QGC_PROTOBUF_ENABLED)
 
             if (message.msgid == MAVLINK_MSG_ID_EXTENDED_MESSAGE)
diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h
index 158890dbab..16dea03bdc 100644
--- a/src/comm/MAVLinkProtocol.h
+++ b/src/comm/MAVLinkProtocol.h
@@ -276,6 +276,19 @@ signals:
     void actionGuardChanged(bool enabled);
     /** @brief Emitted if actiion request timeout changed */
     void actionRetransmissionTimeoutChanged(int ms);
+    /**
+     * @brief Emitted if a new radio status packet received
+     *
+     * @param rxerrors receive errors
+     * @param fixed count of error corrected packets
+     * @param rssi local signal strength
+     * @param remrssi remote signal strength
+     * @param txbuf how full the tx buffer is as a percentage
+     * @param noise background noise level
+     * @param remnoise remote background noise level
+     */
+    void radioStatusChanged(LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi,
+    unsigned txbuf, unsigned noise, unsigned remnoise);
 };
 
 #endif // MAVLINKPROTOCOL_H_
-- 
GitLab