-
Notifications
You must be signed in to change notification settings - Fork 2
/
Examples.cpp
145 lines (104 loc) · 4.64 KB
/
Examples.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <stdio.h>
#include "SmsSubmit.h"
void test00()
{
SmsSubmit pdu = SmsSubmit("86112233445566", L"Simple constructor", CHARACTER_SET_GSM7);
string result = "0001000E8068112233445566000012D3741BCE2E83C66FF79C2EAF8FE96F39";
printf("********** PDU TEST 00 **********\n");
for (int i = 0; i < pdu.TP_UD.getSegCount(); i++)
{
printf("PDU(%d/%d): %s\n%s\n\n", i+1, pdu.TP_UD.getSegCount(), (pdu.format(i).compare(result) == 0) ? "Correct":"Error", pdu.detailInfo(i).data());
}
}
void test01()
{
SmsSubmit pdu;
pdu.SMSC.setType(1, 1);
pdu.SMSC.setAddress("+1234567", 1);
pdu.FO.setRd(true);
pdu.FO.setSrr(true);
pdu.FO.setVpf(VPF_ENHANCED);
pdu.TP_MR.setMr(135);
pdu.TP_DA.setType(0, 1);
pdu.TP_DA.setAddress("8698765432101");
pdu.TP_PID.setPid(1, 0);
pdu.TP_DCS.setDcs(0);
SmsVpE vpE = {0};
vpE.vpf = 0;
pdu.TP_VP.setVp(vpE);
wstring ud = L"Hello@World!";
pdu.TP_UD.setUd(ud, CHARACTER_SET_GSM7);
string result = "0591214365F72D870D90688967452301F14000000000000000000CC8329BFD065CDF72363904";
printf("********** PDU TEST 01 **********\n");
for (int i = 0; i < pdu.TP_UD.getSegCount(); i++)
{
printf("PDU(%d/%d): %s\n%s\n\n", i+1, pdu.TP_UD.getSegCount(), (pdu.format(i).compare(result) == 0) ? "Correct":"Error", pdu.detailInfo(i).data());
}
}
void test02()
{
SmsSubmit pdu;
pdu.FO.setSrr(true);
pdu.FO.setRp(true);
pdu.FO.setUdhi(true);
pdu.FO.setVpf(VPF_ABSOLUTE);
pdu.TP_MR.setMr(234);
pdu.TP_DA.setType(1, 2);
pdu.TP_DA.setAddress("8698765432101");
pdu.TP_PID.setPid(0, 2, true);
pdu.TP_DCS.setDcs(1);
SmsVpA vpA;
vpA.year = 17;
vpA.month = 3;
vpA.day = 29;
vpA.hour = 9;
vpA.minute = 48;
vpA.second = 20;
vpA.timezone = -8;
pdu.TP_VP.setVp(vpA);
wstring ud = L"Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]Hello World![@]";
pdu.TP_UD.setPortUdh(191, 16, true);
pdu.TP_UD.setUd(ud, CHARACTER_SET_8BIT);
string result[2] =
{
"00F9EA0DA1688967452301F122047130929084022B8C090003000201040210BF48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C",
"00F9EA0DA1688967452301F122047130929084022B2D090003000202040210BF64215B405D48656C6C6F20576F726C64215B405D48656C6C6F20576F726C64215B405D"
};
printf("********** PDU TEST 02 **********\n");
for (int i = 0; i < pdu.TP_UD.getSegCount(); i++)
{
printf("PDU(%d/%d): %s\n%s\n\n", i+1, pdu.TP_UD.getSegCount(), (pdu.format(i).compare(result[i]) == 0) ? "Correct":"Error", pdu.detailInfo(i).data());
}
}
void test03()
{
SmsSubmit pdu;
pdu.FO.setUdhi(true);
pdu.TP_MR.setMr(255);
pdu.TP_DA.setAddress("8698765432101");
pdu.TP_PID.setPid(PID_SC_SPECIFIC, 37);
pdu.TP_DCS.setDcs(2, 1, true, false, false);
wstring ud = L"天地玄黄 宇宙洪荒 日月盈昃 辰宿列张 寒来暑往 秋收冬藏 闰余成岁 律吕调阳 云腾致雨 露结为霜 金生丽水 玉出昆冈 剑号巨阙 珠称夜光 果珍李柰 菜重芥姜 海咸河淡 鳞潜羽翔 龙师火帝 鸟官人皇 始制文字 乃服衣裳 推位让国 有虞陶唐";
pdu.TP_UD.setIndicationUdh(INDICATION_FAX, 0, 15);
pdu.TP_UD.setPortUdh(1601, 395, false);
pdu.TP_UD.setUd(ud, CHARACTER_SET_UCS2);
string result[2] =
{
"0041FF0D80688967452301F1E5198C0F00030002010102810F0504018B06415929573073849EC400205B875B996D2A8352002065E5670876C8660300208FB05BBF52175F2000205BD2676566915F80002079CB653651AC85CF002095F04F5962105C8100205F8B54158C03963300204E91817E81F496E8002097327ED34E3A971C002091D1751F4E3D6C340020738951FA660651880020525153F7",
"0041FF0D80688967452301F1E519820F00030002020102810F0504018B06415DE89619002073E079F0591C51490020679C73CD674E67F0002083DC91CD82A559DC00206D7754B86CB36DE100209CDE6F5C7FBD7FD400209F995E08706B5E1D00209E1F5B984EBA7687002059CB523665875B5700204E43670D886388F3002063A84F4D8BA956FD00206709865E96765510"
};
printf("********** PDU TEST 03 **********\n");
for (int i = 0; i < pdu.TP_UD.getSegCount(); i++)
{
printf("PDU(%d/%d): %s\n%s\n\n", i+1, pdu.TP_UD.getSegCount(), (pdu.format(i).compare(result[i]) == 0) ? "Correct":"Error", pdu.detailInfo(i).data());
}
}
int main()
{
test00();
test01();
test02();
test03();
getchar();
return 0;
}