1. SMS AT command

1. AT+CPMS function: Set the SMS storage location

AT+CPMS=?
+CPMS: ("ME"."MT"."SM"."SR"), ("ME"."MT"."SM"."SR"), ("ME"."MT"."SM"."SR")

+CPMS: (list of supported <mem1>s),(list of supported<mem2>s),(list of supported<mem3>s)
Copy the code

Parameter Description:

“SM” (U)SIM information storage “ME” Mobile device information storage “MT” is the same as “ME” storage “SR” in the EC20 AT manual did not find corresponding instructions, temporarily ignored.

Mem1: messages to be read and deleted from this memory store MEM2: messages will be written and sent to this memory store MEM3: Received messages will be placed in this memory store (provided not set with AT+CNMI)

AT+CPMS=”SM”,”SM”,”SM” Sets the SMS stored in the SIM card.

2, AT + CNMI chief

Effect: SMS event reporting configuration

AT+CNMI=? + CNMI chief: (0-2), (0-3), (0, 2), (0, 2), (0, 1) OKCopy the code

Detailed instructions, refer to: https://blog.csdn.net/chenwr2018/article/details/88313436

3, AT + CMGF

Function: Sets the SMS format

AT+CMGF=? + CMGF: (0, 1) OKCopy the code

Parameter Description:

0 indicates the PDU mode. 1 indicates the Text mode

Note: On CDMA networks, only Test mode is supported.

4, AT + CMGS

Function: Send SMS messages

(1) Set the Test mode first

AT+CMGF=1 otherwise it would appear

AT+CMGS="139000000"

+CMS ERROR: 304
Copy the code

(2) Set the terminal character set

AT+CSCS="GSM"

OK
Copy the code

(3) Enter the short message content

AT+CMGS="13900000000"

> 666
> 
+CMGS: 46

OK
Copy the code

AT+CMGS=”13900000000″

Enter the content and press Enter, then CTRL + Z to send.

5, AT + CMGR

Function: Reads SMS messages

AT+CMGR=< index >

Parameter Index manual translation is as follows:

Integer type values in the range of position numbers supported by associated memory. (After a series of parameter description made my head spin, feel temporarily do not need to pay attention to such details.)

AT+CMGR=0 indicates the first SMS received, AT+CMGR=1 indicates the second SMS received, and so on.

The Test model

REC UNREAD Received UNREAD messages UNREAD messages Received REC READreadMessages Received read messages STO UNSENT Stored UNSENT messages Stores UNSENT messages. STO SENT Stored UNSENT messages Stores SENT messages. ALL ALL messagesCopy the code

PDU mode

0  Received unread messages
1  Received read messages
2  Stored unsent messages
3  Stored sent messages
4  All messages
Copy the code
AT+CMGF=1

OK
AT+CMGR=2

+CMGR: "REC UNREAD"."139000000000"."19/03/07, 19:29:33 + 32", 161,36,0,0,"+ 8613010383500",145,4
2333

OK
Copy the code

6, AT + CMGL

What it does: Lists all SMS messages

Parameter: Query all SMS messages in the corresponding status

AT+CMGL=?

+CMGL: ("REC UNREAD"."REC READ"."STO UNSENT"."STO SENT"."ALL")

OK
Copy the code
AT+CMGL="ALL"

+CMGL: 0,"REC READ"."13900000000"."19/03/07, 19:22:15 + 32", 161, 2 66 + CMGL: 1,"REC READ"."13900000000"."19/03/07, 19:24:38 + 32", 161, 999 + CMGL: 2,"REC READ"."13900000000"."19/03/07, 19:29:33 + 32", 161, 2333 + CMGL: 3,"REC READ"."13900000000"."19/03/07, 19:41:36 + 32", 161, 10 chenwr2018 OKCopy the code

Make a list of all the text messages.

7, AT + CMGD

Function: Delete SMS messages

AT+CMGD=? ,1,2,3 + CMGD: (0), (0 to 4)Copy the code

+CMGD: (list of supported s),(list of supported s)

Parameter: index indicates the SMS index number. The value starts from 0, and 3 indicates the fourth SMS.

delflag

1 Delete all the short messages read from the storage. 2 Delete all the short messages read from the storage and send the short messages. 3 Delete all the short messages read from the storage and all the sent and unsent short messagesCopy the code
AT+CMGD=1 // Delete all SMS OK with index 1Copy the code

8, AT + CSCA

Function: Queries the phone number of the SMS center.

AT+CSCA?
+CSCA: "+ 8613010300000",145

OK
Copy the code

Ii. Analysis of offline SMS problems

1, SMS function

(1) SMS is mainly used to set parameters and control devices. Send reset SMS messages in special scenarios. The device reads text messages every time it is turned on. Therefore, ensure that read SMS messages are deleted; otherwise, the device will reset continuously. (2) Because the SIM card has only 10,000 to 100,000 read and write times and storage space of 40-50 short messages. Service life and space problems cause that the Terminal Equipment (TE) is not stored when receiving SMS messages.

Fault: After the device is powered on again, the device cannot receive the control commands of offline SMS messages. The application layer cannot read the control commands of offline SMS messages.

Question: Is the specific principle of offline SMS stored in the base station in advance, and then sent to the mobile phone terminal after broadcasting to inform the base station that the network has been stationed? If so then the entire SMS flow is consistent with the normal device online? Then why can’t I get it?

2, simple SMS principle

(1) Process of sending and receiving SMS messages

Source phone – base Station – SMS Center – Base Station – Destination phone

(2) base station

The GSM system scans the whole frequency band, and the strongest signal is the suitable base station. CDMA system base station uses a fixed frequency. [Control carrier frequency tuning]

(3) How does the base station find the mobile phone

The base station broadcasts constantly, sending a location area when the phone is connected. When the phone detects a change in its current location area, it sends its current location, which the wireless network records in a database (location register). The phone periodically tells the wireless network its current location.

(4) Process description

  • The source phone sends a text message, which is actually sent to the base station. The phone has a dedicated channel with the base station, and the control channel provides access for SMS messages.
  • Every cell phone has an SMSC(Short Message Service Center), and when someone sends an SMS message to their cell phone, they are actually sending it to the SHORT message Service center. This mechanism should be similar to the early principles of pagers.
  • The short message will pass through the SMSC (Short Message Service Center) in the form of small packets on the control channel, and then send the short message to the mobile phone through the base station. Similarly, when sending a short message, the mobile phone will send the short message to the base station through the control channel, and then the base station will send the short message to the SMSC, and finally from this position to the receiving target.

3. Current practice

To ensure that offline SMS messages can be obtained by the application layer.

  • SMS messages sent in any state are first saved to the SIM card.
  • After the device is initialized, the contents of the SIM card can be deleted after the execution program reads the message.

The main problem is still the SIM card read/write life, but fortunately SMS control command usage is not very high!

Reference materials: Move away EC20 AT Instruction manual, Dahua Wireless Data Communication