The encoder of the PDU works as a reverse process of the decoder. It is relatively straightforward to work with the PDU code sent only by the encoder as required . This article explains the coding idea, the specific code please refer to the Blog pduencoder part
I took The PDU code is divided into two parts,SMS and EMS. the EMS section I only provided the Concatenatedshortmessage encoder. This is the code of the long text message, the most used.
SMS Encoding
encode a SMS generally requires the following information:
Tp_data_coding_scheme tp_ud Encoding method
Tp_destination_address the other number
Tp_message_reference Reference Number
Tp_status_report_request Status Report
Tp_user_data User Information
Tp_validity_priod Validity
Servicecenternumber SMS Center number
so there are the above attributes in the encoder, and the A processing code is added to the set to convert the readable information into the corresponding hexadecimal information.
the special attention is the Tp_user_data property, which automatically sets tp_udl based on user data encoding . For pure English encoding,tp_udl is the number of characters; for Unicode encoding, because one character is represented by two bytes,tp_udl is the number of characters . Note that the length of the Tp_user_data is checked, and the encoded tp_ud length cannot exceed the number of bytes for SMS . In other words , the English characters (140/7*8), Chinese characters .
for Tp_ud code in the decoder also has a description, not to repeat this.
I've also designed several enumeration variables:
Enum_tp_dcs Encoding Method
Enum_tp_sri Status Report
Enum_tp_valid_period Validity
ENUM_TP_VPF Expiration Format
These enumeration variables can simplify the input and also facilitate future expansion.
when the above content is set up, basically a message shelf is out. At this point the call Getsmspducode is combined, the simple hexadecimal stitching together to form a complete PDU code.
Transfer from bbs.sendsms.cn
vb.net encoded PDU in SMS (i.)