AdSense

Sunday, May 12, 2013

Getting SMS Deliver Notification from SMS Center using AT Command

I have been working on the SMS Application that would send and receive SMS using USB modem through serial port using AT Commands. During the development, i stumbled upon getting SMS Message Deliver Confirmation Status Report from the SMS Service Center. After much googling, and hit and trial, i could finally get the status report. Thus, i wanted to share my part of experience with the hope that it would make some one else's work a little bit easier.

For the Text Mode:
  1.  AT+CMGF=1
  2.  AT+CSMP = 49,167,0,242 
  3.  AT+CNMI = 1,0,0,1,0 
  4.  AT+CNMI = 2  (This was how i could set the correct values. I used ZTE Modem  and Nepal Telecom SIM card)
After setting up the Notificaton setting, you can send the SMS using AT+CMGS="PhoneNumber" and wait for few seconds to get the delivery status report from the message center.
A successful delivery report will have error code "0" at the end.
+CDS:6,72,"9851111111[PhoneNumber]" ,129[Message ID],"05/12/13,13:16:18+22"[Time Stamp] , "08/11/17,10:16:21+22" , 0[Error Code]

For the PDU Mode:

PDU gives you better leverage over text mode, as you can edit different SMS Submit headers. While working on Text mode, I was unable to send SMS to CDMA network from a GSM network. Later, switching to PDU mode made made it possible. So if you too are having problem sending SMS, from GSM network to a CDMA network, you can try switching to PDU mode.
To get the message deliver status report in PDU mode one  need to edit the TPDU parameters.
Let's take an example of sample TPDU SMS Submit code:
0031000A9189151111110000AA0CC8329BFD065DDF72363904
It's a hex code that has a message "Hello World!", destined to number "9851111111". I assume that you know the different meaning that the values of parameter determined.
The first  sub field "00" dictates modem to use SMSC number assigned by the SIM itself or by AT+CMSCA command. The second sub field "31" is the one that we are looking for. It says the SMSC that the message is of SUBMIT type and a delivery status report is requested from the SMSC about the SMS.  Rest, i believe, the reader knows the meaning and value of each sub field. For interested ones, a good tutorial about the SMS Submit PDU can be read here.

That's it. Now, for every SMS sent, we get a delivery report from the SMSC center, and can be read from the serial port. We can parse the Delivery report for further purpose such as error check or know SMS status.

6 comments:

Anonymous said...

Thanks for sharing. I'm not getting +CDS value. Also I received an error while entering AT+CNMI. Please help me.

praveenvishal@gmail.com

by
PRAVEEN.E

Bishwa Hang Rai said...

I assume you are working on text mode, so did you try the step above in sequence? i.e first setting CNMI to 1,0,0,1,0 and then later just to 2?

Unknown said...

Thanks lot,It was great help for me.Thanks again.

Bishwa Hang Rai said...

Thank you. It's a pleasure to be of help.

Unknown said...

I congratulate you on the article is very good
Now I have one question
as I can save the SMS delivery report in memory zte usb modem?
I tried AT + CNMI changing him = 1 instead of AT + CNMI = 2, but it did not work
I would appreciate help me
Thank you

Unknown said...

hi i am executing these commands but i am not getting the delivery report only i am getting
+CMGS: 130

OK
after that nothing is priting.
i am using UC15 modem on obd2 device.how to get delivery report.