Sim900 Read SMS edge case

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.

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?

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?

I try little trick and it works:

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

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