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", |
| 12 | "MEASURE", "FAKE_RSSI", "FAKE_TIMING" ) with { |
| 13 | variant "TEXT_CODING(,convert=upper_case, |
| 14 | '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TIMING))' |
| 15 | ,case_insensitive)" |
| 16 | } |
| 17 | |
| 18 | type integer TrxcStatus; |
| 19 | type charstring TrxcParam; |
| 20 | type record of TrxcParam TrxcParams; |
| 21 | |
| 22 | type record TrxcCommand { |
| 23 | TrxcVerb verb, |
| 24 | TrxcParams params optional |
| 25 | } with { |
| 26 | variant "SEPARATOR(' ', ' ')" |
| 27 | } |
| 28 | |
| 29 | type record TrxcResponse { |
| 30 | TrxcVerb verb, |
| 31 | TrxcStatus status, |
| 32 | TrxcParams params optional |
| 33 | } with { |
| 34 | variant "SEPARATOR(' ', ' ')" |
| 35 | } |
| 36 | |
| 37 | type record TrxcIndication { |
| 38 | TrxcVerb verb, |
| 39 | TrxcParams params optional |
| 40 | } with { |
| 41 | variant "SEPARATOR(' ', ' ')" |
| 42 | } |
| 43 | |
| 44 | type union TrxcMessage { |
| 45 | TrxcCommand cmd, |
| 46 | TrxcResponse rsp, |
| 47 | TrxcIndication ind |
| 48 | } with { |
| 49 | variant (cmd) "BEGIN('CMD ')" |
| 50 | variant (rsp) "BEGIN('RSP ')" |
| 51 | variant (ind) "BEGIN('IND ')" |
| 52 | } |
| 53 | |
| 54 | external function enc_TrxcMessage(in TrxcMessage id) return charstring |
| 55 | with { extension "prototype(convert) encode(TEXT)" }; |
| 56 | external function dec_TrxcMessage(in charstring id) return TrxcMessage |
| 57 | with { extension "prototype(convert) decode(TEXT)" }; |
| 58 | |
| 59 | template (value) TrxcMessage ts_TRXC_FAKE_RSSI(uint8_t rssi) := { |
| 60 | cmd := { |
| 61 | verb := "FAKE_RSSI", |
| 62 | params := { int2str(rssi) } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | template (value) TrxcMessage ts_TRXC_FAKE_TIMING(int16_t timing) := { |
| 67 | cmd := { |
| 68 | verb := "FAKE_TIMING", |
| 69 | params := { int2str(timing) } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | |
| 74 | } with { encode "TEXT" } |