HERMES Modem
Hermes ARQ/Broadcast modem
Loading...
Searching...
No Matches
Macros | Functions | Variables
arq_modem.c File Reference
#include "arq_modem.h"
#include "arq_protocol.h"
#include <pthread.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "../modem/freedv/freedv_api.h"
Include dependency graph for arq_modem.c:

Macros

#define MAX_QUEUE_CAPACITY   128
 

Functions

int arq_modem_queue_init (size_t capacity)
 Initialise the action queue.
 
void arq_modem_queue_shutdown (void)
 Flush and destroy the action queue.
 
int arq_modem_enqueue (const arq_action_t *action)
 Enqueue a modem action (called from FSM action callbacks).
 
bool arq_modem_dequeue (arq_action_t *action, int timeout_ms)
 Dequeue the next modem action (called from modem TX worker).
 
void arq_modem_set_event_fn (void(*fn)(int mode, bool ptt_on))
 Register the PTT event injection function (called from arq.c init).
 
void arq_modem_ptt_on (int mode, size_t frame_size)
 Notify ARQ that PTT has gone ON.
 
void arq_modem_ptt_off (void)
 Notify ARQ that PTT has gone OFF.
 
int arq_modem_preferred_rx_mode (const arq_session_t *sess)
 Return the preferred RX FreeDV mode for the current session state.
 
int arq_modem_preferred_tx_mode (const arq_session_t *sess)
 Return the preferred TX FreeDV mode for the current session state.
 

Variables

static arq_action_t g_queue [MAX_QUEUE_CAPACITY]
 
static size_t g_head
 
static size_t g_tail
 
static size_t g_count
 
static size_t g_cap
 
static pthread_mutex_t g_qmtx = PTHREAD_MUTEX_INITIALIZER
 
static pthread_cond_t g_qcond = PTHREAD_COND_INITIALIZER
 
static bool g_shutdown = false
 
static void(* g_inject_event )(int mode, bool ptt_on) = NULL
 

Macro Definition Documentation

◆ MAX_QUEUE_CAPACITY

#define MAX_QUEUE_CAPACITY   128

Function Documentation

◆ arq_modem_dequeue()

bool arq_modem_dequeue ( arq_action_t action,
int  timeout_ms 
)

Dequeue the next modem action (called from modem TX worker).

Blocks up to timeout_ms milliseconds waiting for an action.

Parameters
actionOutput action.
timeout_msWait timeout in milliseconds.
Returns
true if an action was dequeued, false on timeout.

◆ arq_modem_enqueue()

int arq_modem_enqueue ( const arq_action_t action)

Enqueue a modem action (called from FSM action callbacks).

Returns
0 on success, -1 if queue full.

◆ arq_modem_preferred_rx_mode()

int arq_modem_preferred_rx_mode ( const arq_session_t sess)

Return the preferred RX FreeDV mode for the current session state.

Parameters
sessCurrent session (read-only).
Returns
FREEDV_MODE_* constant.

◆ arq_modem_preferred_tx_mode()

int arq_modem_preferred_tx_mode ( const arq_session_t sess)

Return the preferred TX FreeDV mode for the current session state.

Parameters
sessCurrent session (read-only).
Returns
FREEDV_MODE_* constant.

◆ arq_modem_ptt_off()

void arq_modem_ptt_off ( void  )

Notify ARQ that PTT has gone OFF.

◆ arq_modem_ptt_on()

void arq_modem_ptt_on ( int  mode,
size_t  frame_size 
)

Notify ARQ that PTT has gone ON.

Parameters
modeFreeDV mode of the frame now on air.
frame_sizeFrame size in bytes.

◆ arq_modem_queue_init()

int arq_modem_queue_init ( size_t  capacity)

Initialise the action queue.

Parameters
capacityMaximum number of pending actions.
Returns
0 on success, -1 on allocation failure.

◆ arq_modem_queue_shutdown()

void arq_modem_queue_shutdown ( void  )

Flush and destroy the action queue.

◆ arq_modem_set_event_fn()

void arq_modem_set_event_fn ( void(*)(int mode, bool ptt_on)  fn)

Register the PTT event injection function (called from arq.c init).

Parameters
fnCallback: mode >= 0 and ptt_on=true → TX_STARTED; ptt_on=false → TX_COMPLETE.

Variable Documentation

◆ g_cap

size_t g_cap
static

◆ g_count

size_t g_count
static

◆ g_head

size_t g_head
static

◆ g_inject_event

void(* g_inject_event) (int mode, bool ptt_on) ( int  mode,
bool  ptt_on 
) = NULL
static

◆ g_qcond

pthread_cond_t g_qcond = PTHREAD_COND_INITIALIZER
static

◆ g_qmtx

pthread_mutex_t g_qmtx = PTHREAD_MUTEX_INITIALIZER
static

◆ g_queue

◆ g_shutdown

bool g_shutdown = false
static

◆ g_tail

size_t g_tail
static