From 37f0045fbb706dedeb6eb538ad96af149984d41b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <niccolo.caruso@skywarder.eu>
Date: Fri, 24 Jan 2025 14:53:26 +0100
Subject: [PATCH] [ARP] Fix on SMA for feedback states check

Using only feedback macrostate made not enter in the feedback data reception part
---
 cmake/dependencies.cmake                | 1 +
 src/Groundstation/Automated/Hub.h       | 6 +++---
 src/Groundstation/Automated/SMA/SMA.cpp | 7 ++++++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index 27364e888..6a45efb67 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -45,6 +45,7 @@ set(MAIN_COMPUTER
 set(GROUNDSTATION_COMMON
     src/Groundstation/Common/Radio/RadioBase.cpp
     src/Groundstation/Common/Ports/EthernetBase.cpp
+    src/Groundstation/Common/Ports/EthernetSniffer.cpp
     src/Groundstation/Common/Ports/Serial.cpp
     src/Groundstation/Common/HubBase.cpp
 )
diff --git a/src/Groundstation/Automated/Hub.h b/src/Groundstation/Automated/Hub.h
index 0828b3d22..0c537945b 100644
--- a/src/Groundstation/Automated/Hub.h
+++ b/src/Groundstation/Automated/Hub.h
@@ -108,9 +108,9 @@ private:
     bool rocketNasSet = false;
     miosix::FastMutex coordinatesMutex;
     miosix::FastMutex nasStateMutex;
-    bool hasNewNasSet = false;
-    uint64_t lastFlightTMTimestamp;
-    uint64_t lastStatsTMTimestamp;
+    bool hasNewNasSet              = false;
+    uint64_t lastFlightTMTimestamp = 0;
+    uint64_t lastStatsTMTimestamp  = 0;
 };
 
 }  // namespace Antennas
diff --git a/src/Groundstation/Automated/SMA/SMA.cpp b/src/Groundstation/Automated/SMA/SMA.cpp
index 3470e27db..9fa53f0d1 100644
--- a/src/Groundstation/Automated/SMA/SMA.cpp
+++ b/src/Groundstation/Automated/SMA/SMA.cpp
@@ -145,8 +145,13 @@ void SMA::update()
     Hub* hub      = static_cast<Hub*>(getModule<Groundstation::HubBase>());
     auto* sensors = getModule<Sensors>();
 
+    // TODO: Verify if same with the macrostate
     // Update the antenna position if in feedback
-    if (status.state == SMAState::FEEDBACK)
+    // if (testState(&SMA::state_feedback))
+    if (testState(&SMA::state_init_done) || testState(&SMA::state_armed) ||
+        testState(&SMA::state_fix_antennas) ||
+        testState(&SMA::state_fix_rocket) || testState(&SMA::state_active) ||
+        testState(&SMA::state_test))
     {
         // update antenna coordinates
         data = sensors->getVN300LastSample();
-- 
GitLab