3
$\begingroup$

I am using SIM900A for some purpose and want to know the number of the sender from where a message comes. I am unable to find the specific AT command related to receiving message which give me number from where latest message comes.

I had used AT+CNMI (it corresponds to notification regarding latest received message), but am unable to find sender number.

I had seen AT+CMGL=<stat>[,<mode>] will give you a string which will have oa i.e. originating address and once that is stored in a string I can easily parse it out, but when I had data format of that string. Need help or any suggestion if somebody can help me out with any other possible solution.

$\endgroup$
1
$\begingroup$

Text mode vs PDU mode

The SIM900 module supports both text and PDU mode. Please note that some AT commands have different syntax depending on which mode is currently active.

To check which mode is currently active (0: PDU mode, 1: Text mode):

 AT+CMGF?

Retrieving SMS's

You can use the CMGL command to retrieve unread, read, stored unsent, stored sent, or all messages.

If text mode is currently selected:

 AT+CMGL=STAT,MODE

Parameters:

STAT:
   "REC UNREAD"  Received unread messages
   "REC READ"    Received read messages
   "STO UNSENT"  Stored unsent messages
   "STO SENT"    Stored sent messages
   "ALL"         All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL="ALL"

If PDU mode is currently selected:

 AT+CMGL=STAT,MODE

Parameters:

STAT:
   0  Received unread messages
   1  Received read messages
   2  Stored unsent messages
   3  Stored sent messages
   4  All messages
MODE: (OPTIONAL)
   0 Normal
   1 Not change status of the specified SMS record

In other words, the following command should print all SMS messages:

   AT+CMGL=4

Example

If text mode is currently selected, and a CMGL command is issued, the following is an example of what could be expected (note there's a line break before the actual message starts).

AT+CMGL="ALL"
+CMGL: 1,"REC READ","+85291234567",,"07/05/01,08:00:15+32",145,37
It is easy to list SMS text messages.

     1                      : Message index
     "REC READ"             : Message status (it's been read before)
     "+85291234567"         : Source number (ie the person that sent you the sms)
     "07/05/01,08:00:15+32" : Service center timestamp
     145                    : Character set
     37                     : Length of message

Refer to Section 4.2.3, page 99, of the SIM900 AT command set for more information.

External links

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.