Attention is currently required from: pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email )
Change subject: Asterisk: Initial AMI support ......................................................................
Patch Set 2:
(1 comment)
File asterisk/AMI_Functions.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594/comment/fbca309d_39ffd... PS2, Line 109: var integer pos := f_strstr(str, ": ", 0); Looks like you could use TITAN's TEXT encoder for doing this:
``` type record AMI_Field { charstring key, charstring val } with { encode "TEXT" variant "SEPARATOR(':')" };
type set of AMI_Field AMI_Msg with { encode "TEXT" variant "SEPARATOR('\r\n')" variant "END('\r\n')" };
external function enc_AMI_Msg(in AMI_Msg msg) return charstring with { extension "prototype(convert) encode(TEXT)" } external function dec_AMI_Msg(in charstring stream) return AMI_Msg with { extension "prototype(convert) decode(TEXT)" } ```
See https://gitlab.eclipse.org/eclipse/titan/titan.core/-/blob/master/usrguide/r....
Not saying you have to do it this way, but if we can offload some work to TITAN - why not.
I have a small self-test:
``` private type component dummy_CT { };
testcase TC_tuwat() runs on dummy_CT { var AMI_Msg msg := { { "field1", "value1" }, { "field2", "value2" }, { "field3", "value3" } };
var charstring text := enc_AMI_Msg(msg); log("AMI msg encoded: ", text);
var AMI_Msg msg_dec := dec_AMI_Msg(text); log("AMI msg decoded: ", msg_dec); } ```
and here is the output it produces:
``` MTC@LEGION: AMI msg encoded: "field1:value1\r\nfield2:value2\r\nfield3:value3\r\n" MTC@LEGION: AMI msg decoded: { { key := "field1", val := "value1" }, { key := "field2", val := "value2" }, { key := "field3", val := "value3" } } ```