|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Layer 1 (Physical) - vendor-neutral core. More...
#include "physical.h"Go to the source code of this file.
Functions | |
| pc_iface | pc_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 | init_wifi_physical (const char *, const char *) |
| Connect to a WiFi access point. | |
| bool | wifi_ready () |
| True if the WiFi station link is up (associated + an IP is assigned). | |
| bool | init_wifi_radio_physical (uint8_t) |
| Bring the WiFi radio up in station mode WITHOUT associating to an AP. | |
| bool | init_wifi_ap_physical (const char *, const char *) |
| Bring up a softAP, enabling AP+STA coexistence so a station link can run alongside it. | |
| bool | init_eth_physical (void) |
| Bring up a wired Ethernet link (PC_ENABLE_ETHERNET). | |
| bool | eth_ready (void) |
| True if the Ethernet link is up and an IP is assigned. | |
| bool | init_ipv6_physical (void) |
| Enable IPv6 (dual-stack) on the Wi-Fi interface (PC_ENABLE_IPV6). | |
| bool | net_global_ipv6 (pc_ip *) |
| The interface's global (routable) IPv6 address, if it has one. | |
| bool | pc_ipv6_ready (void) |
| True once the interface has a global IPv6 address (see net_global_ipv6()). | |
| uint32_t | pc_net_egress_ip (void) |
| IPv4 (network byte order) of the current egress interface, or 0 if none. | |
| pc_iface | pc_net_egress (void) |
| Which interface currently carries outbound traffic. | |
| uint32_t | pc_net_ap_ip (void) |
| softAP IPv4 (network byte order), or 0 if the softAP is not up (and on host builds). | |
| int8_t | pc_net_rssi (void) |
| Station link RSSI in dBm, or 0 if not associated (and on host builds). | |
| bool | pc_net_mac (uint8_t *) |
| bool | pc_net_egress_mac (uint8_t *) |
| bool | pc_phy_ps_set (pc_phy_ps) |
| Apply a power-save mode. | |
| pc_phy_ps | pc_phy_ps_get (void) |
| Read the active power-save mode (PC_PHY_PS_NONE when unsupported). | |
| bool | pc_phy_tx_power_set (int8_t) |
| Cap transmit power. | |
| bool | pc_phy_monitor_begin (uint8_t, pc_phy_frame_fn) |
Enter monitor mode on channel, delivering frames to cb. | |
| void | pc_phy_monitor_set_channel (uint8_t) |
Retune monitor mode to channel. | |
| void | pc_phy_monitor_end (void) |
| Leave monitor mode. | |
| size_t | pc_net_ssid (char *out, size_t cap) |
Copy the associated SSID (null-terminated) into out. | |
| uint8_t | pc_net_channel (void) |
| Station WiFi channel (1..14), or 0 if not associated (and on host builds). | |
Layer 1 (Physical) - vendor-neutral core.
Holds the two things that are not silicon-specific: the pure IP-egress classifier (always compiled, host-tested), and the fallback link stubs used when the selected vendor has no physical backend yet (PC_PHYSICAL_HAS_BACKEND == 0 - host/native builds, or a vendor whose PHY driver is not written). Each vendor's real bring-up lives in board_drivers/physical/<vendor>/ (board_drivers/physical/esp/physical_esp.cpp today), chosen by the PC_VENDOR_* selector. The stubs never bring a link up, so a new target builds and runs headless from day one - the L1 analogue of crypto/ falling back to its portable software field path.
Definition in file physical.cpp.
| pc_iface pc_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).
A live egress IP equal to the station or softAP IP is that WiFi interface; any other live IP is a wired (Ethernet) route; 0 is no route.
| egress_ip | Current default-route IPv4 (network order), 0 if none. |
| sta_ip | WiFi station IPv4 (network order), 0 if not connected. |
| ap_ip | softAP IPv4 (network order), 0 if the softAP is not up. |
Definition at line 20 of file physical.cpp.
References PC_IFACE_ANY, PC_IFACE_AP, PC_IFACE_ETH, and PC_IFACE_STA.
| bool init_wifi_physical | ( | const char * | ssid, |
| const char * | password | ||
| ) |
Connect to a WiFi access point.
Starts the station join and returns immediately; it does not block waiting for association. Poll wifi_ready() to check link status.
| ssid | Network SSID (null-terminated). |
| password | WPA2 passphrase (null-terminated). |
Definition at line 41 of file physical.cpp.
| bool wifi_ready | ( | ) |
True if the WiFi station link is up (associated + an IP is assigned).
Definition at line 45 of file physical.cpp.
| bool init_wifi_radio_physical | ( | uint8_t | channel | ) |
Bring the WiFi radio up in station mode WITHOUT associating to an AP.
For raw-radio use that needs the PHY running but no IP link: ESP-NOW peer messaging and promiscuous capture. Pins the radio to channel (1..14) when non-zero; pass 0 to leave the channel to a capture layer that sets its own (services/radio/promisc). Returns immediately.
Definition at line 49 of file physical.cpp.
| bool init_wifi_ap_physical | ( | const char * | ssid, |
| const char * | password | ||
| ) |
Bring up a softAP, enabling AP+STA coexistence so a station link can run alongside it.
| ssid | softAP SSID (null-terminated). |
| password | softAP passphrase (null-terminated; >= 8 chars for WPA2, "" for an open AP). |
Definition at line 53 of file physical.cpp.
| bool init_eth_physical | ( | void | ) |
Bring up a wired Ethernet link (PC_ENABLE_ETHERNET).
A thin wrapper over the Arduino ETH library (ETH.begin()); the RMII PHY pins / type / clock come from the standard ETH_PHY_* build flags for your board. Returns immediately (bring-up is asynchronous); poll eth_ready(). The egress reporting already classifies a wired route as pc_iface::PC_IFACE_ETH, so the server accepts on the link once it has an IP.
Definition at line 57 of file physical.cpp.
| bool eth_ready | ( | void | ) |
True if the Ethernet link is up and an IP is assigned.
Definition at line 61 of file physical.cpp.
| bool init_ipv6_physical | ( | void | ) |
Enable IPv6 (dual-stack) on the Wi-Fi interface (PC_ENABLE_IPV6).
Turns on IPv6 for the netif so it acquires a SLAAC link-local address and, if the network advertises a prefix, a global address. Returns immediately (address configuration is asynchronous); poll pc_ipv6_ready(). The listeners already bind IPADDR_TYPE_ANY, so the server answers over IPv6 as soon as an address is up.
Definition at line 65 of file physical.cpp.
| bool net_global_ipv6 | ( | pc_ip * | out | ) |
The interface's global (routable) IPv6 address, if it has one.
| [out] | out | receives the address (family pc_ip_family::PC_IP_V6) when true is returned. |
Definition at line 69 of file physical.cpp.
| bool pc_ipv6_ready | ( | void | ) |
True once the interface has a global IPv6 address (see net_global_ipv6()).
Definition at line 73 of file physical.cpp.
| uint32_t pc_net_egress_ip | ( | void | ) |
IPv4 (network byte order) of the current egress interface, or 0 if none.
Definition at line 77 of file physical.cpp.
| pc_iface pc_net_egress | ( | void | ) |
Which interface currently carries outbound traffic.
Reads the live lwIP default route, so it reflects the current state after any failover the stack performed - no polling, no cached state. Returns pc_iface::PC_IFACE_ETH / pc_iface::PC_IFACE_STA / pc_iface::PC_IFACE_AP, or pc_iface::PC_IFACE_ANY when no route is up (and on host builds).
Definition at line 81 of file physical.cpp.
References PC_IFACE_ANY.
| uint32_t pc_net_ap_ip | ( | void | ) |
softAP IPv4 (network byte order), or 0 if the softAP is not up (and on host builds).
Definition at line 85 of file physical.cpp.
| int8_t pc_net_rssi | ( | void | ) |
Station link RSSI in dBm, or 0 if not associated (and on host builds).
Definition at line 89 of file physical.cpp.
| bool pc_net_mac | ( | uint8_t * | ) |
Definition at line 93 of file physical.cpp.
| bool pc_net_egress_mac | ( | uint8_t * | ) |
Definition at line 97 of file physical.cpp.
| bool pc_phy_ps_set | ( | pc_phy_ps | mode | ) |
Apply a power-save mode.
Definition at line 104 of file physical.cpp.
| pc_phy_ps pc_phy_ps_get | ( | void | ) |
Read the active power-save mode (PC_PHY_PS_NONE when unsupported).
Definition at line 108 of file physical.cpp.
References PC_PHY_PS_NONE.
| bool pc_phy_tx_power_set | ( | int8_t | dbm | ) |
Cap transmit power.
| dbm | Maximum transmit power in whole dBm; the backend converts to its own unit. |
Definition at line 112 of file physical.cpp.
| bool pc_phy_monitor_begin | ( | uint8_t | channel, |
| pc_phy_frame_fn | cb | ||
| ) |
Enter monitor mode on channel, delivering frames to cb.
Definition at line 116 of file physical.cpp.
| void pc_phy_monitor_set_channel | ( | uint8_t | channel | ) |
Retune monitor mode to channel.
Definition at line 120 of file physical.cpp.
| void pc_phy_monitor_end | ( | void | ) |
Leave monitor mode.
Definition at line 123 of file physical.cpp.
| size_t pc_net_ssid | ( | char * | out, |
| size_t | cap | ||
| ) |
Copy the associated SSID (null-terminated) into out.
cap is 0, or on a host build. Definition at line 126 of file physical.cpp.
| uint8_t pc_net_channel | ( | void | ) |
Station WiFi channel (1..14), or 0 if not associated (and on host builds).
Definition at line 134 of file physical.cpp.