26#ifndef PROTOCORE_PHYSICAL_H
27#define PROTOCORE_PHYSICAL_H
39#ifndef PROTOCORE_PHYSICAL_HAS_BACKEND
40#define PROTOCORE_PHYSICAL_HAS_BACKEND 1
180 PROTOCORE_PHY_PS_NONE = 0,
181 PROTOCORE_PHY_PS_MIN_MODEM = 1,
182 PROTOCORE_PHY_PS_MAX_MODEM = 2,
219#if PROTOCORE_PHYSICAL_HAS_BACKEND && !PROTOCORE_VENDOR_ESP
228embed_bool protocore_phy_mock_deliver(
const uint8_t *frame, uint16_t len, int8_t rssi, uint8_t channel);
247#define PROTOCORE_IF_NONE (-1)
366 void (*
const egress)(
const uint8_t *work);
411static const PhysicalNs Physical __attribute__((unused)) = {
Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing,...
EMBED_INLINE embed_bool protocore_physical_eth_up(void)
Physical.eth_ready as an expression, for a bring-up loop to wait on.
EMBED_INLINE uint32_t protocore_physical_egress_ipv4(void)
Physical.egress_ip as an expression: the address a sketch prints once its link is up.
void protocore_physical_egress_mac(const uint8_t *work)
EMBED_INLINE embed_bool protocore_physical_wifi_up(void)
Physical.wifi_ready as an expression, for a bring-up loop to wait on.
embed_bool(* protocore_if_send_fn)(uint8_t if_id, const uint8_t *data, uint16_t len, void *ctx)
Put len octets on interface if_id.
protocore_if_kind protocore_net_classify_ip(uint32_t egress_ip, uint32_t sta_ip, uint32_t ap_ip)
Map a live default-route IPv4 to the interface it belongs to.
void protocore_physical_ip6_init(const uint8_t *work)
uint8_t protocore_net_channel(void)
Station channel (1..14), or 0 when not associated.
embed_bool init_ipv6_physical(void)
Enable dual IP layer operation on the WiFi interface (RFC 4213 sec 2, PROTOCORE_ENABLE_IPV6).
EMBED_INLINE uint8_t protocore_physical_channel(void)
Physical.wifi_channel as an expression: the 802.11 channel the radio is on.
void protocore_physical_classify_ip(const uint8_t *work)
EMBED_ENUM_BYTE(protocore_phy_ps, PROTOCORE_PHY_PS_NONE=0, PROTOCORE_PHY_PS_MIN_MODEM=1, PROTOCORE_PHY_PS_MAX_MODEM=2,)
Radio power-save mode, in the library's own vocabulary (IEEE 802.11 power management).
EMBED_BEGIN_DECLS embed_bool init_wifi_physical(const char *ssid, const char *password)
Start an 802.11 station join to an access point.
void protocore_physical_iface_kind(uint8_t *work)
int8_t protocore_net_rssi(void)
Station link RSSI in dBm, or 0 when not associated.
PhysicalVars PhysicalV
The operands and the outcome.
void protocore_physical_iface_reset(uint8_t *work)
embed_bool protocore_phy_monitor_begin(uint8_t channel, protocore_phy_frame_fn cb)
Enter monitor mode on channel, delivering frames to cb.
void protocore_physical_egress(const uint8_t *work)
void protocore_physical_wifi_rssi(const uint8_t *work)
size_t protocore_net_ssid(char *out, size_t cap)
Copy the associated SSID into out, null-terminated.
void protocore_physical_wifi_ready(const uint8_t *work)
uint8_t * protocore_physical_span(void)
The PROTOCORE_PHYSICAL_BORROW bytes this module's state lives in.
uint32_t protocore_net_egress_ip(void)
IPv4 of the current default-route interface, network byte order (RFC 791 app. B), 0 if none.
embed_bool init_wifi_ap_physical(const char *ssid, const char *password)
Start a softAP, with AP and station coexistence so a station link runs alongside it.
void protocore_physical_wifi_init(const uint8_t *work)
void protocore_physical_iface_add(uint8_t *work)
embed_bool wifi_ready(void)
True when the station link is associated and holds an IPv4 address.
void protocore_physical_iface_count(uint8_t *work)
EMBED_INLINE uint32_t protocore_physical_ap_ipv4(void)
Physical.wifi_ap_ip as an expression: the softAP IPv4, network byte order; 0 if it is down.
embed_bool protocore_net_mac(uint8_t out[6])
Copy the 802.11 station hardware address into out (6 octets, RFC 826 ar$hln = 6).
embed_bool eth_ready(void)
True when the wired link is up and holds an IPv4 address.
embed_bool protocore_phy_tx_power_set(int8_t dbm)
Cap transmit power.
protocore_if_kind protocore_net_egress(void)
Which interface carries outbound traffic (RFC 1122 sec 3.3.1.2).
void protocore_phy_monitor_set_channel(uint8_t channel)
Retune monitor mode to channel.
uint32_t protocore_net_ap_ip(void)
softAP IPv4, network byte order, or 0 when the softAP is down.
void protocore_physical_ip6_ready(const uint8_t *work)
void protocore_physical_wifi_ap_init(const uint8_t *work)
void protocore_physical_eth_init(const uint8_t *work)
EMBED_INLINE int8_t protocore_physical_rssi(void)
Physical.wifi_rssi as an expression: the station's received signal strength, in dBm.
protocore_phy_ps protocore_phy_ps_get(void)
The active power-save mode (PROTOCORE_PHY_PS_NONE when unsupported).
embed_bool init_wifi_radio_physical(uint8_t channel)
Start the radio in station mode without associating.
void protocore_physical_wifi_mac(const uint8_t *work)
void protocore_physical_wifi_radio_init(const uint8_t *work)
void protocore_physical_wifi_ap_ip(const uint8_t *work)
void protocore_physical_iface_at(uint8_t *work)
embed_bool protocore_phy_ps_set(protocore_phy_ps mode)
Apply a power-save mode. False when there is no radio backend.
embed_bool net_global_ipv6(protocore_ip *out)
The interface's global unicast IPv6 address (RFC 4291 sec 2.5.4).
void protocore_physical_egress_ip(const uint8_t *work)
void protocore_physical_iface_send(uint8_t *work)
void protocore_physical_eth_ready(const uint8_t *work)
EMBED_INLINE protocore_if_kind protocore_physical_egress_kind(void)
Physical.egress as an expression: the kind of interface the default route leaves on.
void protocore_physical_ip6_global(const uint8_t *work)
void(* protocore_phy_frame_fn)(const uint8_t *frame, uint16_t len, int8_t rssi, uint8_t channel)
One received frame, delivered in neutral terms.
void protocore_physical_iface_present(uint8_t *work)
void protocore_phy_monitor_end(void)
Leave monitor mode.
void protocore_physical_wifi_channel(const uint8_t *work)
embed_bool protocore_ipv6_ready(void)
True once a global unicast IPv6 address is configured.
embed_bool init_eth_physical(void)
Start a wired Ethernet link (PROTOCORE_ENABLE_ETHERNET).
embed_bool protocore_net_egress_mac(uint8_t out[6])
Copy the hardware address of the current default-route interface into out (6 octets).
void protocore_physical_wifi_ssid(const uint8_t *work)
What names an interface in the registry, and the frame a send puts on it.
uint8_t id
the interface a call acts on
const uint8_t * data
the frame a send puts on the wire
void * ctx
what that callback is handed back
uint16_t len
its length in octets
uint8_t i
the registry row a lookup names
protocore_if_send_fn send
how octets reach the interface being registered
protocore_if_kind kind
what the interface being registered is
void(*const wifi_ssid)(const uint8_t *work)
void(*const iface_reset)(uint8_t *work)
void(*const iface_at)(uint8_t *work)
void(*const egress_mac)(const uint8_t *work)
void(*const iface_kind)(uint8_t *work)
void(*const wifi_ap_ip)(const uint8_t *work)
void(*const classify_ip)(const uint8_t *work)
void(*const wifi_rssi)(const uint8_t *work)
void(*const egress)(const uint8_t *work)
void(*const wifi_mac)(const uint8_t *work)
void(*const wifi_ready)(const uint8_t *work)
void(*const eth_ready)(const uint8_t *work)
void(*const iface_count)(uint8_t *work)
void(*const iface_add)(uint8_t *work)
void(*const wifi_init)(const uint8_t *work)
void(*const ip6_global)(const uint8_t *work)
void(*const ip6_init)(const uint8_t *work)
void(*const egress_ip)(const uint8_t *work)
void(*const wifi_ap_init)(const uint8_t *work)
void(*const eth_init)(const uint8_t *work)
void(*const wifi_channel)(const uint8_t *work)
void(*const wifi_radio_init)(const uint8_t *work)
void(*const ip6_ready)(const uint8_t *work)
void(*const iface_present)(uint8_t *work)
void(*const iface_send)(uint8_t *work)
Where a readout copies to.
uint8_t * mac
receives a 6-octet hardware address (RFC 826 ar$hln = 6)
size_t cap
how much room text has
protocore_ip * ip6
receives the global unicast IPv6 address (RFC 4291 sec 2.5.4)
char * text
receives the SSID, null-terminated
What the egress classifier judges: the live route and the two WiFi addresses.
uint32_t egress_ip
default-route IPv4, network byte order (RFC 791 app. B); 0 if no route
uint32_t ap_ip
softAP IPv4, network byte order; 0 if the softAP is down
uint32_t sta_ip
station IPv4, network byte order; 0 if not associated
protocore_if_kind if_kind
What an 802.11 bring-up takes: the station join, the softAP, and the radio-only start.
uint8_t channel
channel a radio-only start pins (1..14); 0 leaves it to a capture layer
const char * ssid
SSID a join or a softAP names (IEEE 802.11-2020 9.4.2.2, <= 32 octets).
const char * password
WPA2 passphrase; "" opens the softAP.
A v4 or v6 address in network (big-endian) byte order.