diff --git a/src/Groundstation/Automated/Hub.cpp b/src/Groundstation/Automated/Hub.cpp index 523568364cb10c1b4058794a0ceb4c4bd1f7acc6..f77e4bcaf5406fa271946389038354f4fc01e5d3 100644 --- a/src/Groundstation/Automated/Hub.cpp +++ b/src/Groundstation/Automated/Hub.cpp @@ -247,7 +247,8 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg) msg.msgid == MAVLINK_MSG_ID_ROCKET_STATS_TM) { TRACE( - "[info] Hub: A MAIN packet was received from ground packet " + "[info][SNIFFING] Hub: A MAIN packet was received from ground " + "packet " "(ethernet probably and NOT radio)\n"); /* The message received by ethernet (outgoing) in reality is not a * command but the telemetry spoofed, therefore is then used as incoming @@ -272,7 +273,8 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) mavlink_msg_rocket_flight_tm_decode(&msg, &rocketTM); uint64_t timestamp = mavlink_msg_rocket_flight_tm_get_timestamp(&msg); TRACE( - "[info] Hub: A FLIGHT_ROCKET_TM packet was received from ground " + "[info][Radio/Sniffing] Hub: A FLIGHT_ROCKET_TM packet was " + "received " "packet with ts %llu\n", timestamp); /* Messages older and within the discard interval are treated as old @@ -280,8 +282,10 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) if (timestamp <= lastFlightTMTimestamp && lastFlightTMTimestamp > timestamp + DISCARD_MSG_DELAY) return; - TRACE("[info] Hub: A FLIGHT_ROCKET_TM packet is valid with ts %llu\n", - timestamp); + TRACE( + "[info][Radio/Sniffing] Hub: A FLIGHT_ROCKET_TM packet is valid " + "with ts %llu\n", + timestamp); lastFlightTMTimestamp = timestamp; NASState nasState{ mavlink_msg_rocket_flight_tm_get_timestamp(&msg), @@ -302,7 +306,7 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) mavlink_rocket_stats_tm_t rocketST; mavlink_msg_rocket_stats_tm_decode(&msg, &rocketST); TRACE( - "[info] Hub: A ROCKET_STAT_TM packet was received from ground " + "[info][Radio/Sniffing] Hub: A ROCKET_STAT_TM packet was received " "packet with ts %llu\n", rocketST.timestamp); /* Messages older and within the discard interval are treated as old @@ -310,8 +314,10 @@ void Hub::dispatchIncomingMsg(const mavlink_message_t& msg) if (rocketST.timestamp <= lastStatsTMTimestamp && lastStatsTMTimestamp > rocketST.timestamp + DISCARD_MSG_DELAY) return; - TRACE("[info] Hub: A ROCKET_STAT_TM packet is valid, with ts %llu\n", - rocketST.timestamp); + TRACE( + "[info][Radio/Sniffing] Hub: A ROCKET_STAT_TM packet is valid, " + "with ts %llu\n", + rocketST.timestamp); lastStatsTMTimestamp = rocketST.timestamp; // TODO: The origin should have its own struct since only timestamp and diff --git a/src/Groundstation/Common/Ports/EthernetBase.cpp b/src/Groundstation/Common/Ports/EthernetBase.cpp index dbae923398a5de4a357da89095135aad164cf97e..76e66d89a1a3e7ce7d47cd129a48152a8e690fc2 100644 --- a/src/Groundstation/Common/Ports/EthernetBase.cpp +++ b/src/Groundstation/Common/Ports/EthernetBase.cpp @@ -85,6 +85,17 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500) WizMac mac = MAC_BASE; // Add to the mac address the offset set on the dipswitch mac.c += 1 + ipOffset; + // In case of sniffing change ulteriorly the MAC to avoid switch to + // filter based on not whole MAC... + if (sniffOtherGs) + { + mac.a += 1; + mac.b += 1; + mac.c += 1; + mac.d += 1; + mac.e += 1; + mac.f += 1; + } this->wiz5500->setSourceMac(mac); } else @@ -115,7 +126,7 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500) if (sniffOtherGs) { getModule<EthernetSniffer>()->init(1, SEND_PORT, RECV_PORT); - if (!getModule<EthernetSniffer>()->start(wiz5500)) + if (!getModule<EthernetSniffer>()->start(this->wiz5500)) return false; } diff --git a/src/Groundstation/Common/Ports/EthernetSniffer.cpp b/src/Groundstation/Common/Ports/EthernetSniffer.cpp index 564024f893ad963d69c63ce4ec9ab24e561ae07b..e08e1c538c3f842536cf6097bde48d7572b11d7e 100644 --- a/src/Groundstation/Common/Ports/EthernetSniffer.cpp +++ b/src/Groundstation/Common/Ports/EthernetSniffer.cpp @@ -51,9 +51,9 @@ Boardcore::Wiz5500::PhyState EthernetSniffer::getState() void EthernetSniffer::init(uint16_t portNumber, uint16_t srcPort, uint16_t dstPort) { - portNr = portNumber; - srcPort = srcPort; - dstPort = dstPort; + portNr = portNumber; + this->srcPort = srcPort; + this->dstPort = dstPort; } bool EthernetSniffer::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500) @@ -62,7 +62,7 @@ bool EthernetSniffer::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500) TRACE("[info] Opening sniffing UDP socket\n"); // We open the UDP socket for sniffing - if (!this->wiz5500->openUdp(1, SEND_PORT, {255, 255, 255, 255}, RECV_PORT, + if (!this->wiz5500->openUdp(portNr, srcPort, {255, 255, 255, 255}, dstPort, 500)) { return false;