HERMES Modem
Hermes ARQ/Broadcast modem
Loading...
Searching...
No Matches
arq_modem.h
Go to the documentation of this file.
1/* HERMES Modem — ARQ Modem interface: action queue and PTT callbacks
2 *
3 * Copyright (C) 2025 Rhizomatica
4 * Author: Rafael Diniz <rafael@riseup.net>
5 *
6 * SPDX-License-Identifier: GPL-3.0-or-later
7 */
8
9#ifndef ARQ_MODEM_H_
10#define ARQ_MODEM_H_
11
12#include <stdbool.h>
13#include <stddef.h>
14
15#include "arq.h" /* arq_action_t, arq_action_type_t */
16#include "arq_fsm.h" /* arq_session_t */
17
18/* ======================================================================
19 * Action queue (replaces arq_action_queue in old arq.c)
20 *
21 * The FSM enqueues TX actions; the modem worker dequeues them.
22 * Thread-safe: enqueue from event-loop thread, dequeue from modem thread.
23 * ====================================================================== */
24
30int arq_modem_queue_init(size_t capacity);
31
34
39int arq_modem_enqueue(const arq_action_t *action);
40
50bool arq_modem_dequeue(arq_action_t *action, int timeout_ms);
51
52/* ======================================================================
53 * PTT notifications (modem → ARQ)
54 *
55 * Called from the modem TX worker when PTT changes state.
56 * These generate ARQ_EV_TX_STARTED / ARQ_EV_TX_COMPLETE events and
57 * trigger the timing recorder.
58 * ====================================================================== */
59
64void arq_modem_set_event_fn(void (*fn)(int mode, bool ptt_on));
65
71void arq_modem_ptt_on(int mode, size_t frame_size);
72
76void arq_modem_ptt_off(void);
77
78/* ======================================================================
79 * Mode selection helpers
80 *
81 * Used by the modem worker to query preferred RX/TX modes.
82 * Delegated to arq_modem.c so mode-selection logic is co-located with
83 * the rest of the modem interface.
84 * ====================================================================== */
85
92
99
100#endif /* ARQ_MODEM_H_ */
void arq_modem_queue_shutdown(void)
Flush and destroy the action queue.
Definition arq_modem.c:47
int arq_modem_preferred_rx_mode(const arq_session_t *sess)
Return the preferred RX FreeDV mode for the current session state.
Definition arq_modem.c:163
void arq_modem_set_event_fn(void(*fn)(int mode, bool ptt_on))
Register the PTT event injection function (called from arq.c init).
Definition arq_modem.c:141
int arq_modem_enqueue(const arq_action_t *action)
Enqueue a modem action (called from FSM action callbacks).
Definition arq_modem.c:55
int arq_modem_queue_init(size_t capacity)
Initialise the action queue.
Definition arq_modem.c:34
bool arq_modem_dequeue(arq_action_t *action, int timeout_ms)
Dequeue the next modem action (called from modem TX worker).
Definition arq_modem.c:73
int arq_modem_preferred_tx_mode(const arq_session_t *sess)
Return the preferred TX FreeDV mode for the current session state.
Definition arq_modem.c:170
void arq_modem_ptt_off(void)
Notify ARQ that PTT has gone OFF.
Definition arq_modem.c:153
void arq_modem_ptt_on(int mode, size_t frame_size)
Notify ARQ that PTT has gone ON.
Definition arq_modem.c:146
Single modem action item popped by modem TX worker.
Definition arq.h:75
Definition arq_fsm.h:153