Davechika
Newbie level 6
- Joined
- Oct 8, 2009
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Port-Harcourt,Nigeria
- Activity points
- 1,357
Hi, i want to extract sms message from AT+CMGR=1; AT command issued by 8051 to gsm Modem,
i get a response like this
+CMGR:"REC READ", "+2347060580383" "Date and time", sms text here
Ok.
i want to extract the sms text here using c/c++
here is my code but i simulated using keil with protues Vsm but still cant read anything on my SBUF.
i get a response like this
+CMGR:"REC READ", "+2347060580383" "Date and time", sms text here
Ok.
i want to extract the sms text here using c/c++
here is my code but i simulated using keil with protues Vsm but still cant read anything on my SBUF.
Code:
#include <reg51.h>
#include<string.h>
#include <stdio.h>
void init()
{
EA=0;
TL1=0XFD; //9600 @ 11.0592
TH1=0xFD;
TMOD=0x21;
SCON=0x50;
ET0=1;
TR1=1;
RI=0;
}
void SMSString(char*text) //function to send SMS using GSM modem
{
int count = 0;
while (text[count])
{
tx0(text[count++]);
}
}
void tx0(unsigned char x) //send data to serial port 0
{
while(TI==0){;}
TI=0;
SBUF=x;
}
unsigned char Rx_data( ) // returns data take note
{
while(!RI);//waits till a byte is recieved
RI = 0;
return(SBUF);
}
void main ()
{
P1=0x00;
init();
SMSString("AT\r"); // AT commands to initialize gsm modem
delay_sms(1000);
SMSString( "ATe0\r"); // turn off echo
delay_sms(1000);
SMSString( "AT&W\r"); // save settings
delay_sms(9000);
sSMSString( "AT+CMGF=1\r"); // select text mode for sms
delay_sms(90000);
SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms
delay_sms(90000);
SMSString( "AT+CMGR=1\r"); // AT command to read sms
/* i get a response like this
// +CMGR:"REC READ"," +95445677888 begin_of_the_skype_highlighting +95445677888 end_of_the_skype_highlighting", "Date and time", sms text here
// Ok. */
// read sms and store in buffer msg1
for(j=0;j<100;j++)
msg1[j] = Rx_data(); // stroring data in buffer for string compare.
delay_sms(9000);
i am using Protues with compim interfaced with gsm modem on the serial port.
i am able to send sms via protues but cant receive and extract sms.