There are three control modes for sending and receiving short messages: block mode, PDU mode, and text mode. To use the block mode, the mobile phone manufacturer must provide driver support. Currently, the PDU mode has replaced the block mode, while the text mode does not support Chinese characters. Therefore, for the system's versatility and compatibility with the sending and receiving of Short Messages in Chinese and English, the system uses the PDU mode to process short messages.
Before setting the system, briefly describe the concept of Short Message class: according to the specified storage location, short messages are divided into four categories of class0-3, you can also do not specify the category (no class ), by default, mobile devices are stored in memory or SIM card. In the TP-DCS bytes of the tpdu, The bit7-bit4 indicates the class to which the message belongs when the bit1-bit0 is 00x1, 1111.
00 -- Class 0, which can be directly displayed.
01 -- class 1, which is stored in me memory by default.
02 -- class 2, stored in SIM card.
03 -- class 3, which can be directly transmitted to the terminal device TE.
The default short message is stored in the SIM card, and no other short messages are usually stored in the SIM card.
Generally, GSM Modem supports an "at + cnmi" command to set how to handle a short message when it arrives-only stored in the specified memory (easy to lose/non-easy to lose) medium; store the data before notifying the Te; Forward the data directly to the Te.
The syntax of the "at + cnmi" command is:
At + cnmi = <mode>, <Mt>, <BM>, <DS>, <BFR>
(1) <mode> control the mode of notification te.
0 -- first cache the notification and then send it according to the value of <Mt>.
1 -- notify the Te when the data line is idle. Otherwise, the Te is not notified.
2-when the data line is idle, notify te directly; otherwise, the notification will be cached and sent again when the data line is idle.
3 -- directly notify te. When the data line is occupied, the notification te message will be transmitted together.
(2) <Mt> set the content of the short message storage and notification te.
0 -- the received short messages are stored in the default memory location (including class 3), and Te is not notified.
1 -- the received short messages are stored in the default memory location and sent to te (including class 3 ). The notification format is:
+ Cmti: "SM", <index>
2 -- for Class 2 short messages, store the messages to the SIM card and send notifications to te; for other classes, directly forward the short messages to te:
+ CMT: [<alpha>], <length> <CR> <LF> <PDU> (PDU Mode)
Or + CMT: <OA>, [<alpha>,] <SCTS> [, <tooa>, <fo>, <pid>, <DCS>, <SCA>, <Tosca>, <length>] <CR> <LF> <DATA> (text mode)
3 -- for Class 3 short messages, the messages are directly forwarded to te, which is the same as <Mt> = 2; for other classes, the messages are the same as <Mt> = 1.
(3) for definitions of BM, DS, and BFR, refer to the relevant standard documents. Generally, you do not need to care about them. Set it to 0.
Based on the above analysis, if the short message is sent directly to te without passing through the SIM card, you can set:
At + cnmi =, 0
However, there is another problem: the Class 2 text message will still be stored in the SIM card and sent + cmti: "SM", <index>. Then, the recipient needs to process the text message notification and content, increasing complexity. If the sender is also controlled by the program, only messages of no Class and Class 1 can be sent. The no class configuration is used here. In PDU mode, make the TP-DCS of the bit7-bit4 00x0, you can set the sent sms to no class. Text messages sent by mobile phones are not similar.
During communication, both sending and receiving parties must unify the text message format. Set at + cmgf = 0 on the sender and confirm that the SMS sending format is PDU.
Set in receiver:
At + cmgf = 0 // The message receiving format is PDU
At + CSMs = 0
If at + CSMs = 1, when receiving the SMS, the Te must send a feedback message to the module within a certain period of time. If the message times out, the values of <mode> and <Mt> are forcibly reset to 0. Then, new messages cannot be correctly processed. You must use the "at + cnmi" command to reset the parameters. This increases the complexity of program processing. At + CSMs = 0, saving these troubles.