Add TRXC (OsmoTRX Control) protocol types + codec port
Change-Id: I3b5e81693e5cf8ee8a2c360bde8b16c5276d2297
diff --git a/library/TRXC_Types.ttcn b/library/TRXC_Types.ttcn
new file mode 100644
index 0000000..c12e5d2
--- /dev/null
+++ b/library/TRXC_Types.ttcn
@@ -0,0 +1,74 @@
+module TRXC_Types {
+
+import from Osmocom_Types all;
+
+type charstring TrxcType ("CMD", "RSP", "IND") with {
+ variant "TEXT_CODING(,convert=upper_case,'((CMD)|(RSP)|(IND))',case_insensitive)"
+}
+
+type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK",
+ "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", "SETPOWER",
+ "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", "NOHANDOVER",
+ "MEASURE", "FAKE_RSSI", "FAKE_TIMING" ) with {
+ variant "TEXT_CODING(,convert=upper_case,
+ '((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TIMING))'
+ ,case_insensitive)"
+}
+
+type integer TrxcStatus;
+type charstring TrxcParam;
+type record of TrxcParam TrxcParams;
+
+type record TrxcCommand {
+ TrxcVerb verb,
+ TrxcParams params optional
+} with {
+ variant "SEPARATOR(' ', ' ')"
+}
+
+type record TrxcResponse {
+ TrxcVerb verb,
+ TrxcStatus status,
+ TrxcParams params optional
+} with {
+ variant "SEPARATOR(' ', ' ')"
+}
+
+type record TrxcIndication {
+ TrxcVerb verb,
+ TrxcParams params optional
+} with {
+ variant "SEPARATOR(' ', ' ')"
+}
+
+type union TrxcMessage {
+ TrxcCommand cmd,
+ TrxcResponse rsp,
+ TrxcIndication ind
+} with {
+ variant (cmd) "BEGIN('CMD ')"
+ variant (rsp) "BEGIN('RSP ')"
+ variant (ind) "BEGIN('IND ')"
+}
+
+external function enc_TrxcMessage(in TrxcMessage id) return charstring
+ with { extension "prototype(convert) encode(TEXT)" };
+external function dec_TrxcMessage(in charstring id) return TrxcMessage
+ with { extension "prototype(convert) decode(TEXT)" };
+
+template (value) TrxcMessage ts_TRXC_FAKE_RSSI(uint8_t rssi) := {
+ cmd := {
+ verb := "FAKE_RSSI",
+ params := { int2str(rssi) }
+ }
+}
+
+template (value) TrxcMessage ts_TRXC_FAKE_TIMING(int16_t timing) := {
+ cmd := {
+ verb := "FAKE_TIMING",
+ params := { int2str(timing) }
+ }
+}
+
+
+} with { encode "TEXT" }