Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 25th April 2009, 07:50 PM   #1
Default reading SMS from Gsm phone

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 ...
ahmedragia21 is offline  
Old 25th April 2009, 07:53 PM   #2
Default

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.
Sceadwian is offline  
Old 25th April 2009, 07:55 PM   #3
Default

I'm not using PDU message , i use TEXT message instead ...
ahmedragia21 is offline  
Old 25th April 2009, 08:06 PM   #4
Default

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."
Sceadwian is offline  
Old 25th April 2009, 08:10 PM   #5
Default

Can you post what you got on your computer?
__________________
F.N.
Funny NYPD is offline  
Old 25th April 2009, 08:26 PM   #6
Default

yea sure

AT+CMGR=1
+CMGR: "REC READ","+20101880936","","09/04/25,05:27:55+12"
Switch1on

OK
ahmedragia21 is offline  
Old 25th April 2009, 08:41 PM   #7
Default

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."
Sceadwian is offline  
Old 25th April 2009, 08:43 PM   #8
Default

so im gonna save up to 20 charas in an array ??
i thought about save the full buffer and then strcmp it ?
ahmedragia21 is offline  
Old 25th April 2009, 08:45 PM   #9
Default

The problem is in code ,how do i ignore the reading ?
just read chars 20 times for examples ?
ahmedragia21 is offline  
Old 25th April 2009, 08:55 PM   #10
Default

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."
Sceadwian is offline  
Old 25th April 2009, 08:57 PM   #11
Default

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."
Sceadwian is offline  
Old 25th April 2009, 10:55 PM   #12
Default

AT+CMGL="ALL"

will retrieve all text messages when it text mode.
Diver300 is offline  
Old 26th April 2009, 09:49 AM   #13
Default

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.
Silversolar is offline  
Old 26th April 2009, 08:35 PM   #14
Default

Here is something that might be useful "ahmedragia21".
Attached Files
File Type: pdf Report.pdf (896.8 KB, 62 views)

Last edited by Manor_Villages; 26th April 2009 at 08:37 PM.
Manor_Villages is offline  
Old 26th April 2009, 11:45 PM   #15
Default

Thanks so much , manor villages
ahmedragia21 is offline  
Reply

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



All times are GMT. The time now is 02:10 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker