Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 1 | module TRXC_Types { |
| 2 | |
| 3 | import from Osmocom_Types all; |
| 4 | |
| 5 | type charstring TrxcType ("CMD", "RSP", "IND") with { |
| 6 | variant "TEXT_CODING(,convert=upper_case,'((CMD)|(RSP)|(IND))',case_insensitive)" |
| 7 | } |
| 8 | |
| 9 | type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK", |
| 10 | "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", "SETPOWER", |
| 11 | "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", "NOHANDOVER", |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 12 | "MEASURE", "FAKE_RSSI", "FAKE_TOA" ) with { |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 13 | variant "TEXT_CODING(,convert=upper_case, |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 14 | '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TOA))' |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 15 | ,case_insensitive)" |
| 16 | } |
| 17 | |
| 18 | type integer TrxcStatus; |
| 19 | type charstring TrxcParam; |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 20 | type record of TrxcParam TrxcParams with { |
| 21 | variant "SEPARATOR(' ', ' ')" |
| 22 | } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 23 | |
| 24 | type record TrxcCommand { |
| 25 | TrxcVerb verb, |
| 26 | TrxcParams params optional |
| 27 | } with { |
| 28 | variant "SEPARATOR(' ', ' ')" |
| 29 | } |
| 30 | |
| 31 | type record TrxcResponse { |
| 32 | TrxcVerb verb, |
| 33 | TrxcStatus status, |
| 34 | TrxcParams params optional |
| 35 | } with { |
| 36 | variant "SEPARATOR(' ', ' ')" |
| 37 | } |
| 38 | |
| 39 | type record TrxcIndication { |
| 40 | TrxcVerb verb, |
| 41 | TrxcParams params optional |
| 42 | } with { |
| 43 | variant "SEPARATOR(' ', ' ')" |
| 44 | } |
| 45 | |
| 46 | type 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 | |
| 56 | external function enc_TrxcMessage(in TrxcMessage id) return charstring |
| 57 | with { extension "prototype(convert) encode(TEXT)" }; |
| 58 | external function dec_TrxcMessage(in charstring id) return TrxcMessage |
| 59 | with { extension "prototype(convert) decode(TEXT)" }; |
| 60 | |
Vadim Yanitskiy | a201b97 | 2018-10-23 00:09:32 +0200 | [diff] [blame] | 61 | template (value) TrxcMessage ts_TRXC_FAKE_RSSI(uint8_t rssi, int16_t thresh := 0) := { |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 62 | cmd := { |
| 63 | verb := "FAKE_RSSI", |
Vadim Yanitskiy | a201b97 | 2018-10-23 00:09:32 +0200 | [diff] [blame] | 64 | params := { int2str(rssi), int2str(thresh) } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 68 | 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] | 69 | cmd := { |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 70 | verb := "FAKE_TOA", |
| 71 | params := { int2str(timing), int2str(thresh) } |
Harald Welte | 7f26f55 | 2018-02-23 09:38:15 +0100 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | } with { encode "TEXT" } |