blob: 5dd4bb17ebd51e3dec4a983f7c13a903fdbf0b58 [file] [log] [blame]
Vadim Yanitskiy92015542018-05-29 21:55:01 +07001module USSD_Helpers {
2
3/* USSD helpers for composing messages, building on top
4 * of both L3_Templates and USSD_Templates.
5 *
6 * (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
7 * All rights reserved.
8 *
9 * Released under the terms of GNU General Public License, Version 2 or
10 * (at your option) any later version.
11 */
12
13import from General_Types all;
14import from TCCEncoding_Functions all;
15
16import from SS_Templates all;
17import from SS_Types all;
18
19function f_USSD_FACILITY_IE_INVOKE(
20 integer invoke_id := 1,
21 SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
22 charstring ussd_string := "*#100#"
23) return octetstring {
24 var SS_FacilityInformation facility_ie;
25 var octetstring ussd_string_enc;
26
27 /* Encode input string with GSM 7-bit encoding */
28 ussd_string_enc := f_encGSM7bit(ussd_string);
29
30 /* Encode Facility IE */
31 facility_ie := valueof(ts_SS_USSD_FACILITY_INVOKE(
32 invoke_id := invoke_id,
33 op_code := op_code,
34 ussd_dcs := SS_USSD_DEFAULT_DCS,
35 ussd_string := ussd_string_enc
36 ));
37
38 return enc_SS_FacilityInformation(facility_ie);
39}
40
41function f_USSD_FACILITY_IE_RETURN_RESULT(
42 integer invoke_id := 1,
43 SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
44 charstring ussd_string := "Lorem Ipsum"
45) return octetstring {
46 var SS_FacilityInformation facility_ie;
47 var octetstring ussd_string_enc;
48
49 /* Encode input string with GSM 7-bit encoding */
50 ussd_string_enc := f_encGSM7bit(ussd_string);
51
52 /* Encode Facility IE */
53 facility_ie := valueof(ts_SS_USSD_FACILITY_RETURN_RESULT(
54 invoke_id := invoke_id,
55 op_code := op_code,
56 ussd_dcs := SS_USSD_DEFAULT_DCS,
57 ussd_string := ussd_string_enc
58 ));
59
60 return enc_SS_FacilityInformation(facility_ie);
61}
62
Vadim Yanitskiyc3cb5332018-06-06 05:27:32 +070063function f_USSD_FACILITY_IE_RETURN_ERROR(
64 integer invoke_id := 1,
65 SS_Err_Code err_code := SS_ERR_CODE_UNEXPECTED_DATA_VALUE
66) return octetstring {
67 var SS_FacilityInformation facility_ie;
68
69 /* Encode Facility IE */
70 facility_ie := valueof(ts_SS_FACILITY_RETURN_ERROR(
71 invoke_id := invoke_id,
72 err_code := err_code
73 ));
74
75 return enc_SS_FacilityInformation(facility_ie);
76}
77
Vadim Yanitskiy92015542018-05-29 21:55:01 +070078}