63typedef enum : int32_t {
94 while ((n < cap) && (text[n] !=
'\0')) {
102 if ((cfg ==
nullptr) || (ssid ==
nullptr)) {
103 if (cfg !=
nullptr) {
114 const uint8_t pass_len =
120 for (uint8_t i = 0U; i < ssid_len; i++) {
121 cfg->
ssid[i] = ssid[i];
123 for (uint8_t i = 0U; i < pass_len; i++) {
124 cfg->
pass[i] = pass[i];
181 for (uint8_t i = 0U; i < cfg->
ssid_len; i++) {
182 buf->
ssid[i] = (uint8_t)cfg->
ssid[i];
184 for (uint8_t i = 0U; i < cfg->
pass_len; i++) {
185 buf->
pass[i] = (uint8_t)cfg->
pass[i];
215 WifiScanThreshold threshold;
216 wifi_scan_threshold__init(&threshold);
220 wifi_pmf_config__init(&pmf);
227 wifi_sta_config__init(&sta);
228 sta.ssid.data = buf.
ssid;
229 sta.ssid.len = (size_t)cfg->
ssid_len;
230 sta.password.data = buf.
pass;
231 sta.password.len = (size_t)cfg->
pass_len;
234 sta.channel = (uint32_t)cfg->
channel;
236 sta.bssid.data = buf.
bssid;
238 sta.threshold = &threshold;
242 wifi_config__init(&wcfg);
243 wcfg.u_case = WIFI_CONFIG__U_STA;
246 RpcReqWifiSetConfig body;
247 rpc__req__wifi_set_config__init(&body);
253 req.msg_type = RPC_TYPE__Req;
254 req.msg_id = RPC_ID__Req_WifiSetConfig;
255 req.payload_case = RPC__PAYLOAD_REQ_WIFI_SET_CONFIG;
256 req.req_wifi_set_config = &body;
260 .rpc_id = (uint32_t)RPC_ID__Req_WifiSetConfig};
263 (uint32_t)RPC_ID__Resp_WifiSetConfig,
272 if ((link ==
nullptr) || (cfg ==
nullptr)) {
310 const Rpc* msg = (
const Rpc*)msg_v;
313 const RpcRespGetMacAddress* body = msg->resp_get_mac_address;
314 if (body ==
nullptr) {
326 if ((link ==
nullptr) || (out ==
nullptr)) {
334 RpcReqGetMacAddress body;
335 rpc__req__get_mac_address__init(&body);
345 req.msg_type = RPC_TYPE__Req;
346 req.msg_id = RPC_ID__Req_GetMACAddress;
347 req.payload_case = RPC__PAYLOAD_REQ_GET_MAC_ADDRESS;
348 req.req_get_mac_address = &body;
352 .rpc_id = (uint32_t)RPC_ID__Req_GetMACAddress};
355 (uint32_t)RPC_ID__Resp_GetMACAddress,
381 const Rpc* msg = (
const Rpc*)msg_v;
384 const RpcRespWifiStaGetApInfo* body = msg->resp_wifi_sta_get_ap_info;
385 if (body ==
nullptr) {
392 if (body->ap_record ==
nullptr) {
396 const WifiApRecord* rec = body->ap_record;
398 out->
channel = (uint8_t)rec->primary;
399 out->
rssi = (int8_t)rec->rssi;
407 if ((link ==
nullptr) || (out ==
nullptr)) {
415 RpcReqWifiStaGetApInfo body;
416 rpc__req__wifi_sta_get_ap_info__init(&body);
420 req.msg_type = RPC_TYPE__Req;
421 req.msg_id = RPC_ID__Req_WifiStaGetApInfo;
422 req.payload_case = RPC__PAYLOAD_REQ_WIFI_STA_GET_AP_INFO;
423 req.req_wifi_sta_get_ap_info = &body;
427 .rpc_id = (uint32_t)RPC_ID__Req_WifiStaGetApInfo};
430 (uint32_t)RPC_ID__Resp_WifiStaGetApInfo,
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
uint8_t priv_c6link_copy_str(char *dst, uint8_t cap, const ProtobufCBinaryData *src)
Copy a length-counted binary field into a NUL-terminated string.
bool priv_c6link_copy_mac(ra8_c6link_mac_t *dst, const ProtobufCBinaryData *src)
Copy a binary field into a MAC address, all-or-nothing.
The single integration boundary between this firmware and the ESP32-C6.
struct ra8_c6link_mac ra8_c6link_mac_t
@ k_ra8_c6link_mac_bytes
Octets in an IEEE 802 address.
@ k_ra8_c6link_ssid_max
Octets in the longest SSID 802.11 allows.
struct ra8_c6link ra8_c6link_t
bool ra8_c6link_is_open(const ra8_c6link_t *link)
Report whether a handle is currently open.
Cross-translation-unit contract inside libs/ra8_c6link.
ra8_err_t priv_c6link_take_resp(void *ctx, const void *msg_v)
Extract the result code from an answer that carries nothing else.
ra8_err_t priv_c6link_bare_req(ra8_c6link_t *link, uint32_t req_id)
Issue a request whose body carries no fields and whose answer carries only a result code.
struct ra8_c6link_take_ctx ra8_c6link_take_ctx_t
ra8_err_t priv_c6link_resp(ra8_c6link_t *link, uint32_t rpc_id, int32_t resp)
Map a co-processor result code onto an ra8 error, recording it.
ra8_err_t priv_c6link_rpc_call(ra8_c6link_t *link, Rpc *req, uint32_t resp_id, ra8_c6link_take_fn_t take, void *take_ctx)
Issue one request and pump until its answer arrives.
Wi-Fi station bring-up and association over the C6 link.
struct ra8_c6link_sta_cfg ra8_c6link_sta_cfg_t
@ k_ra8_c6link_pass_max
Longest passphrase the co-processor accepts, in octets.
struct ra8_c6link_ap_info ra8_c6link_ap_info_t
static uint8_t internal_c6link_sta_len(const char *text, uint8_t cap)
Measure a NUL-terminated string without trusting it to be terminated.
struct ra8_c6link_sta_wire_buf ra8_c6link_sta_wire_buf_t
ra8_err_t ra8_c6link_wifi_mac(ra8_c6link_t *link, ra8_c6link_mac_t *out)
Read the station interface's MAC address.
ra8_c6link_sta_wire_t
Co-processor-side numbering the station requests transmit.
@ k_ra8_c6link_scan_fast
WIFI_FAST_SCAN: stop at the first acceptable AP, which is what a fixed bench network wants.
@ k_ra8_c6link_sort_signal
WIFI_CONNECT_AP_BY_SIGNAL.
@ k_ra8_c6link_auth_open
WIFI_AUTH_OPEN as a threshold means "impose no minimum".
@ k_ra8_c6link_iface_sta
WIFI_IF_STA: STA interface index (also the Req_GetMACAddress.mode selector).
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.
static ra8_err_t internal_c6link_take_mac(void *ctx, const void *msg_v)
Extract the station address from its answer.
static ra8_err_t internal_c6link_sta_set_config(ra8_c6link_t *link, const ra8_c6link_sta_cfg_t *cfg)
Send Req_WifiSetConfig carrying the station credentials.
static void internal_c6link_sta_stage(ra8_c6link_sta_wire_buf_t *buf, const ra8_c6link_sta_cfg_t *cfg)
Copy the caller's credentials into writable transmit storage.
static ra8_err_t internal_c6link_take_ap(void *ctx, const void *msg_v)
Extract the associated AP's record from its answer.
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.
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.
@ 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_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Secure-comparison primitives for the crypto / secure-boot paths.
void ra8_secure_memzero(void *ptr, size_t len)
Securely zero a buffer such that the write cannot be optimised away.
ra8_c6link_mac_t bssid
Address of the associated AP.
int32_t authmode
Co-processor wifi_auth_mode_t.
char ssid[k_ra8_c6link_ssid_max+1U]
Its SSID, NUL-terminated.
uint8_t ssid_len
Octets of ssid.
int8_t rssi
Signal level in dBm.
uint8_t channel
Primary channel in use.
uint8_t octet[k_ra8_c6link_mac_bytes]
Address octets, first on the wire first.
bool bssid_set
Pin the association to bssid.
uint8_t channel
Channel to try first, or zero.
uint8_t ssid_len
Octets of ssid to transmit.
char pass[k_ra8_c6link_pass_max+1U]
Passphrase, NUL-terminated.
uint8_t pass_len
Octets of pass to transmit.
ra8_c6link_mac_t bssid
Target AP address when pinned.
char ssid[k_ra8_c6link_ssid_max+1U]
Target SSID, NUL-terminated.
Writable copies of the credentials, for the codec's binary fields.
uint8_t bssid[k_ra8_c6link_mac_bytes]
Pinned AP address, if any.
uint8_t pass[k_ra8_c6link_pass_max]
Passphrase octets.
uint8_t ssid[k_ra8_c6link_ssid_max]
SSID octets, as transmitted.
ra8_c6link_t * link
Handle the request was issued on.
uint32_t rpc_id
RPC_ID__Req_* to record in the fault slot.
void * out
Where the extracted fields go, or null.