47#ifndef SAPI_DUAL_CHANNEL_H
48#define SAPI_DUAL_CHANNEL_H
66#define SAPI_DUAL_CHANNEL_MAX_LINKS 4U
72#define SAPI_DUAL_CHANNEL_MAX_PAYLOAD (SAPI_DUAL_MSGCHANNEL_MAX_PAYLOAD - 4U)
94typedef struct sapi_dual_channel_s
101 void *status_callback_ctx;
104 bool pending_data_valid;
106 uint8_t pending_data_size;
108 bool pending_state_valid;
113typedef struct sapi_dual_channel_config_s
178 const uint8_t *payload,
179 uint8_t payload_size,
180 uint32_t *out_ack_link_count);
200 uint8_t *out_payload,
243 bool channel_degraded, uint64_t timestamp_ms);
sapi_status_t sapi_dual_channel_send(sapi_dual_channel_t *channel, const uint8_t *payload, uint8_t payload_size, uint32_t *out_ack_link_count)
Sends payload as a DATA frame on every configured redundant link - never gated by any negotiated stat...
#define SAPI_DUAL_CHANNEL_MAX_LINKS
Maximum number of redundant links one sapi_dual_channel_t may be configured with. Fixed,...
void(*) sapi_dual_channel_status_callback_t(sapi_dual_channel_status_t new_status, sapi_dual_channel_status_t old_status, void *user_ctx)
Optional callback invoked whenever sapi_dual_channel_get_status()'s value changes (ADR-020 section 2'...
sapi_status_t sapi_dual_channel_receive_state_frame(sapi_dual_channel_t *channel, sapi_duration_ms_t timeout_ms, sapi_dual_state_frame_t *out_frame)
Returns the most recently staged inbound STATE frame, actively polling the configured links if none w...
sapi_dual_state_t
State of one instance in a dual (two-redundant-instance) relationship, as decided by sapi_dual_negoti...
sapi_dual_channel_status_t sapi_dual_channel_get_status(const sapi_dual_channel_t *channel)
Returns the aggregate connection status across every configured redundant link, as of the most recent...
sapi_dual_channel_status_t
Aggregate connection status of a sapi_dual_channel_t across all of its configured redundant links (AD...
#define SAPI_DUAL_CHANNEL_MAX_PAYLOAD
Max application payload bytes usable via sapi_dual_channel_send()/_receive() - Layer-1's own SAPI_DUA...
sapi_status_t sapi_dual_channel_receive(sapi_dual_channel_t *channel, uint8_t *out_payload, uint8_t max_size, sapi_duration_ms_t timeout_ms, uint8_t *out_size)
Returns the most recently staged inbound DATA frame, actively polling the configured links (each auto...
sapi_status_t sapi_dual_channel_init(sapi_dual_channel_t *channel, const sapi_dual_channel_config_t *config)
Initializes a sapi_dual_channel_t: initializes every configured redundant link (sapi_dual_msgchannel_...
bool sapi_dual_channel_is_link_up(const sapi_dual_channel_t *channel, uint32_t link_index)
Returns whether one specific configured link is currently considered up, as of the most recent sapi_d...
sapi_status_t sapi_dual_channel_send_heartbeat(sapi_dual_channel_t *channel, uint32_t *out_ack_count)
Sends a sapi_dual_state_frame_t (sapi_dual_frames.h) on every configured redundant link - fire-and-fo...
struct sapi_netlink_impl_s * sapi_netlink_handle_t
Opaque handle to an established link, returned by sapi_netlink_open().
sapi_status_t
Common result/status codes.
uint32_t sapi_duration_ms_t
Layer-2 (DualChannel-owned) frame kind/header definitions for ADR-020 - shared between sapi_dual_chan...
"Channel" layer of ADR-020: one EN 50159-defended message channel over one already-open sapi_netlink_...
Shared enums for the sapi_dual module (ADR-020): dual-instance state negotiation and the redundant,...
OS Abstraction Layer - Point-to-point network link service.
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
Configuration for sapi_dual_channel_init().
sapi_duration_ms_t ack_timeout_ms
uint32_t expected_peer_id
sapi_dual_channel_status_callback_t status_callback
sapi_netlink_handle_t links[SAPI_DUAL_CHANNEL_MAX_LINKS]
void * status_callback_ctx
One sapi_dual_channel_t instance's state. Caller-owned storage; every field is private - reach it onl...
One sapi_dual_msgchannel_t instance's state. Caller-owned storage (REQ-DUAL-MSGCHANNEL-001); opaque i...
SAPI_DUAL_FRAME_KIND_STATE payload - sapi_dual_negotiator_t's own periodic beacon.