mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-05 17:40:51 +00:00
* UDP for RAK4631 Eth Gw and the t-eth-elite. Also enable IP output on Portduino. Solves #7149 * Copilot suggestion Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix portduino build * initialize local port --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
@@ -4,8 +4,13 @@
|
||||
#include "main.h"
|
||||
#include "mesh/Router.h"
|
||||
|
||||
#include <AsyncUDP.h>
|
||||
#if HAS_ETHERNET && defined(ARCH_NRF52)
|
||||
#include "mesh/eth/ethClient.h"
|
||||
#else
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <AsyncUDP.h>
|
||||
|
||||
#if HAS_ETHERNET && defined(USE_WS5500)
|
||||
#include <ETHClass2.h>
|
||||
@@ -22,11 +27,11 @@ class UdpMulticastHandler final
|
||||
void start()
|
||||
{
|
||||
if (udp.listenMulticast(udpIpAddress, UDP_MULTICAST_DEFAUL_PORT, 64)) {
|
||||
#ifndef ARCH_PORTDUINO
|
||||
// FIXME(PORTDUINO): arduino lacks IPAddress::toString()
|
||||
LOG_DEBUG("UDP Listening on IP: %s", WiFi.localIP().toString().c_str());
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO)
|
||||
LOG_DEBUG("UDP Listening on IP: %u.%u.%u.%u:%u", udpIpAddress[0], udpIpAddress[1], udpIpAddress[2], udpIpAddress[3],
|
||||
UDP_MULTICAST_DEFAUL_PORT);
|
||||
#else
|
||||
LOG_DEBUG("UDP Listening");
|
||||
LOG_DEBUG("UDP Listening on IP: %s", WiFi.localIP().toString().c_str());
|
||||
#endif
|
||||
udp.onPacket([this](AsyncUDPPacket packet) { onReceive(packet); });
|
||||
} else {
|
||||
@@ -37,7 +42,10 @@ class UdpMulticastHandler final
|
||||
void onReceive(AsyncUDPPacket packet)
|
||||
{
|
||||
size_t packetLength = packet.length();
|
||||
#ifndef ARCH_PORTDUINO
|
||||
#if defined(ARCH_NRF52)
|
||||
IPAddress ip = packet.remoteIP();
|
||||
LOG_DEBUG("UDP broadcast from: %u.%u.%u.%u, len=%u", ip[0], ip[1], ip[2], ip[3], packetLength);
|
||||
#elif !defined(ARCH_PORTDUINO)
|
||||
// FIXME(PORTDUINO): arduino lacks IPAddress::toString()
|
||||
LOG_DEBUG("UDP broadcast from: %s, len=%u", packet.remoteIP().toString().c_str(), packetLength);
|
||||
#endif
|
||||
@@ -61,7 +69,11 @@ class UdpMulticastHandler final
|
||||
if (!mp || !udp) {
|
||||
return false;
|
||||
}
|
||||
#ifndef ARCH_PORTDUINO
|
||||
#if defined(ARCH_NRF52)
|
||||
if (!isEthernetAvailable()) {
|
||||
return false;
|
||||
}
|
||||
#elif !defined(ARCH_PORTDUINO)
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user