Add TRXC (OsmoTRX Control) protocol types + codec port
Change-Id: I3b5e81693e5cf8ee8a2c360bde8b16c5276d2297
diff --git a/library/TRXC_CodecPort.ttcn b/library/TRXC_CodecPort.ttcn
new file mode 100644
index 0000000..6acead0
--- /dev/null
+++ b/library/TRXC_CodecPort.ttcn
@@ -0,0 +1,62 @@
+module TRXC_CodecPort {
+
+import from IPL4asp_PortType all;
+import from IPL4asp_Types all;
+import from TRXC_Types all;
+
+type record TRXC_RecvFrom {
+ ConnectionId connId,
+ HostName remName,
+ PortNumber remPort,
+ HostName locName,
+ PortNumber locPort,
+ TrxcMessage msg
+}
+
+template TRXC_RecvFrom tr_TRXC_RecvFrom(template TrxcMessage msg) := {
+ connId := ?,
+ remName := ?,
+ remPort := ?,
+ locName := ?,
+ locPort := ?,
+ msg := msg
+}
+
+type record TRXC_Send {
+ ConnectionId connId,
+ TrxcMessage msg
+}
+
+private function IPL4_to_TRXC_RecvFrom(in ASP_RecvFrom pin, out TRXC_RecvFrom pout) {
+ pout.connId := pin.connId;
+ pout.remName := pin.remName;
+ pout.remPort := pin.remPort;
+ pout.locName := pin.locName;
+ pout.locPort := pin.locPort;
+ pout.msg := dec_TrxcMessage(oct2char(pin.msg));
+} with { extension "prototype(fast)" };
+
+private function TRXC_to_IPL4_Send(in TRXC_Send pin, out ASP_Send pout) {
+ pout.connId := pin.connId;
+ pout.proto := { udp := {} };
+ pout.msg := char2oct(enc_TrxcMessage(pin.msg));
+} with { extension "prototype(fast)" };
+
+type port TRXC_CODEC_PT message {
+ out TRXC_Send;
+ in TRXC_RecvFrom,
+ ASP_ConnId_ReadyToRelease,
+ ASP_Event;
+} with { extension "user IPL4asp_PT
+ out(TRXC_Send -> ASP_Send: function(TRXC_to_IPL4_Send))
+ in(ASP_RecvFrom -> TRXC_RecvFrom: function(IPL4_to_TRXC_RecvFrom);
+ ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
+ ASP_Event -> ASP_Event: simple)"
+}
+
+template (value) TRXC_Send ts_TRXC_Send(ConnectionId cid, template (value) TrxcMessage msg) := {
+ connId := cid,
+ msg := msg
+}
+
+}
diff --git a/library/TRXC_CodecPort_CtrlFunct.ttcn b/library/TRXC_CodecPort_CtrlFunct.ttcn
new file mode 100644
index 0000000..07d809c
--- /dev/null
+++ b/library/TRXC_CodecPort_CtrlFunct.ttcn
@@ -0,0 +1,43 @@
+module TRXC_CodecPort_CtrlFunct {
+
+ import from TRXC_CodecPort all;
+ import from IPL4asp_Types all;
+
+ external function f_IPL4_listen(
+ inout TRXC_CODEC_PT portRef,
+ in HostName locName,
+ in PortNumber locPort,
+ in ProtoTuple proto,
+ in OptionList options := {}
+ ) return Result;
+
+ external function f_IPL4_connect(
+ inout TRXC_CODEC_PT portRef,
+ in HostName remName,
+ in PortNumber remPort,
+ in HostName locName,
+ in PortNumber locPort,
+ in ConnectionId connId,
+ in ProtoTuple proto,
+ in OptionList options := {}
+ ) return Result;
+
+ external function f_IPL4_close(
+ inout TRXC_CODEC_PT portRef,
+ in ConnectionId id,
+ in ProtoTuple proto := { unspecified := {} }
+ ) return Result;
+
+ external function f_IPL4_setUserData(
+ inout TRXC_CODEC_PT portRef,
+ in ConnectionId id,
+ in UserData userData
+ ) return Result;
+
+ external function f_IPL4_getUserData(
+ inout TRXC_CODEC_PT portRef,
+ in ConnectionId id,
+ out UserData userData
+ ) return Result;
+
+ }
diff --git a/library/TRXC_CodecPort_CtrlFunctDef.cc b/library/TRXC_CodecPort_CtrlFunctDef.cc
new file mode 100644
index 0000000..aecd1ee
--- /dev/null
+++ b/library/TRXC_CodecPort_CtrlFunctDef.cc
@@ -0,0 +1,55 @@
+#include "IPL4asp_PortType.hh"
+#include "IPL4asp_PT.hh"
+#include "TRXC_CodecPort.hh"
+
+namespace TRXC__CodecPort__CtrlFunct {
+
+ IPL4asp__Types::Result f__IPL4__listen(
+ TRXC__CodecPort::TRXC__CODEC__PT& portRef,
+ const IPL4asp__Types::HostName& locName,
+ const IPL4asp__Types::PortNumber& locPort,
+ const IPL4asp__Types::ProtoTuple& proto,
+ const IPL4asp__Types::OptionList& options)
+ {
+ return f__IPL4__PROVIDER__listen(portRef, locName, locPort, proto, options);
+ }
+
+ IPL4asp__Types::Result f__IPL4__connect(
+ TRXC__CodecPort::TRXC__CODEC__PT& portRef,
+ const IPL4asp__Types::HostName& remName,
+ const IPL4asp__Types::PortNumber& remPort,
+ const IPL4asp__Types::HostName& locName,
+ const IPL4asp__Types::PortNumber& locPort,
+ const IPL4asp__Types::ConnectionId& connId,
+ const IPL4asp__Types::ProtoTuple& proto,
+ const IPL4asp__Types::OptionList& options)
+ {
+ return f__IPL4__PROVIDER__connect(portRef, remName, remPort,
+ locName, locPort, connId, proto, options);
+ }
+
+ IPL4asp__Types::Result f__IPL4__close(
+ TRXC__CodecPort::TRXC__CODEC__PT& portRef,
+ const IPL4asp__Types::ConnectionId& connId,
+ const IPL4asp__Types::ProtoTuple& proto)
+ {
+ return f__IPL4__PROVIDER__close(portRef, connId, proto);
+ }
+
+ IPL4asp__Types::Result f__IPL4__setUserData(
+ TRXC__CodecPort::TRXC__CODEC__PT& portRef,
+ const IPL4asp__Types::ConnectionId& connId,
+ const IPL4asp__Types::UserData& userData)
+ {
+ return f__IPL4__PROVIDER__setUserData(portRef, connId, userData);
+ }
+
+ IPL4asp__Types::Result f__IPL4__getUserData(
+ TRXC__CodecPort::TRXC__CODEC__PT& portRef,
+ const IPL4asp__Types::ConnectionId& connId,
+ IPL4asp__Types::UserData& userData)
+ {
+ return f__IPL4__PROVIDER__getUserData(portRef, connId, userData);
+ }
+
+}
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" }