How can i Extract Sms Message From AT command response
Sun May 08 2011, 01:48 pm
Yeah Romel, Check this link
http://www.8051projects.net/forum-t41321.html
Here Mojaka and Ajay has given very good suggestions.
http://www.8051projects.net/forum-t41321.html
Here Mojaka and Ajay has given very good suggestions.
Mon Jul 11 2011, 02:46 am
any update of this thread?? is ti done?romel_emperado
@romel_emperado
as for the project,it worked very well but i had issues with responding to a second command after the first one,i tryed clearing msg1 and reseting abc = 0 after reception but didnt work.
so any ideas is still welcomed.
Mon Jul 11 2011, 09:16 am
@Dave Chika,
Try using arrays not pointers in read_msg().
If i use that function controller was getting reset by itself.
Try using arrays not pointers in read_msg().
If i use that function controller was getting reset by itself.
Tue Jul 12 2011, 04:00 am
@Dave Chika,
Try using arrays not pointers in read_msg().
If i use that function controller was getting reset by itself.kirangowle
@kirangowle
pls i need more clarity here,a line or two of codes will be sufficient.
Tue Jul 12 2011, 09:17 am
like this
void read_msg(unsigned char msg[]) { char i; i=59 // i am manually moving the location to the starting char of recd msg. while(msg[i]!= '\r') { lcddata(msg[i]);// display the msg on LCD. i++; }
Fri Dec 28 2012, 06:37 pm
Sorry for reviving this thread.
why do I get error at my LCD? Im using the code of majoka(downloaded the array.rar file.) and use the latest code he suggested.
hope someone would reply.
thanks.
why do I get error at my LCD? Im using the code of majoka(downloaded the array.rar file.) and use the latest code he suggested.
hope someone would reply.
thanks.
Fri Dec 28 2012, 10:10 pm
@ DaveChika
@ jepoy12
what are the latest problems that anyone facing here with my code
i will explain that
there can be many reasons of errors
and are u using modem or any cell phone
and also paste code here then i will guess where can be the problem
@ jepoy12
what are the latest problems that anyone facing here with my code
i will explain that
there can be many reasons of errors
and are u using modem or any cell phone
and also paste code here then i will guess where can be the problem
Sat Dec 29 2012, 12:33 pm
Thanks for the reply.
Heres the code I used and the result. Im using a modem btw.
Heres the code I used and the result. Im using a modem btw.
#include <REGX52.H> #define LCD P1 #define LCD_EN 0x80 #define LCD_RS 0x20 //LCD Commands #define LCD_SETMODE 0x04 #define LCD_SETVISIBLE 0x08 #define LCD_SETFUNCTION 0x28 #define LCD_SETDDADDR 0x80 void delayms(unsigned char); void delayus(unsigned char); void lcd_init(); void lcd_reset(); void lcd_cmd (char); void lcd_data(unsigned char); void lcd_str (unsigned char *); void clear(void); void tx0(unsigned char); void delay_sms (unsigned int); void SMSString(char*text) ; void init(); void read_text(unsigned char * , unsigned char * , unsigned char *); unsigned char j,abc; unsigned char idata msg1[150]; unsigned char rec_no[20]; unsigned char time_date[20]; void serial () interrupt 4 { msg1[abc]=SBUF; abc++; RI=0; } void main (void) { /* if u do not want to check "OK" response after each AT command then enable interrupt IE=0X90 ; after last AT command of SMSString( "AT+CMGR=1\r"); // AT command to read sms so after that u recieve a no of bytes from modile if u disable it then u do not reieve it even data comes use a virtual terminal in Proteus run a Proteus and right click on virtual terminal and click on option echo character display. in Proteus there is no mobile model so u should enter text in hyper terminal to suppose gsm Modem is responding. use serial receive interrupt to receive data check here */ clear(); init(); lcd_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(1000); SMSString( "AT+CMGF=1\r"); // select text mode for sms delay_sms(1000); SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms delay_sms(1000); SMSString( "AT+CMGR=901\r"); // AT command to read sms IE=0X90; // Enable serial interrupt delay_sms(2000); /* i get a response like this // +CMGR: "REC READ" ,"+2347060580383","10/10/23,14:29:33+04" // device1 off // Ok. */ // read sms and store in buffer msg1 read_text(msg1,rec_no,time_date); clear(); IE=0X00; // Disable all interrupt while(1); } void init(void) { j=0; abc=0; TL1=0XFD; //9600 @ 11.0592 TH1=0xFD; TMOD=0x20; SCON=0x50; TR1=1; } void SMSString(unsigned char* text) //function to send SMS using GSM modem { while (*text) { tx0(*text++); } } void tx0(unsigned char x) //send data to serial port 0 { EA=0; SBUF=x; while(TI==0); TI=0; EA=1; } void delay_sms (unsigned int count) { unsigned int i; // Keil v7.5a while(count) { i = 115; while(i> 0) i--; count--; } } void read_text( unsigned char *msg,unsigned char *no ,unsigned char *time) { unsigned char *temp; temp=msg; do msg++; while(*msg!='+'); do msg++; while(*msg!='+'); // reaching at no do *no++=*msg++; while(*msg!='"'); // reaching at time *no++='\0'; msg++; msg++; msg++; do *time++=*msg++; while(*msg!='+'); // raching at message *time='\0'; do msg++; while(*msg!='\n'); msg++; do *temp++=*msg++; while(*msg!='\r'); // reaching at end of message *temp='\0'; lcd_cmd(0x80); // ist line address lcd_str(rec_no); // array having receipt no lcd_cmd(0xC0); // 2nd line address lcd_str(time_date); // array having date and time lcd_cmd(0x94); // 3rd line address lcd_str(msg1); // array having message } void lcd_reset() { LCD = 0xFF; delay_sms(40); LCD = 0x03+LCD_EN; LCD = 0x03; delay_sms(40); LCD = 0x03+LCD_EN; LCD = 0x03; delay_sms(5); LCD = 0x03+LCD_EN; LCD = 0x03; delay_sms(5); LCD = 0x02+LCD_EN; LCD = 0x02; delay_sms(5); } void lcd_init () { lcd_reset(); lcd_cmd(LCD_SETFUNCTION); // 4-bit mode - 1 line - 5x7 font. lcd_cmd(LCD_SETVISIBLE+0x04); // Display no cursor - no blink. lcd_cmd(LCD_SETMODE+0x02); // Automatic Increment - No Display shift. lcd_cmd(LCD_SETDDADDR); // Address DDRAM with 0 offset 80h. } void lcd_cmd (char cmd) { LCD = ((cmd > > 4) & 0x0F)|LCD_EN; LCD = ((cmd > > 4) & 0x0F); LCD = (cmd & 0x0F)|LCD_EN; LCD = (cmd & 0x0F); delay_sms(1); } void lcd_data (unsigned char dat) { LCD = (((dat > > 4) & 0x0F)|LCD_EN|LCD_RS); LCD = (((dat > > 4) & 0x0F)|LCD_RS); LCD = ((dat & 0x0F)|LCD_EN|LCD_RS); LCD = ((dat & 0x0F)|LCD_RS); delay_sms(1); } void clear(void) { unsigned char a; for(a=0;a<100;a++) msg1[a]=0x00; } void lcd_str (unsigned char *str) { while(*str){ lcd_data(*str++); } }
Powered by e107 Forum System