HERMES Modem
Hermes ARQ/Broadcast modem
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
arq.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "fsm.h"
#include "arq_events.h"
Include dependency graph for arq.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arq_info
 Runtime ARQ connection and mode state shared across modules. More...
 
struct  arq_action_t
 Single modem action item popped by modem TX worker. More...
 
struct  arq_runtime_snapshot_t
 Snapshot of current ARQ runtime state for telemetry/decision making. More...
 

Macros

#define CALLSIGN_MAX_SIZE   16
 
#define RX   0
 
#define TX   1
 
#define HEADER_SIZE   1
 
#define PACKET_ARQ_CONTROL   0x00
 
#define PACKET_ARQ_DATA   0x01
 
#define PACKET_ARQ_CALL   0x02
 
#define PACKET_BROADCAST_CONTROL   0x03
 
#define PACKET_BROADCAST_PAYLOAD   0x04
 

Enumerations

enum  arq_action_type_t { ARQ_ACTION_NONE = 0 , ARQ_ACTION_TX_CONTROL = 1 , ARQ_ACTION_TX_PAYLOAD = 2 , ARQ_ACTION_MODE_SWITCH = 3 }
 Action types emitted by ARQ for modem worker execution. More...
 

Functions

int arq_init (size_t frame_size, int mode)
 Initialize ARQ subsystem.
 
void arq_shutdown ()
 Shut down ARQ workers and release ARQ resources.
 
void arq_tick_1hz (void)
 Execute 1 Hz ARQ maintenance tick.
 
void arq_post_event (int event)
 Post an FSM event to ARQ.
 
bool arq_is_link_connected (void)
 Check whether ARQ link is connected.
 
int arq_queue_data (const uint8_t *data, size_t len)
 Queue outbound payload bytes for ARQ transmission.
 
int arq_get_tx_backlog_bytes (void)
 Get pending outbound payload backlog.
 
int arq_get_speed_level (void)
 Get current ARQ speed level (gear).
 
int arq_get_payload_mode (void)
 Get active ARQ payload mode.
 
int arq_get_control_mode (void)
 Get active ARQ control mode.
 
int arq_get_preferred_rx_mode (void)
 Get ARQ-preferred receive mode for modem.
 
int arq_get_preferred_tx_mode (void)
 Get ARQ-preferred transmit mode for modem.
 
void arq_set_active_modem_mode (int mode, size_t frame_size)
 Inform ARQ of modem mode/frame size actually active in modem.
 
bool arq_handle_incoming_connect_frame (uint8_t *data, size_t frame_size)
 Handle incoming compressed CALL/ACCEPT frame.
 
void arq_handle_incoming_frame (uint8_t *data, size_t frame_size, float rx_snr)
 Handle incoming regular ARQ control/data frame.
 
void arq_update_link_metrics (int sync, float snr, int rx_status, bool frame_decoded)
 Feed decoder/link metrics into ARQ adaptation.
 
bool arq_try_dequeue_action (arq_action_t *action)
 Try to dequeue next modem action without blocking.
 
bool arq_wait_dequeue_action (arq_action_t *action, int timeout_ms)
 Wait for next modem action.
 
bool arq_get_runtime_snapshot (arq_runtime_snapshot_t *snapshot)
 Copy ARQ runtime snapshot.
 
int arq_submit_tcp_cmd (const arq_cmd_msg_t *cmd)
 Submit parsed control command from TCP bridge to ARQ.
 
int arq_submit_tcp_payload (const uint8_t *data, size_t len)
 Submit payload bytes from TCP bridge to ARQ.
 
void clear_connection_data ()
 Clear legacy ARQ connection state and buffers.
 
void reset_arq_info (arq_info *arq_conn)
 Reset external arq_info structure.
 
void call_remote ()
 Trigger outgoing call attempt using current ARQ addresses.
 
void callee_accept_connection ()
 Trigger callee-side accept flow in compatibility path.
 

Variables

arq_info arq_conn
 
fsm_handle arq_fsm
 

Macro Definition Documentation

◆ CALLSIGN_MAX_SIZE

#define CALLSIGN_MAX_SIZE   16

◆ HEADER_SIZE

#define HEADER_SIZE   1

◆ PACKET_ARQ_CALL

#define PACKET_ARQ_CALL   0x02

◆ PACKET_ARQ_CONTROL

#define PACKET_ARQ_CONTROL   0x00

◆ PACKET_ARQ_DATA

#define PACKET_ARQ_DATA   0x01

◆ PACKET_BROADCAST_CONTROL

#define PACKET_BROADCAST_CONTROL   0x03

◆ PACKET_BROADCAST_PAYLOAD

#define PACKET_BROADCAST_PAYLOAD   0x04

◆ RX

#define RX   0

◆ TX

#define TX   1

Enumeration Type Documentation

◆ arq_action_type_t

Action types emitted by ARQ for modem worker execution.

Enumerator
ARQ_ACTION_NONE 
ARQ_ACTION_TX_CONTROL 
ARQ_ACTION_TX_PAYLOAD 
ARQ_ACTION_MODE_SWITCH 

Function Documentation

◆ arq_get_control_mode()

int arq_get_control_mode ( void  )

Get active ARQ control mode.

Returns
FreeDV control mode value.

