summaryrefslogtreecommitdiffstats
path: root/library/USSD_Helpers.ttcn
blob: 5dd4bb17ebd51e3dec4a983f7c13a903fdbf0b58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module USSD_Helpers {

/* USSD helpers for composing messages, building on top
 * of both L3_Templates and USSD_Templates.
 *
 * (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 */

import from General_Types all;
import from TCCEncoding_Functions all;

import from SS_Templates all;
import from SS_Types all;

function f_USSD_FACILITY_IE_INVOKE(
	integer invoke_id := 1,
	SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
	charstring ussd_string := "*#100#"
) return octetstring {
	var SS_FacilityInformation facility_ie;
	var octetstring ussd_string_enc;

	/* Encode input string with GSM 7-bit encoding */
	ussd_string_enc := f_encGSM7bit(ussd_string);

	/* Encode Facility IE */
	facility_ie := valueof(ts_SS_USSD_FACILITY_INVOKE(
		invoke_id := invoke_id,
		op_code := op_code,
		ussd_dcs := SS_USSD_DEFAULT_DCS,
		ussd_string := ussd_string_enc
	));

	return enc_SS_FacilityInformation(facility_ie);
}

function f_USSD_FACILITY_IE_RETURN_RESULT(
	integer invoke_id := 1,
	SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
	charstring ussd_string := "Lorem Ipsum"
) return octetstring {
	var SS_FacilityInformation facility_ie;
	var octetstring ussd_string_enc;

	/* Encode input string with GSM 7-bit encoding */
	ussd_string_enc := f_encGSM7bit(ussd_string);

	/* Encode Facility IE */
	facility_ie := valueof(ts_SS_USSD_FACILITY_RETURN_RESULT(
		invoke_id := invoke_id,
		op_code := op_code,
		ussd_dcs := SS_USSD_DEFAULT_DCS,
		ussd_string := ussd_string_enc
	));

	return enc_SS_FacilityInformation(facility_ie);
}

function f_USSD_FACILITY_IE_RETURN_ERROR(
	integer invoke_id := 1,
	SS_Err_Code err_code := SS_ERR_CODE_UNEXPECTED_DATA_VALUE
) return octetstring {
	var SS_FacilityInformation facility_ie;

	/* Encode Facility IE */
	facility_ie := valueof(ts_SS_FACILITY_RETURN_ERROR(
		invoke_id := invoke_id,
		err_code := err_code
	));

	return enc_SS_FacilityInformation(facility_ie);
}

}