Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 1 | module TRXC_Types { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* 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 Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 13 | import from Osmocom_Types all; |
| 14 | |
| 15 | type charstring TrxcType ("CMD", "RSP", "IND") with { |
| 16 | variant "TEXT_CODING(,convert=upper_case,'((CMD)|(RSP)|(IND))',case_insensitive)" |
| 17 | } |
| 18 | |
| 19 | type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK", |
| 20 | "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", "SETPOWER", |
| 21 | "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", "NOHANDOVER", |
Vadim Yanitskiy | 71136df | 2019-06-24 14:42:28 +0700 | [diff] [blame] | 22 | "MEASURE", "FAKE_RSSI", "FAKE_TOA", "FAKE_CI" ) with { |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 23 | variant "TEXT_CODING(,convert=upper_case, |
Vadim Yanitskiy | 71136df | 2019-06-24 14:42:28 +0700 | [diff] [blame] | 24 | '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TOA)|(FAKE_CI))' |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 25 | ,case_insensitive)" |
| 26 | } |
| 27 | |
| 28 | type integer TrxcStatus; |
| 29 | type charstring TrxcParam; |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 30 | type record of TrxcParam TrxcParams with { |
| 31 | variant "SEPARATOR(' ', ' ')" |
| 32 | } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 33 | |
| 34 | type record TrxcCommand { |
| 35 | TrxcVerb verb, |
| 36 | TrxcParams params optional |
| 37 | } with { |
| 38 | variant "SEPARATOR(' ', ' ')" |
| 39 | } |
| 40 | |
| 41 | type record TrxcResponse { |
| 42 | TrxcVerb verb, |
| 43 | TrxcStatus status, |
| 44 | TrxcParams params optional |
| 45 | } with { |
| 46 | variant "SEPARATOR(' ', ' ')" |
| 47 | } |
| 48 | |
| 49 | type record TrxcIndication { |
| 50 | TrxcVerb verb, |
| 51 | TrxcParams params optional |
| 52 | } with { |
| 53 | variant "SEPARATOR(' ', ' ')" |
| 54 | } |
| 55 | |
| 56 | type 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 | |
| 66 | external function enc_TrxcMessage(in TrxcMessage id) return charstring |
| 67 | with { extension "prototype(convert) encode(TEXT)" }; |
| 68 | external function dec_TrxcMessage(in charstring id) return TrxcMessage |
| 69 | with { extension "prototype(convert) decode(TEXT)" }; |
| 70 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 71 | /* rxlev2dbm(0..63) gives us [-110..-47], plus -10 dbm for noise */ |
| 72 | type integer TRXC_RSSI (-120..-47); |
| 73 | type integer TRXC_RSSI_THRESH (-120..120); |
| 74 | |
| 75 | template (value) TrxcMessage ts_TRXC_FAKE_RSSI(TRXC_RSSI rssi, TRXC_RSSI_THRESH thresh := 0) := { |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 76 | cmd := { |
| 77 | verb := "FAKE_RSSI", |
Vadim Yanitskiy | a201b97 | 2018-10-23 00:09:32 +0200 | [diff] [blame] | 78 | params := { int2str(rssi), int2str(thresh) } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 82 | template (value) TrxcMessage ts_TRXC_FAKE_TIMING(int16_t timing, int16_t thresh := 0) := { |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 83 | cmd := { |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 84 | verb := "FAKE_TOA", |
| 85 | params := { int2str(timing), int2str(thresh) } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
Vadim Yanitskiy | 71136df | 2019-06-24 14:42:28 +0700 | [diff] [blame] | 89 | template (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 | |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 96 | |
| 97 | } with { encode "TEXT" } |