libosmo-trx 1.8.0.50-7f5e
Osmocom TRX protocol (TRXC/TRXD) library
trxc.h
Go to the documentation of this file.
1
3#pragma once
4
5#include <stdint.h>
6#include <stddef.h>
7#include <stdbool.h>
8
9#include <osmocom/core/utils.h>
10
12#define OSMO_TRXC_CMD_LEN_MAX 32
14#define OSMO_TRXC_MSG_BUF_SIZE 1500
20#define OSMO_TRXC_PARAMS_LEN_MAX (OSMO_TRXC_MSG_BUF_SIZE - OSMO_TRXC_CMD_LEN_MAX - 32)
21
26};
27
35 int status;
37};
38
39int osmo_trxc_msg_parse(struct osmo_trxc_msg *msg, const char *buf, size_t len);
40int osmo_trxc_msg_build(char *buf, size_t buf_size, const struct osmo_trxc_msg *msg);
41int osmo_trxc_msg_params_scan(const struct osmo_trxc_msg *msg, const char *fmt, ...);
42
43const char *osmo_trxc_msg_name(const struct osmo_trxc_msg *msg);
44char *osmo_trxc_msg_name_buf(char *buf, size_t buf_size,
45 const struct osmo_trxc_msg *msg);
46
47/* Well-known command verbs (the codec itself is verb-agnostic) */
48#define OSMO_TRXC_CMD_POWERON "POWERON"
49#define OSMO_TRXC_CMD_POWEROFF "POWEROFF"
50#define OSMO_TRXC_CMD_RXTUNE "RXTUNE"
51#define OSMO_TRXC_CMD_TXTUNE "TXTUNE"
52#define OSMO_TRXC_CMD_SETSLOT "SETSLOT"
53#define OSMO_TRXC_CMD_SETTSC "SETTSC"
54#define OSMO_TRXC_CMD_SETBSIC "SETBSIC"
55#define OSMO_TRXC_CMD_SETPOWER "SETPOWER"
56#define OSMO_TRXC_CMD_ADJPOWER "ADJPOWER"
57#define OSMO_TRXC_CMD_NOMTXPOWER "NOMTXPOWER"
58#define OSMO_TRXC_CMD_SETRXGAIN "SETRXGAIN"
59#define OSMO_TRXC_CMD_SETMAXDLY "SETMAXDLY"
60#define OSMO_TRXC_CMD_SETMAXDLYNB "SETMAXDLYNB"
61#define OSMO_TRXC_CMD_SETFORMAT "SETFORMAT"
62#define OSMO_TRXC_CMD_HANDOVER "HANDOVER"
63#define OSMO_TRXC_CMD_NOHANDOVER "NOHANDOVER"
64#define OSMO_TRXC_CMD_RFMUTE "RFMUTE"
65#define OSMO_TRXC_CMD_NOISELEV "NOISELEV"
66#define OSMO_TRXC_CMD_SETFH "SETFH"
67#define OSMO_TRXC_CMD_ERR "ERR"
69/* SETSLOT: "<tn> <chan_comb> [C<tsc>/S<tsc_set> ...]" */
70
88};
89
90extern const struct value_string osmo_trxc_chan_comb_names[];
91static inline const char *osmo_trxc_chan_comb_name(enum osmo_trxc_chan_comb comb)
92{
93 return get_value_string(osmo_trxc_chan_comb_names, comb);
94}
95
103};
104
105extern const struct value_string osmo_trxc_vamos_comb_names[];
106static inline const char *osmo_trxc_vamos_comb_name(enum osmo_trxc_vamos_comb comb)
107{
108 return get_value_string(osmo_trxc_vamos_comb_names, comb);
109}
110
111#define OSMO_TRXC_SETSLOT_TSC_MAX 3
116 uint8_t tsc;
117 uint8_t tsc_set;
118};
119
122 uint8_t tn;
123 bool vamos;
124 union {
127 };
128 unsigned int num_tsc;
130};
131
132int osmo_trxc_setslot_parse(struct osmo_trxc_setslot *ss, const struct osmo_trxc_msg *msg);
133int osmo_trxc_setslot_build(char *buf, size_t buf_size, const struct osmo_trxc_setslot *ss);
134
135/* Clock socket: "IND CLOCK <fn>" */
136int osmo_trxc_clock_ind_parse(uint32_t *fn, const char *buf, size_t len);
137int osmo_trxc_clock_ind_build(char *buf, size_t buf_size, uint32_t fn);
A single de-/serialized TRXC message.
Definition: trxc.h:32
int status
RSP only.
Definition: trxc.h:35
enum osmo_trxc_msg_type type
Definition: trxc.h:33
char params[OSMO_TRXC_PARAMS_LEN_MAX]
raw parameters, may be ""
Definition: trxc.h:36
char cmd[OSMO_TRXC_CMD_LEN_MAX]
verb, e.g.
Definition: trxc.h:34
One "C<tsc>/S<tsc_set>" override, as used by SETSLOT for (VAMOS) sub-channels that don't use the endp...
Definition: trxc.h:115
uint8_t tsc_set
Definition: trxc.h:117
uint8_t tsc
Definition: trxc.h:116
Parsed SETSLOT parameters.
Definition: trxc.h:121
unsigned int num_tsc
number of valid entries in tsc[]
Definition: trxc.h:128
enum osmo_trxc_vamos_comb vamos_comb
Definition: trxc.h:126
bool vamos
false: chan_comb is valid, true: vamos_comb is valid
Definition: trxc.h:123
enum osmo_trxc_chan_comb chan_comb
Definition: trxc.h:125
uint8_t tn
Definition: trxc.h:122
struct osmo_trxc_setslot_tsc tsc[OSMO_TRXC_SETSLOT_TSC_MAX]
Definition: trxc.h:129
char * osmo_trxc_msg_name_buf(char *buf, size_t buf_size, const struct osmo_trxc_msg *msg)
Compose a human-readable representation of the given message (for logging), store into the given buff...
Definition: trxc.c:193
static const char * osmo_trxc_vamos_comb_name(enum osmo_trxc_vamos_comb comb)
Definition: trxc.h:106
int osmo_trxc_clock_ind_parse(uint32_t *fn, const char *buf, size_t len)
Parse a clock indication ("IND CLOCK <fn>").
Definition: trxc.c:287
const struct value_string osmo_trxc_vamos_comb_names[]
Definition: trxc.c:65
#define OSMO_TRXC_SETSLOT_TSC_MAX
up to 3 sub-channels (VAMOS "HVHH")
Definition: trxc.h:111
int osmo_trxc_msg_build(char *buf, size_t buf_size, const struct osmo_trxc_msg *msg)
Serialize a TRXC message into the given buffer (zero-terminated).
Definition: trxc.c:137
int osmo_trxc_msg_params_scan(const struct osmo_trxc_msg *msg, const char *fmt,...)
Parse the parameters string of a TRXC message, sscanf() style.
Definition: trxc.c:165
int osmo_trxc_setslot_build(char *buf, size_t buf_size, const struct osmo_trxc_setslot *ss)
Serialize SETSLOT parameters ("<tn> <chan_comb> [C<tsc>/S<tsc_set> ...]") into the given buffer (zero...
Definition: trxc.c:254
#define OSMO_TRXC_CMD_LEN_MAX
Maximum length of a command verb (incl.
Definition: trxc.h:12
int osmo_trxc_msg_parse(struct osmo_trxc_msg *msg, const char *buf, size_t len)
Parse a TRXC message ("CMD <verb> [<params>]", "RSP <verb> <status> [<params>]" or "IND <verb> <param...
Definition: trxc.c:79
static const char * osmo_trxc_chan_comb_name(enum osmo_trxc_chan_comb comb)
Definition: trxc.h:91
int osmo_trxc_setslot_parse(struct osmo_trxc_setslot *ss, const struct osmo_trxc_msg *msg)
Parse SETSLOT parameters ("<tn> <chan_comb> [C<tsc>/S<tsc_set> ...]") from an already-parsed TRXC mes...
Definition: trxc.c:202
osmo_trxc_vamos_comb
VAMOS-enabled channel combinations: the chan_comb parameter of SETSLOT is symbolic (not numeric) for ...
Definition: trxc.h:98
@ OSMO_TRXC_VAMOS_COMB_HVHH
TCH/H0 + V0(TCH/H1) & V1(TCH/H1) (mixed)
Definition: trxc.h:102
@ OSMO_TRXC_VAMOS_COMB_VFH
V0(TCH/F) & V1(TCH/H0) + V0(TCH/F) & V1(TCH/H1)
Definition: trxc.h:101
@ OSMO_TRXC_VAMOS_COMB_VHH
V0(TCH/H0)&V1(TCH/H0) + V0(TCH/H1)&V1(TCH/H1)
Definition: trxc.h:100
@ OSMO_TRXC_VAMOS_COMB_VFF
V0(TCH/F) & V1(TCH/F)
Definition: trxc.h:99
int osmo_trxc_clock_ind_build(char *buf, size_t buf_size, uint32_t fn)
Serialize a clock indication ("IND CLOCK <fn>") into the given buffer.
Definition: trxc.c:310
const struct value_string osmo_trxc_chan_comb_names[]
Definition: trxc.c:47
#define OSMO_TRXC_PARAMS_LEN_MAX
Maximum length of the parameters string (incl.
Definition: trxc.h:20
osmo_trxc_msg_type
Definition: trxc.h:22
@ OSMO_TRXC_MT_CMD
"CMD <verb> [<params>]" (L1 -> TRX)
Definition: trxc.h:23
@ OSMO_TRXC_MT_IND
"IND <verb> <params>" (TRX -> L1)
Definition: trxc.h:25
@ OSMO_TRXC_MT_RSP
"RSP <verb> <status> [<params>]" (TRX -> L1)
Definition: trxc.h:24
const char * osmo_trxc_msg_name(const struct osmo_trxc_msg *msg)
Compose a human-readable representation of the given message (for logging), store into a thread-local...
Definition: trxc.c:181
osmo_trxc_chan_comb
Classic (non-VAMOS) GSM TS 05.02 channel combinations, as used by the chan_comb parameter of SETSLOT.
Definition: trxc.h:73
@ OSMO_TRXC_CHAN_COMB_BCCH_SDCCH4
DL: +SDCCH/4+SACCH/4, UL: +SDCCH/4.
Definition: trxc.h:79
@ OSMO_TRXC_CHAN_COMB_BCCH
DL: FCCH+SCH+CCCH+BCCH, UL: RACH.
Definition: trxc.h:78
@ OSMO_TRXC_CHAN_COMB_CCCH
DL: CCCH+BCCH, UL: RACH.
Definition: trxc.h:80
@ OSMO_TRXC_CHAN_COMB_TCHH
Definition: trxc.h:77
@ OSMO_TRXC_CHAN_COMB_TCHF_SACCHM
Definition: trxc.h:83
@ OSMO_TRXC_CHAN_COMB_TCHF_FACCH_SACCHM
Definition: trxc.h:82
@ OSMO_TRXC_CHAN_COMB_PDTCH
PDTCH+PACCH+PTCCH.
Definition: trxc.h:87
@ OSMO_TRXC_CHAN_COMB_SDCCH8
SDCCH/8 + SACCH/8.
Definition: trxc.h:81
@ OSMO_TRXC_CHAN_COMB_UNUSED
Channel is transmitted, but unused.
Definition: trxc.h:74
@ OSMO_TRXC_CHAN_COMB_PCCCH
PCCCH+PDTCH+PACCH+PTCCH.
Definition: trxc.h:86
@ OSMO_TRXC_CHAN_COMB_TCHH_IDLE
TCH/HS, idle every other slot.
Definition: trxc.h:76
@ OSMO_TRXC_CHAN_COMB_PBCCH
PBCCH+PCCCH+PDTCH+PACCH+PTCCH.
Definition: trxc.h:85
@ OSMO_TRXC_CHAN_COMB_TCHFD_SACCHMD
Definition: trxc.h:84
@ OSMO_TRXC_CHAN_COMB_TCHF
Definition: trxc.h:75