From 8871534ce1732fad0e17b4054024dc5fb1dde45d Mon Sep 17 00:00:00 2001
From: Alberto Nidasio <alberto.nidasio@skywarder.eu>
Date: Sat, 9 Jul 2022 06:46:20 +0000
Subject: [PATCH] [Mavlink] Added isStarted method to the driver

---
 libs/mavlink-skyward-lib                      |  2 +-
 src/shared/events/EventBroker.cpp             |  1 +
 .../radio/MavlinkDriver/MavlinkDriver.h       | 19 ++++++++++++++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/libs/mavlink-skyward-lib b/libs/mavlink-skyward-lib
index aa28ae345..2105872f9 160000
--- a/libs/mavlink-skyward-lib
+++ b/libs/mavlink-skyward-lib
@@ -1 +1 @@
-Subproject commit aa28ae345943b3686d72a0675fa374771e4a00b1
+Subproject commit 2105872f965e63932abf304854604369a523f587
diff --git a/src/shared/events/EventBroker.cpp b/src/shared/events/EventBroker.cpp
index b748fc1e9..b7029ee58 100644
--- a/src/shared/events/EventBroker.cpp
+++ b/src/shared/events/EventBroker.cpp
@@ -29,6 +29,7 @@ namespace Boardcore
 {
 
 EventBroker::EventBroker() {}
+
 void EventBroker::post(const Event& ev, uint8_t topic)
 {
 #ifdef TRACE_EVENTS
diff --git a/src/shared/radio/MavlinkDriver/MavlinkDriver.h b/src/shared/radio/MavlinkDriver/MavlinkDriver.h
index ba01382eb..aec5c22dd 100644
--- a/src/shared/radio/MavlinkDriver/MavlinkDriver.h
+++ b/src/shared/radio/MavlinkDriver/MavlinkDriver.h
@@ -65,7 +65,7 @@ template <unsigned int PktLength, unsigned int OutQueueSize,
           unsigned int MavMsgLength = MAVLINK_MAX_PAYLOAD_LEN>
 class MavlinkDriver
 {
-    ///< Alias of the function to be executed on message reception.
+    /// Alias of the function to be executed on message reception.
     using MavHandler = std::function<void(MavlinkDriver* channel,
                                           const mavlink_message_t& msg)>;
 
@@ -88,6 +88,11 @@ public:
      */
     bool start();
 
+    /**
+     * @brief Tells whether the driver was started.
+     */
+    bool isStarted();
+
     /**
      * @brief Stops sender and receiver threads.
      */
@@ -141,7 +146,8 @@ public:
 
 private:
     /**
-     * @brief Calls the run member function
+     * @brief Calls the run member function.
+     *
      * @param arg the object pointer cast to void*
      */
     static void rcvLauncher(void* arg)
@@ -238,7 +244,14 @@ bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::start()
     if (sndStarted && rcvStarted)
         LOG_DEBUG(logger, "Sender and receiver started");
 
-    return (sndStarted && rcvStarted);
+    return sndStarted && rcvStarted;
+}
+
+template <unsigned int PktLength, unsigned int OutQueueSize,
+          unsigned int MavMsgLength>
+bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::start()
+{
+    return sndStarted && rcvStarted;
 }
 
 template <unsigned int PktLength, unsigned int OutQueueSize,
-- 
GitLab