blob: aaa58eec06ddd08dbad350f7006b2e5afa294c7e [file] [log] [blame]
Harald Welte7f26f552018-02-23 09:38:15 +01001module TRXC_Types {
2
Harald Welte34b5a952019-05-27 11:54:11 +02003/* TRX Control protocol type definitions in TTCN-3
4 * (C) 2018 Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
Harald Welte7f26f552018-02-23 09:38:15 +010013import from Osmocom_Types all;
14
15type charstring TrxcType ("CMD", "RSP", "IND") with {
16 variant "TEXT_CODING(,convert=upper_case,'((CMD)|(RSP)|(IND))',case_insensitive)"
17}
18
19type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK",
20 "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", "SETPOWER",
21 "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", "NOHANDOVER",
Vadim Yanitskiy42525ac2021-10-03 14:00:40 +060022 "MEASURE", "FAKE_RSSI", "FAKE_TOA", "FAKE_CI", "FAKE_TRXC_DELAY") with {
Harald Welte7f26f552018-02-23 09:38:15 +010023 variant "TEXT_CODING(,convert=upper_case,
Vadim Yanitskiy42525ac2021-10-03 14:00:40 +060024 '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TOA)|(FAKE_CI)|(FAKE_TRXC_DELAY))'
Harald Welte7f26f552018-02-23 09:38:15 +010025 ,case_insensitive)"
26}
27
28type integer TrxcStatus;
29type charstring TrxcParam;
Harald Welteef3e1c92018-02-28 23:40:14 +010030type record of TrxcParam TrxcParams with {
31 variant "SEPARATOR(' ', ' ')"
32}
Harald Welte7f26f552018-02-23 09:38:15 +010033
34type record TrxcCommand {
35 TrxcVerb verb,
36 TrxcParams params optional
37} with {
38 variant "SEPARATOR(' ', ' ')"
39}
40
41type record TrxcResponse {
42 TrxcVerb verb,
43 TrxcStatus status,
44 TrxcParams params optional
45} with {
46 variant "SEPARATOR(' ', ' ')"
47}
48
49type record TrxcIndication {
50 TrxcVerb verb,
51 TrxcParams params optional
52} with {
53 variant "SEPARATOR(' ', ' ')"
54}
55
56type union TrxcMessage {
57 TrxcCommand cmd,
58 TrxcResponse rsp,
59 TrxcIndication ind
60} with {
61 variant (cmd) "BEGIN('CMD ')"
62 variant (rsp) "BEGIN('RSP ')"
63 variant (ind) "BEGIN('IND ')"
64}
65
66external function enc_TrxcMessage(in TrxcMessage id) return charstring
67 with { extension "prototype(convert) encode(TEXT)" };
68external function dec_TrxcMessage(in charstring id) return TrxcMessage
69 with { extension "prototype(convert) decode(TEXT)" };
70
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +070071/* rxlev2dbm(0..63) gives us [-110..-47], plus -10 dbm for noise */
72type integer TRXC_RSSI (-120..-47);
73type integer TRXC_RSSI_THRESH (-120..120);
74
75template (value) TrxcMessage ts_TRXC_FAKE_RSSI(TRXC_RSSI rssi, TRXC_RSSI_THRESH thresh := 0) := {
Harald Welte7f26f552018-02-23 09:38:15 +010076 cmd := {
77 verb := "FAKE_RSSI",
Vadim Yanitskiya201b972018-10-23 00:09:32 +020078 params := { int2str(rssi), int2str(thresh) }
Harald Welte7f26f552018-02-23 09:38:15 +010079 }
80}
81
Harald Welteef3e1c92018-02-28 23:40:14 +010082template (value) TrxcMessage ts_TRXC_FAKE_TIMING(int16_t timing, int16_t thresh := 0) := {
Harald Welte7f26f552018-02-23 09:38:15 +010083 cmd := {
Harald Welteef3e1c92018-02-28 23:40:14 +010084 verb := "FAKE_TOA",
85 params := { int2str(timing), int2str(thresh) }
Harald Welte7f26f552018-02-23 09:38:15 +010086 }
87}
88
Vadim Yanitskiy71136df2019-06-24 14:42:28 +070089template (value) TrxcMessage ts_TRXC_FAKE_CI(int16_t ci, int16_t thresh := 0) := {
90 cmd := {
91 verb := "FAKE_CI",
92 params := { int2str(ci), int2str(thresh) }
93 }
94}
95
Vadim Yanitskiy42525ac2021-10-03 14:00:40 +060096template (value) TrxcMessage ts_TRXC_FAKE_TRXC_DELAY(integer delay_ms := 0) := {
97 cmd := {
98 verb := "FAKE_TRXC_DELAY",
99 params := { int2str(delay_ms) }
100 }
101}
102
Harald Welte7f26f552018-02-23 09:38:15 +0100103
104} with { encode "TEXT" }