(12) SMS part - send and receive SMS through RS232
Typically, the terminals transmitting and receiving SMS are connected to the computer through a serial interface, which is more than GSM Modem and mobile phone. Such devices typically support PDU mode, but there are still a few devices only support Text mode.
Equipment hardware can then be connected to whether the device can communicate properly by sending an AT instruction. Here I use the "Super Terminal" tool comes with Windows. This tool can be found in the program - attachment - communication, if this component is installed if you do not confirm if this component is installed. Or enter "HypertRM" in the run, you can quickly start the "Hyper Terminal".
All of the following examples are used as the terminal as a terminal, which is likely to return to your device. Specific parameters Clear inspection device related AT instruction set. This phone AT instruction set has downloaded on my homepage.
Ready to work:
1. Test connection: "AT8" test terminal is connected correctly. Returns "OK" after successful.
2, set the echo: (this step is convenient for test) ATE18
3, check and set the character set: AT CSCS =? 8 CSCS: ("GSM", "UCS2") Description The terminal supports both GSM and UCS2 character sets. Generally set to ucs2at cscs = "ucs2" 8 for Chinese environment
4, get the SMS center number: AT CSCA? 8 CSCA: " 8613800280500", 145
5, query and set the SMS format: query: AT CMGF = 8 Returns: cmgf: (0) 0 Represents the PDU mode. Your device may have other options, please refer to the AT instruction set of the device. Setting: AT CMGF = 08
6, query and set SMS storage location: query: AT CPMS =? 8 Return: CPMS: ("MT", "SM", "ME"), ("MT", "SM", "ME"), ("MT", "SM", "ME") where the MT represents all available storage locations where the device is available. SM represents the SIM card, the ME represents the body. Generally set to: AT CPMS = "MT", "MT", "MT" 8
Query SMS:
1. Query all SMS instructions with the same state: AT cmgl = n where n represents 0-4 numbers. 0 - Not read SMS. After the command is executed, it will become read. 1 - Read SMS. 2 - Draft. 3 - SMS has been sent. 4 - All return (Example): cmgl: 76, 3,, 20
0891683108200805F011620D91683194041338F50000FF0530972D860376-- serial number
3 - Status: Send
20 - PDU string length
2, query the SMS command for a specific number: AT cmgr = N8 where N represents serial number Return (Example): CMGR: 3, 200891683108200805f011620D91683195041338F50000FF0530972D86033 - Status: Send 20 - PDU String length
Note: The PDU string length represents 1/2 of the length of the code remaining in the PDU. For example, the PDU length portion of the PDU is 11620 d91683195041338f50000ff0530972d8603,40 characters, indicating 20 bytes.
Storage PDU instruction: AT CMGW = [PDU length] 8> [PDU string], for example: AT CMGW = 208> 0891683108200805f011620D91682008041338F50000FF0530972D8603 Note, press "Ctrl Z" to terminate after inputting PDU. Use 0x in the program
1A
0x1D acts as termination.
Return: CMGW: 8585 - Sequence
Send a PDU string
1. Send input PDU string instructions: AT cmgs = [PDU length] 8> [PDU code]
2. Send the PDU string directive of the specified number: AT CMSS = [Sequence Number] 8
Receive text messages
There are two ways to receive the just received text message: polling terminal; use event
The polling terminal can periodically read unread acquisition instructions regularly using the AT CMGL = 0 instruction. Method is simple, but many times are doing useless work, low efficiency, generally not recommended. The following main explanation method:
Directive: AT CNMI =
Parameters: Mode:
0 - Capture in the terminal
1 - Directly sent to TE
MT:
0 - Receive new SMS does not return events
1 - If the received SMS is stored in ME, return CMTI:
2 - In addition to Class2 SMS, new SMS is sent directly to the terminal, return: cmt:
3 - Class3 SMS returns using MT = 2, other types of methods that use MT = 1 return.
BM:
0-- Community broadcast is not notified
2 - New Community Broadcast Notice, Return CBM:
3 - Class3 format cell broadcast notification, use BM = 2 format
DS:
0 - Status report is not notified
1 - New Status Report Notice, Return: CDS:
2 - Returns if the new status report is stored in ME:
CDSI:
BRF:
1 - Always 1
example:
Generally we use AT CNMI = 1, 1, 0, 2, 1
The terminal returns when receiving a new SMS:
CMTI: ME, 5
New status report:
CDSI: ME, 6
The program can return new to SMS by judging the return value and returns new to SMS using the AT CMGR instruction.