PDA

View Full Version : Reading a SMS to an array



KA5MAL
- 10th June 2008, 05:48
Dear friends. I need some help reading a SMS into an array. I tried the below code but it doesn't seem to work properly.

I am using harware interrupts to get into an interrupt routine when a SMS is received. I want to check for +CMTI: "SM" ,1 string and extract the SMS location to a variable called sms_location. Then I want to use AT_CMGR command to read that SMS location and put the receiving message into sms_array.

hserin 1000, start, [wait("CMTI:"), skip 6, DEC2 sms_location]
hserout ["AT+CMGR=", sms_location, 13, 10]
hserin 1000, ff, [STR sms_array\100]


Then I can parse the sms_array and remove all unnecessary data. The above code segment compiles but I it doesn't read the correct SMS location.

instead if I replace the 2nd line above with
hserout ["AT+CMGR=1", 13, 10]
then it reads the SMS location 1 and puts the data to smsm_array nicely.

I would appreciate any help from you nice people.

enigma
- 15th June 2008, 13:40
Hi

Just a thought, I could be wrong.
when you use hserin 1000, start, [wait("CMTI:"), skip 6, DEC2 sms_location, sms_location will contain a number, 2 digits say 01.
I have a feeling that the modem will require it passed in ASCII and not in the form its in.
when you do hserout ["AT+CMGR=1", 13, 10] I think it will send the 1 as ASCII $31 Decimal 49 and what your sms_location passes is ASCII char 11

Cheers Pete

KA5MAL
- 16th June 2008, 06:43
Hi Pete,

Thanks a lot for pointing it out. Yes you are right. I have changed the line to

hserout ["AT+CMGR=", #sms_location, 13, 10]

Now it sends ASCII and it works fine. !!!

Kamal

enigma
- 17th June 2008, 17:24
Hi KA5MAL

Glad to be of help!

Cheers Pete