1#ifndef ESP8266NDN_TRANSPORT_UDP_TRANSPORT_HPP
2#define ESP8266NDN_TRANSPORT_UDP_TRANSPORT_HPP
4#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_RP2040)
6#include "../port/port.hpp"
8#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_RP2040)
10#define ESP8266NDN_NetworkUDP WiFiUDP
11#elif defined(ARDUINO_ARCH_ESP32)
12#include <NetworkUdp.h>
13#define ESP8266NDN_NetworkUDP NetworkUDP
39 template<
size_t capacity>
50 bool beginListen(uint16_t localPort = 6363, IPAddress localIp = IPAddress());
58 bool beginTunnel(IPAddress remoteIp, uint16_t remotePort = 6363, uint16_t localPort = 6363);
65 bool beginMulticast(IPAddress localIp = IPAddress(), uint16_t groupPort = 56363);
75 bool doSend(const uint8_t* pkt,
size_t pktLen, uint64_t endpointId) final;
87 enum class Mode : uint8_t {
94 uint8_t* m_buf =
nullptr;
96 std::unique_ptr<uint8_t[]> m_ownBuf;
104 EndpointIdHelper m_endpoints;
107 Mode m_mode = Mode::NONE;
A transport that communicates over UDP tunnel or multicast group.
Definition udp-transport.hpp:19
bool doSend(const uint8_t *pkt, size_t pktLen, uint64_t endpointId) final
bool beginTunnel(IPAddress remoteIp, uint16_t remotePort=6363, uint16_t localPort=6363)
Establish a UDP tunnel to a remote endpoint.
UdpTransport(uint8_t *buffer, size_t capacity)
Construct using external buffer.
bool doIsUp() const final
@ DefaultMtu
Default MTU for UDP is Ethernet MTU minus IPv4 and UDP headers.
Definition udp-transport.hpp:80
bool beginListen(uint16_t localPort=6363, IPAddress localIp=IPAddress())
Listen on a UDP port for packets from any remote endpoint.
bool beginMulticast(IPAddress localIp=IPAddress(), uint16_t groupPort=56363)
Join a UDP multicast group.
UdpTransport(size_t mtu=DefaultMtu)
Construct using internal buffer.
static const IPAddress MulticastGroup
NDN multicast group "224.0.23.170".
Definition udp-transport.hpp:84
void end()
Disable the transport.
UdpTransport(std::array< uint8_t, capacity > &buffer)
Construct using external buffer.
Definition udp-transport.hpp:40
Helper to pack IPv6 endpoint into 64-bit EndpointId.
Definition ipv6-endpointid.hpp:19
Base class of low-level transport.
Definition transport.hpp:10
Definition autoconfig.hpp:24
#define ESP8266NDN_NetworkUDP
Definition udp-transport.hpp:13