◆ arq_get_payload_mode()

int arq_get_payload_mode ( void  )

Get active ARQ payload mode.

Returns
FreeDV payload mode value.

◆ arq_get_preferred_rx_mode()

int arq_get_preferred_rx_mode ( void  )

Get ARQ-preferred receive mode for modem.

Returns
FreeDV mode value.

◆ arq_get_preferred_tx_mode()

int arq_get_preferred_tx_mode ( void  )

Get ARQ-preferred transmit mode for modem.

Returns
FreeDV mode value.

◆ arq_get_runtime_snapshot()

bool arq_get_runtime_snapshot ( arq_runtime_snapshot_t snapshot)

Copy ARQ runtime snapshot.

Parameters
snapshotOutput snapshot pointer.
Returns
true when snapshot contains initialized state.

◆ arq_get_speed_level()

int arq_get_speed_level ( void  )

Get current ARQ speed level (gear).

Returns
Speed level index.

◆ arq_get_tx_backlog_bytes()

int arq_get_tx_backlog_bytes ( void  )

Get pending outbound payload backlog.

Returns
Backlog size in bytes.

◆ arq_handle_incoming_connect_frame()

bool arq_handle_incoming_connect_frame ( uint8_t *  data,
size_t  frame_size 
)

Handle incoming compressed CALL/ACCEPT frame.

Parameters
dataFrame bytes.
frame_sizeFrame length in bytes.
Returns
true if frame was handled by ARQ connect path.

◆ arq_handle_incoming_frame()

void arq_handle_incoming_frame ( uint8_t *  data,
size_t  frame_size,
float  rx_snr 
)

Handle incoming regular ARQ control/data frame.

Parameters
dataFrame bytes.
frame_sizeFrame length in bytes.
rx_snrLocal receive SNR at decode time (dB); 0.0 = unknown.

◆ arq_init()

int arq_init ( size_t  frame_size,
int  mode 
)

Initialize ARQ subsystem.

Parameters
frame_sizeActive modem frame size in bytes.
modeInitial modem mode.
Returns
0 on success, non-zero on failure.

◆ arq_is_link_connected()

bool arq_is_link_connected ( void  )

Check whether ARQ link is connected.

Returns
true when connected; otherwise false.

◆ arq_post_event()

void arq_post_event ( int  event)

Post an FSM event to ARQ.

Parameters
eventEvent identifier from fsm.h.

◆ arq_queue_data()

int arq_queue_data ( const uint8_t *  data,
size_t  len 
)

Queue outbound payload bytes for ARQ transmission.

Parameters
dataPointer to payload bytes.
lenNumber of bytes to queue.
Returns
Number of bytes queued, or negative on error.

◆ arq_set_active_modem_mode()

void arq_set_active_modem_mode ( int  mode,
size_t  frame_size 
)

Inform ARQ of modem mode/frame size actually active in modem.

Parameters
modeActive FreeDV mode.
frame_sizeActive frame size in bytes.

◆ arq_shutdown()

void arq_shutdown ( )

Shut down ARQ workers and release ARQ resources.

◆ arq_submit_tcp_cmd()

int arq_submit_tcp_cmd ( const arq_cmd_msg_t cmd)

Submit parsed control command from TCP bridge to ARQ.

Parameters
cmdCommand message.
Returns
0 on success, negative on queue/error.

◆ arq_submit_tcp_payload()

int arq_submit_tcp_payload ( const uint8_t *  data,
size_t  len 
)

Submit payload bytes from TCP bridge to ARQ.

Parameters
dataPayload bytes.
lenPayload length in bytes.
Returns
0 on success, negative on queue/error.

◆ arq_tick_1hz()

void arq_tick_1hz ( void  )

Execute 1 Hz ARQ maintenance tick.

◆ arq_try_dequeue_action()

bool arq_try_dequeue_action ( arq_action_t action)

Try to dequeue next modem action without blocking.

Parameters
actionOutput action item.
Returns
true if an action was dequeued.

◆ arq_update_link_metrics()

void arq_update_link_metrics ( int  sync,
float  snr,
int  rx_status,
bool  frame_decoded 
)

Feed decoder/link metrics into ARQ adaptation.

Parameters
syncDecoder sync flag.
snrEstimated SNR.
rx_statusDecoder RX status flags.
frame_decodedTrue when a frame decoded this cycle.

◆ arq_wait_dequeue_action()

bool arq_wait_dequeue_action ( arq_action_t action,
int  timeout_ms 
)

Wait for next modem action.

Parameters
actionOutput action item.
timeout_msWait timeout in milliseconds.
Returns
true if an action was dequeued.

◆ call_remote()

void call_remote ( )

Trigger outgoing call attempt using current ARQ addresses.

◆ callee_accept_connection()

void callee_accept_connection ( )

Trigger callee-side accept flow in compatibility path.

◆ clear_connection_data()

void clear_connection_data ( )

Clear legacy ARQ connection state and buffers.

◆ reset_arq_info()

void reset_arq_info ( arq_info arq_conn)

Reset external arq_info structure.

Parameters
arq_connPointer to structure to reset.

Variable Documentation

◆ arq_conn

arq_info arq_conn
extern

◆ arq_fsm

fsm_handle arq_fsm
extern