Mercury Modem
Mercury 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
74void arq_modem_set_channel_busy_fn(bool (*fn)(void));
75
77bool arq_modem_channel_busy(void);
78
88void arq_modem_set_crc_seed_fn(void (*fn)(uint16_t seed));
89void arq_modem_crc_seed(uint16_t seed);
90
96void arq_modem_ptt_on(int mode, size_t frame_size);
97
101void arq_modem_ptt_off(void);
102
103/* ======================================================================
104 * Mode selection helpers
105 *
106 * Used by the modem worker to query preferred RX/TX modes.
107 * Delegated to arq_modem.c so mode-selection logic is co-located with
108 * the rest of the modem interface.
109 * ====================================================================== */
110
117
124
125#endif /* ARQ_MODEM_H_ */
void arq_modem_queue_shutdown(void)
Flush and destroy the action queue.
Definition arq_modem.c:48
void arq_modem_crc_seed(uint16_t seed)
Definition arq_modem.c:177
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:200
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:151
int arq_modem_enqueue(const arq_action_t *action)
Enqueue a modem action (called from FSM action callbacks).
Definition arq_modem.c:65
bool arq_modem_channel_busy(void)
Is the channel occupied? false when no probe is registered.
Definition arq_modem.c:164
int arq_modem_queue_init(size_t capacity)
Initialise the action queue.
Definition arq_modem.c:35
void arq_modem_set_channel_busy_fn(bool(*fn)(void))
Register the station's channel-occupancy probe.
Definition arq_modem.c:159
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:83
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:207
void arq_modem_ptt_off(void)
Notify ARQ that PTT has gone OFF.
Definition arq_modem.c:190
void arq_modem_ptt_on(int mode, size_t frame_size)
Notify ARQ that PTT has gone ON.
Definition arq_modem.c:183
void arq_modem_set_crc_seed_fn(void(*fn)(uint16_t seed))
Register the modem's session-seed setter (carousel data plane).
Definition arq_modem.c:172
int mode
Definition carousel.c:2330
Single modem action item popped by modem TX worker.
Definition arq.h:112
Definition arq_fsm.h:127