Use python to implement sms pdu encoding and python SMS pdu Encoding
A few days ago, I started a 3G module, and then I went backwards. You need to send text messages in both Chinese and English, so the PDU mode is used (not familiar with google pai_^ ).
The biggest problem is of course splicing PDU encoding (python is so powerful, maybe there are modules), rather find a smspdu module (link: https://pypi.python.org/pypi/smspdu ). However, the test found that the generated encoding and module documentation have different requirements ...... But you can still look at the implementation of the source code. The rest is to process it by yourself. The Code is as follows:
From smspdu import SMS_SUBMITdef format_message (phone_number, message_content): tpdu = [] if phone_number and message_content: # + 8613010112500 indicates the SMS center number, you can use the AT command to query pdu = SMS_SUBMIT.create ('+ 100', phone_number, message_content) #00: Set to use the default SMS center number, 11: normal GSM format, 00: Default sending number tpdu. append ('200') #91: + 001100 format 81: 8613000000000 format formatAddress = pdu. encodeAddress (). replace ('0b91 ', '0b81') tpdu. append (formatAddress) #00: Protocol identifier. 00 indicates the common GSM type. 18: The encoding method is UCS2. 01: Valid time tpdu. append ('000000') # The length of the text message content is subject to the unicode encoding tpdu of the text message content. append ('% 02x' % pdu. tp_udl) tpdu. append (''. join (['% 02x' % ord (c) for c in pdu. tp_ud]) return ''. join (tpdu)
The rest is sent through the AT command.
This is the son of the old thin family. If you need to reprint it, please declare that I would like to thank you for your support.