PDU encoding--EMS encoding

Coding EMS is more complicated than SMS, but the basis of each EMS is SMS, so I directly inherited the SMS class. The difference is mainly to deal with TP_UD and IE. For ConcatenatedShortMessage, since its IE and TP_UDHL occupy part of the space of TP_UD, each short message can only accommodate 133 characters in English and 66 characters in Chinese. We can get the number of text messages through this information.

If TP_DCS is Unicode, the SMS entry is:

TotalMessages= (TP_UD.Length / 4) / 66 + ((TP_UD.Length / 4 Mod 66) = 0)+1

If it is 7bit, it is:

TotalMessages= (tp_ud. Length / 266) - ((tp_ud.Length Mod 266) = 0)+1

Note that in the program I did not add one in order to simplify the subsequent array operations.

After the number of short messages is determined, the TP_UD of each short message can be extracted through a loop.

SelectCase tp_dcs

CaseENUM_TP_DCS.UCS2

tmpTP_UD= Mid(TP_UD, i * 66 * 4 + 1, 66 * 4)'When TP_UDL is odd, the max length of anUnicode string in PDU code is 66 Charactor.See [3GPP TS 23.040 V6.5.0 (2004-09] 9.2.3.24.1

CaseENUM_TP_DCS.DefaultAlphabet

tmpTP_UD= Mid(tp_ud, i * 133 * 2 + 1, 133 * 2)

EndSelect

also needs to encode the IE part after that, and the key code is to determine the value of TP_UDL. For TP_DCS to be 7bit, it is more complicated to determine this value, and it is easy to have one more error and one less error.

Iftp_dcs = ENUM_TP_DCS.UCS2 Then

TP_UDL= tmpTP_UD.Length / 2 + 6 + 1 '6: length of IE

End If

Iftp_dcs = ENUM_TP_DCS.DefaultAlphabet Then

TP_UDL= Fix((tmpTP_UD.Length + 7 * 2) * 4 / 7) ' 6:length of IE

End If

Then according to the description of the structure of EMS in 3GPP, the processing program of EMS PDU can be written. See the original code for details.

If you need to expand the EMS to accommodate more types of EMS, you can refer to 3GPP to write a more powerful encoding program. But the most important thing is to deal with IE and TP_UDL.

Transferred from bbs.sendsms.cn

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327066907&siteId=291194637