17#include "lwip/ip_addr.h"
18#include "lwip/netif.h"
20#if DETWS_ENABLE_ETHERNET
26 WiFi.begin(ssid, password);
32 return WiFi.isConnected();
35#if DETWS_ENABLE_ETHERNET
38#if defined(DETWS_ETH_W5500) && DETWS_ETH_W5500 && ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
52 return ETH.linkUp() && (uint32_t)ETH.localIP() != 0;
66#include "lwip/ip6_addr.h"
73#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
74 return WiFi.enableIPv6(
true);
76 return WiFi.enableIpV6();
82 if (!out || !netif_default)
84 for (int8_t i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
86 if (!ip6_addr_isvalid(netif_ip6_addr_state(netif_default, i)))
88 const ip6_addr_t *a6 = netif_ip6_addr(netif_default, i);
89 if (!ip6_addr_isglobal(a6))
92 memcpy(out->
bytes, a6->addr, 16);
121 return netif_default ? ip4_addr_get_u32(ip_2_ip4(&netif_default->ip_addr)) : 0;
129 uint32_t sta = WiFi.isConnected() ? (uint32_t)WiFi.localIP() : 0;
130 uint32_t ap = (WiFi.getMode() & WIFI_AP) ? (uint32_t)WiFi.softAPIP() : 0;
180 if (sta_ip != 0 && egress_ip == sta_ip)
182 if (ap_ip != 0 && egress_ip == ap_ip)
DetIface
Network interface a connection arrived on (for per-route filtering).
@ DETIFACE_ETH
Ethernet interface (wired PHY).
@ DETIFACE_STA
Station interface (joined to an AP / your LAN).
@ DETIFACE_ANY
Unknown / no filter (matches any interface).
@ DETIFACE_AP
softAP interface (clients joined to the device).
#define DETWS_ETH_W5500_MOSI
HSPI MOSI (S3-DevKitC default)
#define DETWS_ETH_W5500_RST
reset
#define DETWS_ETH_W5500_CS
chip select
#define DETWS_ETH_W5500_SCK
HSPI clock (S3-DevKitC default)
#define DETWS_ETH_W5500_SPI_MHZ
W5500 SPI clock (MHz); raise for throughput on clean wiring.
#define DETWS_ETH_W5500_INT
interrupt
#define DETWS_ETH_W5500_MISO
HSPI MISO (S3-DevKitC default)
@ DET_IP_V6
IPv6 (bytes[0..15])
uint32_t det_net_egress_ip(void)
IPv4 (network byte order) of the current egress interface, or 0 if none.
bool ipv6_ready(void)
True once the interface has a global IPv6 address (see net_global_ipv6()).
bool eth_ready(void)
True if the Ethernet link is up and an IP is assigned.
bool wifi_ready()
True if the WiFi station link is up (associated + an IP is assigned).
bool init_wifi_physical(const char *ssid, const char *password)
Connect to a WiFi access point.
DetIface det_net_egress(void)
Which interface currently carries outbound traffic.
bool init_ipv6_physical(void)
Enable IPv6 (dual-stack) on the Wi-Fi interface (DETWS_ENABLE_IPV6).
bool init_eth_physical(void)
Bring up a wired Ethernet link (DETWS_ENABLE_ETHERNET).
DetIface det_net_classify_ip(uint32_t egress_ip, uint32_t sta_ip, uint32_t ap_ip)
Classify an egress IPv4 against the WiFi station / softAP IPs (pure helper, exposed for unit testing)...
bool net_global_ipv6(DetIp *)
The interface's global (routable) IPv6 address, if it has one.
Layer 1 (Physical) - link bring-up and live egress-interface reporting.
A v4 or v6 address in network (big-endian) byte order.
uint8_t bytes[16]
network order; v4 uses the first 4
DetIpFamily family
address family tag