|
Mercury Modem
Mercury ARQ/Broadcast modem
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "arq.h"#include "arq_timing.h"#include "arq_protocol.h"#include "carousel.h"

Go to the source code of this file.
Data Structures | |
| struct | arq_event_t |
| ARQ event with all possible payload fields. More... | |
| struct | arq_session_t |
| struct | arq_fsm_callbacks_t |
Enumerations | |
| enum | arq_conn_state_t { ARQ_CONN_DISCONNECTED = 0 , ARQ_CONN_LISTENING = 1 , ARQ_CONN_CALLING = 2 , ARQ_CONN_ACCEPTING = 3 , ARQ_CONN_CONNECTED = 4 , ARQ_CONN_DISCONNECTING = 5 , ARQ_CONN__COUNT } |
| enum | arq_teardown_t { ARQ_TD_NONE = 0 , ARQ_TD_LISTEN_OFF , ARQ_TD_DRAINING , ARQ_TD_SENT , ARQ_TD_REPLYING , ARQ_TD_NOTIFYING } |
| enum | arq_event_id_t { ARQ_EV_APP_LISTEN = 0 , ARQ_EV_APP_STOP_LISTEN , ARQ_EV_APP_CONNECT , ARQ_EV_APP_DISCONNECT , ARQ_EV_APP_DATA_READY , ARQ_EV_RX_CALL , ARQ_EV_RX_ACCEPT , ARQ_EV_RX_DISCONNECT , ARQ_EV_TIMER_RETRY , ARQ_EV_TIMER_ACK , ARQ_EV_TX_STARTED , ARQ_EV_TX_COMPLETE , ARQ_EV_RX_CAROUSEL , ARQ_EV_TIMER_CAROUSEL , ARQ_EV_RX_PATTERN , ARQ_EV__COUNT } |
| enum | arq_listen_end_t { ARQ_LISTEN_GOES_ON = 0 , ARQ_LISTEN_ENDS_IN_SESSION , ARQ_LISTEN_ENDS_RELEASED } |
Functions | |
| void | arq_fsm_set_callbacks (const arq_fsm_callbacks_t *cbs) |
| Register FSM action callbacks (call once before first dispatch). | |
| void | arq_fsm_set_timing (arq_timing_ctx_t *timing) |
| Register timing context for recording (call once at init). | |
| void | arq_fsm_init (arq_session_t *sess) |
| Initialise a session structure to DISCONNECTED state. | |
| void | arq_fsm_release (arq_session_t *sess) |
| void | arq_fsm_dispatch (arq_session_t *sess, const arq_event_t *event) |
| Dispatch an event through both FSM levels. | |
| arq_listen_end_t | arq_fsm_dispatch_ends_listening (arq_session_t *sess, const arq_event_t *event) |
| arq_fsm_dispatch(), and whether that one event ended a spell of listening for calls (LISTENING or ACCEPTING, to any other state), and how. | |
| int | arq_fsm_timeout_ms (const arq_session_t *sess, uint64_t now) |
| Return milliseconds until the next deadline, or INT_MAX if idle. | |
| int | arq_call_carrier (const arq_session_t *sess) |
| The carrier the next CALL goes out on: the control mode for the first ARQ_CALL_FAST_SLOTS, then MFSK and the control mode alternately. | |
| bool | arq_fsm_expect_pattern (const arq_session_t *sess, uint64_t now) |
| Whether a pattern can arrive now (the modem's detector runs only then). | |
| int | arq_fsm_channel_keyed (const arq_session_t *sess) |
| Why the channel is busy now (a CAR_KEYED_* sign), 0 when clear: the listen-before-talk test the FSM keys by. | |
| const char * | arq_conn_state_name (arq_conn_state_t s) |
| Human-readable name for a connection state (for log output). | |
| bool | arq_conn_state_has_peer (arq_conn_state_t s) |
| The link to the peer exists: CONNECTED, or DISCONNECTING (the teardown is still an exchange with that peer). | |
| const char * | arq_event_name (arq_event_id_t ev) |
| Human-readable name for an event (for log output). | |
| enum arq_conn_state_t |
| enum arq_event_id_t |
| enum arq_listen_end_t |
| enum arq_teardown_t |
| int arq_call_carrier | ( | const arq_session_t * | sess | ) |
The carrier the next CALL goes out on: the control mode for the first ARQ_CALL_FAST_SLOTS, then MFSK and the control mode alternately.
| bool arq_conn_state_has_peer | ( | arq_conn_state_t | s | ) |
The link to the peer exists: CONNECTED, or DISCONNECTING (the teardown is still an exchange with that peer).
Energy on the channel in these states is the peer, not occupancy (the busy detector's mute, modem.c).
| const char * arq_conn_state_name | ( | arq_conn_state_t | s | ) |
Human-readable name for a connection state (for log output).
| const char * arq_event_name | ( | arq_event_id_t | ev | ) |
Human-readable name for an event (for log output).
| int arq_fsm_channel_keyed | ( | const arq_session_t * | sess | ) |
Why the channel is busy now (a CAR_KEYED_* sign), 0 when clear: the listen-before-talk test the FSM keys by.
| void arq_fsm_dispatch | ( | arq_session_t * | sess, |
| const arq_event_t * | event | ||
| ) |
Dispatch an event through both FSM levels.
Runs transition logic, calls action callbacks, and updates deadlines. Must be called from the single ARQ event-loop thread (no locking inside).
| sess | Active session. |
| event | Event to process. |
| arq_listen_end_t arq_fsm_dispatch_ends_listening | ( | arq_session_t * | sess, |
| const arq_event_t * | event | ||
| ) |
arq_fsm_dispatch(), and whether that one event ended a spell of listening for calls (LISTENING or ACCEPTING, to any other state), and how.
The MFSK call listeners must drop what they hold when such a spell ends – above all at a scanning host's LISTEN OFF, whose LISTEN ON follows within a millisecond, often in the same batch of events, and usually on another channel. Checked per event, so a spell that ends and restarts at once is still seen (arq.c counts them for the modem).
ARQ_LISTEN_ENDS_RELEASED is the hop itself: no session goes on, so the control and payload decoders can drop what they hold as well. In a session they cannot: the control decoder is carrying it.
| bool arq_fsm_expect_pattern | ( | const arq_session_t * | sess, |
| uint64_t | now | ||
| ) |
Whether a pattern can arrive now (the modem's detector runs only then).
| void arq_fsm_init | ( | arq_session_t * | sess | ) |
Initialise a session structure to DISCONNECTED state.
| sess | Session to initialise. |
| void arq_fsm_release | ( | arq_session_t * | sess | ) |
| void arq_fsm_set_callbacks | ( | const arq_fsm_callbacks_t * | cbs | ) |
Register FSM action callbacks (call once before first dispatch).
| void arq_fsm_set_timing | ( | arq_timing_ctx_t * | timing | ) |
Register timing context for recording (call once at init).
| timing | Pointer to the arq_timing_ctx_t to record into. |
| int arq_fsm_timeout_ms | ( | const arq_session_t * | sess, |
| uint64_t | now | ||
| ) |
Return milliseconds until the next deadline, or INT_MAX if idle.
Used by the event loop's blocking wait to set a poll timeout.
| sess | Active session. |
| now | Current monotonic time in milliseconds. |