summaryrefslogtreecommitdiff
path: root/include/hybbx/traffic.h
blob: 8d06cf3ab68a4584718d7baa5cab3edc1922c1d0 (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
#ifndef HYBBX_TRAFFIC_H
#define HYBBX_TRAFFIC_H

#include "hybbx/types.h"

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

struct hybbx_config;
struct hybbx_session;

/** Host link speed HyBBX is optimized for (8N1, ~1 byte per 10 bit times). */
#define HYBBX_BAUD2400 2400u

/** Default terminal width (columns). */
#define HYBBX_LINE_WIDTH 80u

/** Maximum configurable `line_width` in INI. */
#define HYBBX_LINE_WIDTH_MAX 132u

/** Maximum user input line (commands / chat). */
#define HYBBX_LINE_MAX 80u

/** Typical AX.25 UI payload ceiling used for outbound chunk sizing. */
#define HYBBX_AX25_PAYLOAD_MAX 256u

typedef struct hybbx_traffic_config {
    unsigned baud;
    unsigned line_width;
    int pace_output;
    int ansi;
    int input_echo;
} hybbx_traffic_config_t;

void hybbx_traffic_config_defaults(hybbx_traffic_config_t *cfg);
void hybbx_traffic_config_apply(const struct hybbx_config *config);
const hybbx_traffic_config_t *hybbx_traffic_config_get(void);

/**
 * Microseconds to wait after one 8N1 byte at @p baud (0 when pacing is off).
 */
unsigned hybbx_traffic_byte_delay_us(unsigned baud);

/**
 * Emit @p data to @p session with plain-ASCII policy, column wrap, and pacing.
 * @p out_col is updated (wrap position on the current output line).
 */
hybbx_result_t hybbx_traffic_emit(struct hybbx_session *session,
                                  unsigned *out_col,
                                  const char *data, size_t len);

#ifdef __cplusplus
}
#endif

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

info@mode42.com