Tag: Message code NIC number submit add BSP phone creat
A few days ago to start a 3G module, then daoteng a bit. Need to send mixed SMS in Chinese and English, so use PDU mode (do not know Google ^_^).
The biggest problem of course is splicing PDU code (Python is so powerful, maybe a module), sure enough to find a SMSPDU module (link: HTTPS://PYPI.PYTHON.ORG/PYPI/SMSPDU). But the test found that the generated coding and module documentation requirements are different, tears rush ... But you can still look at the source of the implementation of the way. The rest is to process it yourself. No wordy, on the code:
From SMSPDU import sms_submitdef format_message (Phone_number, message_content): TPDU = [] if Phone_number and Message_co Ntent: #+8613010112500 is the SMS center number, can be queried by the AT command PDU = sms_submit.create (' +8613010112500 ', Phone_number, message_content) #00: Set Use default SMS center number, 11: Normal GSM format, 00: Default send Number Tpdu.append (' 001100 ') #91: +8613000000000 format 81:13 billion format formataddress = Pdu.encodeaddress (). Replace (' 0b91 ', ' 0b81 ') tpdu.append (formataddress) #00: protocol ID, 00 for general GSM type, 18: encoding mode for UCS2; 01: Effective Time Tpdu.append (' 000801 ') #短信内容长度接短信内容unicode编码 tpdu.append ('%02x '% pdu.tp_udl) tpdu.append ('. Join (['%02 X '% ord (c) for C in Pdu.tp_ud])) return '. Join (TPDU)
The rest is sent through the AT command.
Here is the son of old thin family, if need to reprint please declare, I thank you for old thin.
Implementing SMS PDU encoding using Python