blob: 77666d97f016c7cd0bbe2adddd1d6e703597a84e [file] [log] [blame]
Harald Welte7f26f552018-02-23 09:38:15 +01001module TRXC_Types {
2
3import from Osmocom_Types all;
4
5type charstring TrxcType ("CMD", "RSP", "IND") with {
6 variant "TEXT_CODING(,convert=upper_case,'((CMD)|(RSP)|(IND))',case_insensitive)"
7}
8
9type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK",
10 "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", "SETPOWER",
11 "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", "NOHANDOVER",
Harald Welteef3e1c92018-02-28 23:40:14 +010012 "MEASURE", "FAKE_RSSI", "FAKE_TOA" ) with {
Harald Welte7f26f552018-02-23 09:38:15 +010013 variant "TEXT_CODING(,convert=upper_case,
Harald Welteef3e1c92018-02-28 23:40:14 +010014 '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TOA))'
Harald Welte7f26f552018-02-23 09:38:15 +010015 ,case_insensitive)"
16}
17
18type integer TrxcStatus;
19type charstring TrxcParam;
Harald Welteef3e1c92018-02-28 23:40:14 +010020type record of TrxcParam TrxcParams with {
21 variant "SEPARATOR(' ', ' ')"
22}
Harald Welte7f26f552018-02-23 09:38:15 +010023
24type record TrxcCommand {
25 TrxcVerb verb,
26 TrxcParams params optional
27} with {
28 variant "SEPARATOR(' ', ' ')"
29}
30
31type record TrxcResponse {
32 TrxcVerb verb,
33 TrxcStatus status,
34 TrxcParams params optional
35} with {
36 variant "SEPARATOR(' ', ' ')"
37}
38
39type record TrxcIndication {
40 TrxcVerb verb,
41 TrxcParams params optional
42} with {
43 variant "SEPARATOR(' ', ' ')"
44}
45
46type union TrxcMessage {
47 TrxcCommand cmd,
48 TrxcResponse rsp,
49 TrxcIndication ind
50} with {
51 variant (cmd) "BEGIN('CMD ')"
52 variant (rsp) "BEGIN('RSP ')"
53 variant (ind) "BEGIN('IND ')"
54}
55
56external function enc_TrxcMessage(in TrxcMessage id) return charstring
57 with { extension "prototype(convert) encode(TEXT)" };
58external function dec_TrxcMessage(in charstring id) return TrxcMessage
59 with { extension "prototype(convert) decode(TEXT)" };
60
Vadim Yanitskiya201b972018-10-23 00:09:32 +020061template (value) TrxcMessage ts_TRXC_FAKE_RSSI(uint8_t rssi, int16_t thresh := 0) := {
Harald Welte7f26f552018-02-23 09:38:15 +010062 cmd := {
63 verb := "FAKE_RSSI",
Vadim Yanitskiya201b972018-10-23 00:09:32 +020064 params := { int2str(rssi), int2str(thresh) }
Harald Welte7f26f552018-02-23 09:38:15 +010065 }
66}
67
Harald Welteef3e1c92018-02-28 23:40:14 +010068template (value) TrxcMessage ts_TRXC_FAKE_TIMING(int16_t timing, int16_t thresh := 0) := {
Harald Welte7f26f552018-02-23 09:38:15 +010069 cmd := {
Harald Welteef3e1c92018-02-28 23:40:14 +010070 verb := "FAKE_TOA",
71 params := { int2str(timing), int2str(thresh) }
Harald Welte7f26f552018-02-23 09:38:15 +010072 }
73}
74
75
76} with { encode "TEXT" }