46typedef enum : int32_t {
82 const size_t packed = rpc__get_packed_size(req);
88 uint16_t body_at = 0U;
94 if (rpc__pack(req, &payload[body_at]) != packed) {
98 link->
tx_len = (uint16_t)((uint32_t)body_at + (uint32_t)packed);
99 link->
tx_if = (uint8_t)ESP_SERIAL_IF;
155 if (link ==
nullptr) {
174 if ((link ==
nullptr) || (req ==
nullptr) || (take ==
nullptr)) {
197 .take_ctx = take_ctx,
238 const WifiEventStaConnected* body)
240 if (body ==
nullptr) {
244 ev->
channel = (uint8_t)body->channel;
264 const WifiEventStaDisconnected* body)
266 if (body ==
nullptr) {
270 ev->
reason = (uint16_t)body->reason;
271 ev->
rssi = (int8_t)body->rssi;
295 switch ((int32_t)msg->msg_id) {
296 case (int32_t)RPC_ID__Event_ESPInit:
298 if (msg->event_esp_init !=
nullptr) {
302 case (int32_t)RPC_ID__Event_StaConnected:
304 if (msg->event_sta_connected !=
nullptr) {
308 case (int32_t)RPC_ID__Event_StaDisconnected:
310 if (msg->event_sta_disconnected !=
nullptr) {
314 case (int32_t)RPC_ID__Event_WifiEventNoArgs:
316 if (msg->event_wifi_event_no_args !=
nullptr) {
361 if ((link ==
nullptr) || (payload ==
nullptr)) {
365 uint16_t proto_len = 0U;
367 if (proto ==
nullptr) {
368 if (link->
stats !=
nullptr) {
374 ProtobufCAllocator alloc = {};
378 Rpc* msg = rpc__unpack(&alloc, (
size_t)proto_len, proto);
379 if (msg ==
nullptr) {
380 if (link->
stats !=
nullptr) {
386 if (link->
stats !=
nullptr) {
391 if (msg->msg_type == RPC_TYPE__Event) {
393 }
else if (msg->msg_type == RPC_TYPE__Resp) {
398 if (link->
stats !=
nullptr) {
403 rpc__free_unpacked(msg, &alloc);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
void priv_c6link_emit(ra8_c6link_t *link, const ra8_c6link_event_t *ev)
Deliver one decoded announcement to the registered callback.
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.
@ k_ra8_c6link_rpc_transfers
Transactions one RPC call may clock while waiting for its response.
ra8_err_t(* ra8_c6link_take_fn_t)(void *ctx, const void *msg)
Extractor that copies an answer's fields out.
@ k_ra8_c6link_event_sta_connected
Event_StaConnected: the station has associated with an AP.
@ k_ra8_c6link_event_wifi
Event_WifiEventNoArgs: a Wi-Fi event carrying only its own id, reported verbatim in ra8_c6link_event:...
@ k_ra8_c6link_event_sta_disconnected
Event_StaDisconnected: the station has lost or left its AP.
@ k_ra8_c6link_event_boot
Event_ESPInit: the co-processor has booted and is accepting RPC.
struct ra8_c6link_wait ra8_c6link_wait_t
@ k_ra8_c6link_header_bytes
sizeof(struct esp_payload_header) on this ABI.
@ k_ra8_c6link_max_payload
Largest payload one frame can carry.
struct ra8_c6link_stats ra8_c6link_stats_t
struct ra8_c6link_event ra8_c6link_event_t
struct ra8_c6link ra8_c6link_t
void priv_c6link_arena_bind(ProtobufCAllocator *out, ra8_c6link_t *link)
Bind an allocator descriptor to a link's arena.
void priv_c6link_arena_reset(ra8_c6link_t *link)
Empty the link's decode arena.
Cross-translation-unit contract inside libs/ra8_c6link.
ra8_err_t priv_c6link_pump(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_stats_t *stats)
Clock transactions until the budget or the wait says stop.
const uint8_t * priv_c6link_tlv_body(const uint8_t *payload, uint16_t len, uint16_t *proto_len)
Strip the envelope off a received serial payload.
ra8_err_t priv_c6link_tlv_open(uint8_t *out, uint16_t cap, uint16_t proto_len, uint16_t *body_at)
Write both envelope tags ahead of a protobuf payload.
static bool internal_c6link_rpc_answer(ra8_c6link_t *link, const Rpc *msg)
Offer a decoded message to the outstanding wait.
bool priv_c6link_rpc_consume(ra8_c6link_t *link, const uint8_t *payload, uint16_t len)
Decode one control-plane payload and act on it.
c6link_esp_status_t
Stable ESP-IDF general error values carried on the wire.
@ k_c6link_esp_err_invalid_size
Remote extent validation failed.
@ k_c6link_esp_err_not_supported
Remote image lacks the operation.
@ k_c6link_esp_err_not_allowed
Remote policy denied the operation.
@ k_c6link_esp_err_invalid_response
Remote protocol validation failed.
@ k_c6link_esp_err_no_mem
Remote allocation failed.
@ k_c6link_esp_err_invalid_arg
Remote argument validation failed.
@ k_c6link_esp_err_invalid_crc
Remote checksum validation failed.
@ k_c6link_esp_err_invalid_state
Remote service state rejected the call.
@ k_c6link_esp_err_not_found
Remote object was absent.
@ k_c6link_esp_err_timeout
Remote operation timed out.
static void internal_c6link_rpc_event(ra8_c6link_t *link, const Rpc *msg)
Decode one announcement and hand it to the link's callback.
static ra8_err_t internal_c6link_rpc_stage(ra8_c6link_t *link, Rpc *req)
Stage a packed request in the link's transmit transaction.
static ra8_err_t internal_c6link_remote_error(int32_t response)
Translate one nonzero ESP-IDF wire status into the RA8 error domain.
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.
static void internal_c6link_rpc_ev_connected(ra8_c6link_event_t *ev, const WifiEventStaConnected *body)
Turn a decoded station-connected event into a first-party record.
static void internal_c6link_rpc_ev_disconnected(ra8_c6link_event_t *ev, const WifiEventStaDisconnected *body)
Turn a decoded station-disconnected event into a first-party record.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ 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_access_denied
Operation refused because the target is protected against it.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_timeout
Operation exceeded its time budget.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ 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.
uint8_t channel
Primary channel, sta_connected.
uint16_t reason
802.11 reason code, sta_disconnected.
ra8_c6link_mac_t bssid
AP address for the two station events.
ra8_c6link_event_kind_t kind
Which announcement this is.
char ssid[k_ra8_c6link_ssid_max+1U]
AP SSID, NUL-terminated.
uint32_t reset_reason
Co-processor reset cause, boot.
int8_t rssi
Signal level, sta_disconnected.
int32_t wifi_event_id
Raw id, wifi.
uint8_t ssid_len
Octets of ssid the C6 supplied.
uint32_t rpc_id
RPC_ID__Req_* of the request that failed, or zero.
int32_t resp
The co-processor's result code, or zero if none.
uint16_t rpc_in
Control-plane frames decoded as Rpc.
uint16_t undecodable
Control-plane frames the codec would not parse.
ra8_err_t result
What the extractor decided.
uint32_t uid
UID stamped on the request; echoed back.
void * take_ctx
Context handed to the extractor.
bool armed
A request is outstanding.
ra8_c6link_take_fn_t take
Extractor for the answer's fields.
uint32_t resp_id
RPC_ID__Resp_* that answers it.
bool satisfied
Its answer arrived and was extracted.
uint8_t tx_if
Interface the staged payload uses.
uint32_t next_uid
UID for the next request issued.
bool open
The handle is initialised.
ra8_c6link_fault_t fault
The last failing request.
ra8_c6link_stats_t * stats
Counters for the running pump.
uint16_t tx_len
Staged payload length, or zero.
ra8_c6link_wait_t wait
The outstanding request, if any.
uint8_t tx[k_ra8_c6link_frame_bytes]
Transmit transaction.