|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Wi-Fi station bring-up and association over the C6 link. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_c6link_sta_cfg |
| What this host must tell the co-processor to join one network. More... | |
| struct | ra8_c6link_ap_info |
| What the co-processor knows about the AP the station is on. More... | |
Typedefs | |
| typedef struct ra8_c6link_sta_cfg | ra8_c6link_sta_cfg_t |
| typedef struct ra8_c6link_ap_info | ra8_c6link_ap_info_t |
Enumerations | |
| enum | ra8_c6link_wifi_limits_t : uint8_t { k_ra8_c6link_pass_max = 64U , k_ra8_c6link_channel_max = 14U } |
| Field capacities the station configuration works to. More... | |
Functions | |
| ra8_err_t | ra8_c6link_sta_cfg_set (ra8_c6link_sta_cfg_t *cfg, const char *ssid, const char *pass) |
| Fill a station configuration from an SSID and a passphrase. | |
| ra8_err_t | ra8_c6link_wifi_start (ra8_c6link_t *link) |
| Start the co-processor's Wi-Fi radio in station mode. | |
| ra8_err_t | ra8_c6link_wifi_stop (ra8_c6link_t *link) |
| Stop the radio and release the co-processor's Wi-Fi resources. | |
| ra8_err_t | ra8_c6link_wifi_join (ra8_c6link_t *link, const ra8_c6link_sta_cfg_t *cfg) |
| Ask the station to associate with the configured network. | |
| ra8_err_t | ra8_c6link_wifi_leave (ra8_c6link_t *link) |
| Disassociate the station from its current network. | |
| ra8_err_t | ra8_c6link_wifi_mac (ra8_c6link_t *link, ra8_c6link_mac_t *out) |
| Read the station interface's MAC address. | |
| ra8_err_t | ra8_c6link_wifi_ap_info (ra8_c6link_t *link, ra8_c6link_ap_info_t *out) |
| Read what the co-processor knows about the associated AP. | |
Wi-Fi station bring-up and association over the C6 link.
A station join is eleven RPC ids out of the several hundred the esp-hosted protocol defines, and the only "configuration" the co-processor needs is an SSID, a passphrase and a handful of scalars. This header is that, and nothing else: it does not reproduce ESP-IDF's wifi_*_t types, because the C6 decodes protobuf messages with named fields and no layout on this side is ever transmitted (see the rationale in ra8_c6link.h).
Definition in file ra8_c6link_wifi.h.
| typedef struct ra8_c6link_ap_info ra8_c6link_ap_info_t |
| typedef struct ra8_c6link_sta_cfg ra8_c6link_sta_cfg_t |
| enum ra8_c6link_wifi_limits_t : uint8_t |
Field capacities the station configuration works to.
Both come from 802.11 and from the protobuf field comments upstream ships ("SSID of target AP. 32char", "Password of target AP. 64char"), so they are the co-processor's limits as much as this host's.
| Enumerator | |
|---|---|
| k_ra8_c6link_pass_max | Longest passphrase the co-processor accepts, in octets. |
| k_ra8_c6link_channel_max | Highest 2.4 GHz channel number; zero means "scan for it". |
Definition at line 85 of file ra8_c6link_wifi.h.
|
nodiscard |
Fill a station configuration from an SSID and a passphrase.
Copies both strings into the record, bounded, and derives their lengths. An empty or null passphrase means an open network, which is a legitimate configuration and not an error. Everything else in the record is cleared, so a stale channel or BSSID from a previous use cannot survive.
| [out] | cfg | Record to fill; must be non-null. |
| [in] | ssid | NUL-terminated SSID; must be non-null and 1.. k_ra8_c6link_ssid_max octets. |
| [in] | pass | NUL-terminated passphrase, or null for an open network; at most k_ra8_c6link_pass_max octets. |
| k_ra8_ok | The record is filled and ready for ra8_c6link_wifi_join. |
| k_ra8_err_null_ptr | cfg or ssid was null. |
| k_ra8_err_invalid_size | ssid was empty or either string was longer than its field. |
ssid is NUL-terminated within k_ra8_c6link_ssid_max + 1 octets. pass, when non-null, is NUL-terminated within k_ra8_c6link_pass_max + 1 octets. cfg is left cleared rather than half-filled.Definition at line 100 of file ra8_c6link_wifi_sta.c.
References internal_c6link_sta_len(), k_ra8_c6link_pass_max, k_ra8_c6link_ssid_max, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, ra8_c6link_sta_cfg::pass, ra8_c6link_sta_cfg::pass_len, ra8_secure_memzero(), ra8_c6link_sta_cfg::ssid, and ra8_c6link_sta_cfg::ssid_len.
Referenced by c6_join_phase_associate(), internal_c6_cam_associate(), internal_c6link_op_join(), and internal_open_and_join().
|
nodiscard |
Read what the co-processor knows about the associated AP.
| [in,out] | link | Open handle; must be non-null. |
| [out] | out | Record to fill; must be non-null. |
| k_ra8_ok | out describes the current association. |
| k_ra8_err_null_ptr | link or out was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | The co-processor did not answer. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | The answer reported a failure – which is what an unassociated station returns – or carried no record. |
| k_ra8_err_spi_error | The transport refused a transfer. |
out is fully written. out is cleared rather than left half-written.Definition at line 405 of file ra8_c6link_wifi_sta.c.
References internal_c6link_take_ap(), k_ra8_err_not_initialized, k_ra8_err_null_ptr, priv_c6link_rpc_call(), and ra8_c6link_is_open().
Referenced by internal_c6link_op_get_ap().
|
nodiscard |
Ask the station to associate with the configured network.
Issues Req_WifiSetConfig for the station interface and then Req_WifiConnect. Returns as soon as the co-processor has accepted the request; the association result arrives later as an event.
| [in,out] | link | Open handle; must be non-null. |
| [in] | cfg | Station configuration; must be non-null and consistent, which ra8_c6link_sta_cfg_set guarantees. |
| k_ra8_ok | The co-processor accepted the association request. |
| k_ra8_err_null_ptr | link or cfg was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_invalid_size | A length in cfg exceeds its field. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | The co-processor did not answer a step. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | A step reported a failure code. |
| k_ra8_err_spi_error | The transport refused a transfer. |
link. cfg holds credentials for a network that is in range. Definition at line 270 of file ra8_c6link_wifi_sta.c.
References internal_c6link_sta_set_config(), k_ra8_c6link_pass_max, k_ra8_c6link_ssid_max, k_ra8_err_invalid_size, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, ra8_c6link_sta_cfg::pass_len, priv_c6link_bare_req(), ra8_c6link_is_open(), and ra8_c6link_sta_cfg::ssid_len.
Referenced by c6_join_phase_associate(), internal_c6_cam_associate(), internal_c6link_op_join(), and internal_open_and_join().
|
nodiscard |
Disassociate the station from its current network.
| [in,out] | link | Open handle; must be non-null. |
| k_ra8_ok | The co-processor accepted the disassociation. |
| k_ra8_err_null_ptr | link was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | The co-processor did not answer. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | The answer reported a failure code. |
| k_ra8_err_spi_error | The transport refused a transfer. |
Definition at line 422 of file ra8_c6link_wifi.c.
References k_ra8_err_not_initialized, k_ra8_err_null_ptr, priv_c6link_bare_req(), and ra8_c6link_is_open().
Referenced by internal_c6link_op_leave().
|
nodiscard |
Read the station interface's MAC address.
The address an IP stack above must use as its own. It is a property of the co-processor's efuses, so it is stable across resets and is available as soon as the radio has been initialised.
| [in,out] | link | Open handle; must be non-null. |
| [out] | out | Address to fill; must be non-null. |
| k_ra8_ok | out holds the station address. |
| k_ra8_err_null_ptr | link or out was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | The co-processor did not answer. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | The answer reported a failure, or carried an address of the wrong length. |
| k_ra8_err_spi_error | The transport refused a transfer. |
link. out holds k_ra8_c6link_mac_bytes octets. out is cleared rather than left half-written.Definition at line 324 of file ra8_c6link_wifi_sta.c.
References internal_c6link_take_mac(), k_ra8_c6link_iface_sta, k_ra8_err_not_initialized, k_ra8_err_null_ptr, priv_c6link_rpc_call(), and ra8_c6link_is_open().
Referenced by c6_join_phase_associate(), c6_wifi_phase_station(), internal_c6_cam_associate(), and internal_c6link_op_get_mac().
|
nodiscard |
Start the co-processor's Wi-Fi radio in station mode.
Issues Req_WifiInit, Req_SetWifiMode for station mode, and Req_WifiStart, in that order, stopping at the first one the co-processor refuses. The initialisation configuration transmitted is the ESP-IDF default set for this co-processor, field by field – see ra8_c6link_wifi_init_t in the implementation for what each value is and why it has that value.
| [in,out] | link | Open handle; must be non-null. |
| k_ra8_ok | The radio is up in station mode. |
| k_ra8_err_null_ptr | link was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | The co-processor did not answer a step. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | A step was answered with a failure code; ra8_c6link_last_fault names which. |
| k_ra8_err_spi_error | The transport refused a transfer. |
Definition at line 388 of file ra8_c6link_wifi.c.
References internal_c6link_wifi_do_init(), internal_c6link_wifi_do_mode(), k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, priv_c6link_bare_req(), and ra8_c6link_is_open().
Referenced by c6_join_phase_associate(), c6_wifi_phase_station(), internal_c6_cam_associate(), internal_c6link_op_radio_up(), and internal_open_and_join().
|
nodiscard |
Stop the radio and release the co-processor's Wi-Fi resources.
Issues Req_WifiStop then Req_WifiDeinit. Unlike the start sequence this continues past a refusal: a teardown that stops at the first error leaves the co-processor half-configured, which is worse than reporting the first fault and finishing the job.
| [in,out] | link | Open handle; must be non-null. |
| k_ra8_ok | Both steps succeeded. |
| k_ra8_err_null_ptr | link was null. |
| k_ra8_err_not_initialized | link is not open. |
| k_ra8_err_busy | A request is already outstanding on link. |
| k_ra8_err_timeout | A step went unanswered; the rest still ran. |
| k_ra8_err_hw_timeout | The co-processor never armed HANDSHAKE, so no transaction was clocked. |
| k_ra8_err_protocol_error | A step reported a failure code; the rest still ran and ra8_c6link_last_fault names the first failure. |
| k_ra8_err_spi_error | The transport refused a transfer. |
Definition at line 408 of file ra8_c6link_wifi.c.
References k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, priv_c6link_bare_req(), and ra8_c6link_is_open().
Referenced by c6_wifi_phase_station(), and internal_c6link_op_radio_down().