33#define RA8_WIFI_TAG "WIFI"
286 bool answered =
false;
290 const ra8_err_t serviced = wifi->backend->service(wifi->backend_ctx, &link);
292 last_fault = serviced;
350 return (left !=
k_ra8_ok) ? left : stopped;
371 lease.
bound = (lease.
ip != 0U);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_BOUNDED_LOOP(symbol)
NASA Power-of-10 Rule 2: every loop in a FUNCTION has a constant bound.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_timeout
Operation exceeded its time budget.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_err_t ra8_wifi_deinit(ra8_wifi_t *wifi)
Release a handle and power its radio down.
ra8_err_t ra8_wifi_init(ra8_wifi_t *wifi, const ra8_wifi_cfg_t *cfg)
Bring the radio and its link up and make a handle usable.
ra8_err_t ra8_wifi_get_mac(ra8_wifi_t *wifi, ra8_wifi_mac_t *out)
Read the station's own MAC address.
static ra8_err_t internal_check_backend_query(const ra8_wifi_backend_t *b)
Validate the backend rows that report state or pace a wait.
static ra8_err_t internal_check_backend_session(const ra8_wifi_backend_t *b)
Validate the backend rows that join and leave a network.
static ra8_err_t internal_await_association(ra8_wifi_t *wifi)
Pump the backend until the station associates or the budget runs out.
ra8_err_t ra8_wifi_get_ap(ra8_wifi_t *wifi, ra8_wifi_ap_t *out)
Read what the backend knows about the associated AP.
ra8_err_t ra8_wifi_get_ip(const ra8_wifi_t *wifi, ra8_wifi_lease_t *out)
Read the cached DHCP lease without touching the wire.
ra8_err_t ra8_wifi_wait_ip(ra8_wifi_t *wifi, ra8_wifi_lease_t *out)
Obtain an IP address for the associated station, blocking until bound.
static ra8_err_t internal_check_backend(const ra8_wifi_backend_t *b)
Validate every row of a candidate backend table.
ra8_err_t ra8_wifi_status(const ra8_wifi_t *wifi, ra8_wifi_status_t *out)
Read a handle's cached status without touching the wire.
static ra8_err_t internal_check_backend_lifecycle(const ra8_wifi_backend_t *b)
Validate the backend rows that change the radio's state.
ra8_err_t ra8_wifi_disconnect(ra8_wifi_t *wifi)
Disassociate the station and power the radio down.
#define RA8_WIFI_TAG
Component tag for this facade's log lines.
ra8_err_t ra8_wifi_connect(ra8_wifi_t *wifi, const char *ssid, const char *psk)
Join a network by SSID and passphrase, blocking until associated.
static ra8_err_t internal_ensure_radio_up(ra8_wifi_t *wifi)
Raise the radio if it is not already up.
ra8_err_t ra8_wifi_poll(ra8_wifi_t *wifi, ra8_wifi_link_t *out)
Service the link once and refresh the cached association state.
A small, uniform Wi-Fi facade: init, connect, get an IP, disconnect.
@ k_ra8_wifi_state_ip_bound
A DHCP lease is held.
@ k_ra8_wifi_state_associating
A join has been asked for.
@ k_ra8_wifi_state_associated
Station is joined; no IP yet.
@ k_ra8_wifi_state_down
Not associated; radio may be off.
struct ra8_wifi_backend ra8_wifi_backend_t
One radio's implementation of the operations this facade dispatches.
struct ra8_wifi_ap ra8_wifi_ap_t
struct ra8_wifi_mac ra8_wifi_mac_t
struct ra8_wifi_lease ra8_wifi_lease_t
struct ra8_wifi ra8_wifi_t
ra8_wifi_link_t
The instantaneous association state a backend reports.
@ k_ra8_wifi_link_up
Station is associated with an AP.
@ k_ra8_wifi_link_down
Station is not associated.
struct ra8_wifi_status ra8_wifi_status_t
struct ra8_wifi_cfg ra8_wifi_cfg_t
@ k_ra8_wifi_join_polls
Times ra8_wifi_connect services the link while waiting for the join to complete.
@ k_ra8_wifi_poll_gap_ms
Milliseconds the facade idles between two association attempts.
The radio-operation seam ra8_wifi dispatches through.
int8_t rssi
Signal level in dBm.
ra8_err_t(* open)(void *ctx)
Bring the radio's link up and prove it answers.
ra8_err_t(* radio_up)(void *ctx)
Start the radio in station mode.
ra8_err_t(* get_mac)(void *ctx, ra8_wifi_mac_t *out)
Read the station's own MAC address.
ra8_err_t(* get_ap)(void *ctx, ra8_wifi_ap_t *out)
Read what the radio knows about the associated AP.
ra8_err_t(* join)(void *ctx, const char *ssid, const char *psk)
Ask the station to associate with a network.
ra8_err_t(* close)(void *ctx)
Release the link the backend opened.
ra8_err_t(* service)(void *ctx, ra8_wifi_link_t *out_link)
Service the link once and report the association state.
ra8_err_t(* radio_down)(void *ctx)
Stop the radio and release its resources.
ra8_err_t(* leave)(void *ctx)
Disassociate the station from its network.
const ra8_wifi_backend_t * backend
Radio operations; every row set.
void * backend_ctx
Opaque state handed to the backend.
ra8_wifi_ip_bind_fn ip_bind
IP-stack hook for ra8_wifi_wait_ip.
void * ip_ctx
Opaque context handed to ip_bind.
bool bound
A usable lease is held.
uint32_t ip
Leased station address, or zero if unbound.
ra8_wifi_state_t state
Lifecycle position.
bool associated
The station is joined.
bool ip_bound
A DHCP lease is held.
int8_t rssi
Last known signal level in dBm, or zero.
ra8_wifi_lease_t ip
The current lease, valid when ip_bound.
ra8_wifi_ip_bind_fn ip_bind
Bound IP-stack hook.
const ra8_wifi_backend_t * backend
Bound radio operations.
void * backend_ctx
Backend's opaque state.
void * ip_ctx
Context for ip_bind.
ra8_wifi_mac_t mac
Cached station address.
bool mac_valid
mac has been read.
bool radio_on
The radio has been started.
ra8_wifi_state_t state
Lifecycle position.
bool open
The handle is initialised.
ra8_wifi_lease_t lease
Cached DHCP lease.
int8_t rssi
Last signal reading, dBm.