Pages: [1]   Go Down
Author Topic: Sim900 Read SMS edge case  (Read 306 times)
0 Members and 1 Guest are viewing this topic.
The Netherlands
Offline Offline
Full Member
***
Karma: 2
Posts: 197
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have a question about reading an SMS message using AT commands. I would like to know how to handle SMS messages containing OK or ERROR, because that sgnifies the end of the command response, eg.

Code:
AT+CMGR=3

+CMGR: "REC READ","+85291234567",,"07/04/20,10:08:02+32",145,4,0,0,"+85290000000",145,49
It is easy to read text messages via AT commands.

OK

Now what if the message contains OK/Error?

Code:
AT+CMGR=3

+CMGR: "REC READ","+85291234567",,"07/04/20,10:08:02+32",145,4,0,0,"+85290000000",145,49
It is easy to trick the parser

OK. 

Message continues here

OK <- proper termination

Any ideas?
Logged

Rob
Follow my progress on http://simplicate.weebly.com

Czech Republic
Offline Offline
Sr. Member
****
Karma: 4
Posts: 313
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I try little trick and it works:
Code:
AT+CMGR=3;+CCLK?

+CMGR: "REC READ","+420773684528","","13/12/24,00:44:33+04"
It is easy to trick the parser!

OK

As you can see, the message continues here...

+CCLK: "13/12/23,00:46:37+04"

OK
You may parse until +CCLK is found
« Last Edit: December 23, 2013, 06:57:39 pm by K5CZ » Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

The Netherlands
Offline Offline
Full Member
***
Karma: 2
Posts: 197
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is a real nice solution.

That is, until somebody sends +CCLK !
Perhaps i should investigate if reading the SMS in PDU is feasible, at least i get proper encoding and a length descriptor...

http://www.smartposition.nl/resources/sms_pdu.html

Logged

Rob
Follow my progress on http://simplicate.weebly.com

Pages: [1]   Go Up
Jump to: