![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi, i've managed to use AT commands to send an sms to a cell phone, i wanna read the first message , i know the command its AT+CMGR=0; for index 0 , but at hyperterminal there are many strings have been outputed that includes the phone number , time ..etc and finally the SMS , i dont know how to extract the sms from all these things ? also , the phone worked only when i tired CTR to 5V and RTS to GND , is this correct ?? im not sure how the AT command for sending SMS worked then ... | |
| |
| | #2 |
|
You'll have to decode the SMS header that the phone is sending to you, it's going to have a set format. Does this help? SMS messages and the PDU format Google is your friend =)
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." Last edited by Sceadwian; 25th April 2009 at 07:53 PM. | |
| |
| | #3 |
|
I'm not using PDU message , i use TEXT message instead ...
| |
| |
| | #4 |
|
I'm not sure what problem you're having, parse the text you receive and drop the information you don't want.
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." | |
| |
| | #5 |
|
Can you post what you got on your computer?
__________________ F.N. | |
| |
| | #6 |
|
yea sure AT+CMGR=1 +CMGR: "REC READ","+20101880936","","09/04/25,05:27:55+12" Switch1on OK | |
| |
| | #7 |
|
So what's the problem? The text message itself is on it's own line, it's sitting right there ready for you to pick it out =) After you send the AT command ignore up until the first carriage return (or CR/LF depending on what's being sent) and then save up until the next line.
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." | |
| |
| | #8 |
|
so im gonna save up to 20 charas in an array ?? i thought about save the full buffer and then strcmp it ? | |
| |
| | #9 |
|
The problem is in code ,how do i ignore the reading ? just read chars 20 times for examples ? | |
| |
| | #10 |
|
Well it depends on what other responses you might get back from the AT command, for example what happens if there is no text message to retrieve from the index specified, also how do you determine if this is a new SMS message or an old one? Are there any other error messages that could occur? If you're sure that your AT comand is going to result in a valid SMS message not some other error message then simply ignore everything received up until the first CR/LF and then save everything into a buffer until the next CR/LF that will be your SMS message. You could buffer the whole thing and strcomp that.
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." | |
| |
| | #11 |
|
I would use a terminal program such as bray's terminal which allows you to look at the data that's coming in in hex/dec/binary as well as show it in ascii, that way you can see if each line is a CR or CR/LF As soon a the CR or CR/LF pair was received do your comparison then.
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." | |
| |
| | #12 |
|
AT+CMGL="ALL" will retrieve all text messages when it text mode.
__________________ http://nottheboss.wordpress.com/ | |
| |
| | #13 |
|
You should also anticipate an errors if there are no SMS to read. Try clearing the phone's inbox and read the message. The phone should reply an error message and your software should recognize this. If there is no error, the message is on the second line after the cr/lf. If you have several messages in the inbox, try using AT+CMGR=1 to read the first message in the inbox. AT+CMGR=2 for the second, and so on. You can use AT+CMGL to read new messages that were not read yet. It will be helpful if you empty the inbox after reading so your inbox will not get full with an AT+CMGD=1 command to delete the message in memory1. | |
| |
| | #14 |
|
Here is something that might be useful "ahmedragia21".
Last edited by Manor_Villages; 26th April 2009 at 08:37 PM. | |
| |
| | #15 |
|
Thanks so much , manor villages
| |
| |
|
| Tags |
| gsm, phone, reading, sms |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| ESR Reading | Gregory | Electronic Theory | 4 | 29th April 2008 04:22 AM |
| rms reading | mpj111 | General Electronics Chat | 3 | 10th July 2006 01:37 PM |
| phone line used to power phone charger | evoke | Electronic Projects Design/Ideas/Reviews | 8 | 5th November 2004 11:07 AM |
| hooking a cell phone up to a phone line? | MPH2 | Electronic Projects Design/Ideas/Reviews | 2 | 16th July 2004 10:33 PM |
| Phone Speaker-phone | grrr_arrghh | Electronic Projects Design/Ideas/Reviews | 4 | 3rd March 2004 04:29 PM |