From 092a2b7bb5cc61509cf89521c4faff695d016323 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <nicolo.caruso@skywarder.eu>
Date: Thu, 27 Mar 2025 11:01:32 +0100
Subject: [PATCH] [ARP] Sniffing reception window fix, sniffing if ARP board

- Fixed window for receiving messages, was not correct
- Entrypoint enable sniffer only if is ARP configuration
---
 src/Groundstation/Automated/Hub.cpp        | 2 +-
 src/Groundstation/LyraGS/lyra-gs-entry.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Groundstation/Automated/Hub.cpp b/src/Groundstation/Automated/Hub.cpp
index f77e4bcaf..51565c928 100644
--- a/src/Groundstation/Automated/Hub.cpp
+++ b/src/Groundstation/Automated/Hub.cpp
@@ -280,7 +280,7 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg)
         /* Messages older and within the discard interval are treated as old
          * messages*/
         if (timestamp <= lastFlightTMTimestamp &&
-            lastFlightTMTimestamp > timestamp + DISCARD_MSG_DELAY)
+            timestamp > lastFlightTMTimestamp - DISCARD_MSG_DELAY)
             return;
         TRACE(
             "[info][Radio/Sniffing] Hub: A FLIGHT_ROCKET_TM packet is valid "
diff --git a/src/Groundstation/LyraGS/lyra-gs-entry.cpp b/src/Groundstation/LyraGS/lyra-gs-entry.cpp
index 29a0fdef2..5cec13c85 100644
--- a/src/Groundstation/LyraGS/lyra-gs-entry.cpp
+++ b/src/Groundstation/LyraGS/lyra-gs-entry.cpp
@@ -142,8 +142,8 @@ int main()
     LyraGS::RadioMain* radio_main =
         new LyraGS::RadioMain(dipRead.mainHasBackup, dipRead.mainTXenable);
     LyraGS::BoardStatus* board_status = new LyraGS::BoardStatus(dipRead.isARP);
-    LyraGS::EthernetGS* ethernet =
-        new LyraGS::EthernetGS(false, dipRead.ipConfig, ethernetSniffing);
+    LyraGS::EthernetGS* ethernet      = new LyraGS::EthernetGS(
+        false, dipRead.ipConfig, dipRead.isARP & ethernetSniffing);
     EthernetSniffer* ethernetSniffer    = new EthernetSniffer();
     LyraGS::RadioPayload* radio_payload = new LyraGS::RadioPayload(
         dipRead.payloadHasBackup, dipRead.payloadTXenable);
-- 
GitLab