diff --git a/src/Groundstation/Common/Ports/EthernetBase.cpp b/src/Groundstation/Common/Ports/EthernetBase.cpp
index e66be196a14ad83c826790d3cb63c6112335ee83..dbae923398a5de4a357da89095135aad164cf97e 100644
--- a/src/Groundstation/Common/Ports/EthernetBase.cpp
+++ b/src/Groundstation/Common/Ports/EthernetBase.cpp
@@ -67,7 +67,7 @@ Boardcore::Wiz5500::PhyState EthernetBase::getState()
bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
{
- this->wiz5500 = std::move(wiz5500);
+ this->wiz5500 = wiz5500;
// Reset the device
this->wiz5500->reset();
@@ -103,12 +103,6 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
return false;
}
- if (!this->wiz5500->openUdp(1, SEND_PORT, {255, 255, 255, 255}, RECV_PORT,
- 500))
- {
- return false;
- }
-
auto mav_handler = [this](EthernetMavDriver* channel,
const mavlink_message_t& msg) { handleMsg(msg); };
@@ -116,17 +110,16 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
if (!mav_driver->start())
return false;
- TRACE("[info] mavlink driver started correctly\n");
- // Create and start a second mavlink driver to sniff the ethernet port
+ // In case of sniffing mode initialize and start the EthernetSniffer
if (sniffOtherGs)
{
- getModule<EthernetSniffer>()->init(1, RECV_PORT, SEND_PORT);
+ getModule<EthernetSniffer>()->init(1, SEND_PORT, RECV_PORT);
if (!getModule<EthernetSniffer>()->start(wiz5500))
return false;
}
- TRACE("[info] Ethernet sniffing started correctly\n");
+ TRACE("[info] Ethernet module started correctly\n");
return true;
}
diff --git a/src/Groundstation/Common/Ports/EthernetSniffer.cpp b/src/Groundstation/Common/Ports/EthernetSniffer.cpp
index 8b6be2b7f09a511e06630f8e675e04b4ae95da92..564024f893ad963d69c63ce4ec9ab24e561ae07b 100644
--- a/src/Groundstation/Common/Ports/EthernetSniffer.cpp
+++ b/src/Groundstation/Common/Ports/EthernetSniffer.cpp
@@ -58,31 +58,25 @@ void EthernetSniffer::init(uint16_t portNumber, uint16_t srcPort,
bool EthernetSniffer::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
{
- TRACE("Movin\n");
- this->wiz5500 = std::move(wiz5500);
+ this->wiz5500 = wiz5500;
- TRACE("Opening\n");
- // We open the port for sniffing using the port we specified
- // if (!this->wiz5500->openUdp(portNr, srcPort, {255, 255, 255, 255},
- // dstPort,
- // 500))
- // {
- // return false;
- // }
-
- TRACE("Mavlinker\n");
+ 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,
+ 500))
+ {
+ return false;
+ }
auto mav_handler = [this](EthernetMavDriver* channel,
const mavlink_message_t& msg) { handleMsg(msg); };
- mav_driver = std::make_unique<EthernetMavDriver>(this, mav_handler, 1, 10);
-
- TRACE("Starting\n");
+ mav_driver = std::make_unique<EthernetMavDriver>(this, mav_handler, 0, 10);
if (!mav_driver->start())
return false;
- TRACE("Start ok\n");
+ TRACE("[info] EthernetSniffer start ok\n");
return true;
}