summaryrefslogtreecommitdiff
path: root/include/hybbx/broadcast.h
blob: a4002b703779c8a991698909fe85f4e6996d6059 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef HYBBX_BROADCAST_H
#define HYBBX_BROADCAST_H

/**
 * HyBBX broadcast — Main instance only.
 *
 * User command `/broadcast` (alias `/announce`): instant `+++` message to every
 * online local user session on this Main (telnet/SSH/WebSocket).
 * Format: `+++ <from>: <message>` (manual Sysop/grant announce).
 * Automatic system notices use `***` instead.
 *
 * `/broadcast ax25`: manual instant RF beacon — ax25_auto_message to each
 * qualifying packet-radio link sequentially (no custom RF text).
 *
 * INI `[broadcast]` ax25_auto: periodic AX.25 QST UI beacon over HBX to
 * Secondary extenders (low-bandwidth + half-duplex links). Separate from
 * `/broadcast`; not a user command. One sequential cycle per interval (min
 * 900 s); 180 s own-channel idle before each link TX; 180 s between links;
 * per-link min 900 s. Busy channel defers until idle.
 */

#include "hybbx/ax25.h"
#include "hybbx/config.h"
#include "hybbx/limits.h"
#include "hybbx/types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define HYBBX_AX25_FREQUENCY_MAX      40u
/** Local Main announce message cap. */
#define HYBBX_BROADCAST_MESSAGE_MAX   240u

#define HYBBX_BROADCAST_AUTO_MESSAGE_DEFAULT "Broadcast: @service@ online"

typedef struct hybbx_ax25_frequency_table {
    unsigned count;
    double mhz[HYBBX_AX25_FREQUENCY_MAX];
    char labels[HYBBX_AX25_FREQUENCY_MAX][32];
} hybbx_ax25_frequency_table_t;

typedef struct hybbx_broadcast_config {
    int enabled;
    int ax25_enabled;
    int ax25_auto;
    unsigned ax25_auto_interval_sec;
    /** Ignored (legacy INI); links always send sequentially with link gap. */
    unsigned ax25_auto_stagger_sec;
    char ax25_mycall[HYBBX_AX25_CALL_MAX + 1];
    char ax25_dest[HYBBX_AX25_CALL_MAX + 1];
    char ax25_auto_message[HYBBX_BROADCAST_AX25_MESSAGE_MAX + 1];
    hybbx_ax25_frequency_table_t frequencies;
} hybbx_broadcast_config_t;

struct hybbx_service;
struct hybbx_session;

void hybbx_ax25_frequency_table_clear(hybbx_ax25_frequency_table_t *table);

/** Load `[ax25]` frequency1 … frequencyN (MHz) and optional labels. */
void hybbx_ax25_frequency_apply(hybbx_ax25_frequency_table_t *table,
                                const hybbx_config_t *config);

/** Compare two MHz values (tolerance for INI rounding). */
int hybbx_ax25_frequency_match(double a_mhz, double b_mhz);

void hybbx_broadcast_config_defaults(hybbx_broadcast_config_t *cfg);

/** Load `[broadcast]` + `[ax25]` from INI. */
void hybbx_broadcast_config_apply(hybbx_broadcast_config_t *cfg,
                                  const hybbx_config_t *config);

const hybbx_broadcast_config_t *hybbx_service_get_broadcast(
    const struct hybbx_service *service);

/**
 * Send @p message to every online local user on this Main (Sysop `/broadcast`).
 */
hybbx_result_t hybbx_broadcast_announce(struct hybbx_service *service,
                                        struct hybbx_session *from,
                                        const char *message);

/**
 * Manual AX.25 beacon (Sysop `/broadcast ax25`): INI ax25_auto_message to each
 * qualifying link immediately, one after another. No custom RF text.
 */
hybbx_result_t hybbx_broadcast_ax25_manual(struct hybbx_service *service);

/**
 * AX.25 auto-beacon over HBX (INI ax25_auto only).
 * Link must be low-bandwidth and half-duplex (QoS).
 */
hybbx_result_t hybbx_broadcast_ax25(struct hybbx_service *service,
                                    double frequency_mhz,
                                    const char *message);

/**
 * Periodic AX.25 auto-beacon (call once per second from Main service loop).
 */
void hybbx_broadcast_ax25_tick(struct hybbx_service *service);

/** Abort an in-flight sequential AX.25 cycle (hub stop / shutdown). */
void hybbx_broadcast_ax25_seq_cancel(void);

#ifdef __cplusplus
}
#endif

#endif /* HYBBX_BROADCAST_H */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com