GSM MODEM with 8051
Mon Nov 29 2010, 10:37 am
Hi Ajay,
I want to do in 1st method. i.e through interrupt for notification of new msg arrival.
Can u suggest which interrupt vll be more useful( i have used serial int already in program).
I want to do in 1st method. i.e through interrupt for notification of new msg arrival.
Can u suggest which interrupt vll be more useful( i have used serial int already in program).
Mon Nov 29 2010, 11:43 am
hi kirangowle
in serial communication serial interrupt is use ful
enable serial interrupts and wait for notification of new message
if u received the notification of new sms then send command to modem to read sms otherwise do again the previous job
in serial communication serial interrupt is use ful
enable serial interrupts and wait for notification of new message
if u received the notification of new sms then send command to modem to read sms otherwise do again the previous job
Mon Nov 29 2010, 05:50 pm
Hi mojaka and ajay,
In LCD garbage values are being displayed.
I m bit confused how to check a new msg.becoz wen i reset the controller. controller again sents all AT commands at this time modem notification had been gne without knowing to controller.
//main() SMSString("AT\r"); // AT commands to initialize gsm modem delay(50); SMSString( "ATe0\r"); // turn off echo delay(50); SMSString( "AT&W\r"); // save settings delay(50); SMSString( "AT+CMGF=1\r"); // select text mode for sms delay(50); SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms delay(40); //New msg indication. // +CMTI: "SM",3 IE=0X90; // Enable serial interrupt delay(10); *index=read_notification(msg1); clear(); IE=0x00; SMSString( "AT+CMGR="); // AT command to read sms SMSString(index); SMSString('\r'); IE=0X90; // Enable serial interrupt delay(80); // read sms and store in buffer msg1 read_text(msg1,rec_no,time_date); clear(); IE=0X00; // Disable all interrupt while(1); char read_notification(unsigned char *msg) { unsigned char array[15],i,index_no; i=0; do msg++; while(*msg!='+'); // to check for first '+'. do { array[i]=*msg++; i++; }while(*msg!='\n'); // Check for new line. i--; if(array[0]=='C' && array[1]== 'M' && array[2]=='T' && array[3]== 'I') { index_no=array[i]; return index_no; }
In LCD garbage values are being displayed.
I m bit confused how to check a new msg.becoz wen i reset the controller. controller again sents all AT commands at this time modem notification had been gne without knowing to controller.
Tue Nov 30 2010, 01:21 am
hi kirangowle
do little modify ur code
let say here u want that when new message notification received u display on lcd that new message receive
for that try this
u can use string comparison using built in library or store a +CMTI: "SM",3
in rom of 8051 and compare it with array values instead of long if else statements
do this the go to nrxt to decode the message
do little modify ur code
let say here u want that when new message notification received u display on lcd that new message receive
for that try this
/main() SMSString("AT\r"); // AT commands to initialize gsm modem delay(50); SMSString( "ATe0\r"); // turn off echo delay(50); SMSString( "AT&W\r"); // save settings delay(50); SMSString( "AT+CMGF=1\r"); // select text mode for sms delay(50); SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms IE=0X90; // Enable serial interrupt delay(80); unsigned read_notification(unsigned char *msg) { unsigned char array[15],i,index_no; i=0; do msg++; while(*msg!='+'); // to check for first '+'. do { array[i]=*msg++; i++; }while(*msg!='\n'); // Check for new line. i--; if(array[0]=='C' && array[1]== 'M' && array[2]=='T' && array[3]== 'I' && array[4]== ':' && array[5]== ' ' && array[6]== '"' && array[7]== 'S' && array[8]== 'M' && array[9]== '" && array[10]== ',' && array[11]== '3'') { // display on lcd that new message indication }
u can use string comparison using built in library or store a +CMTI: "SM",3
in rom of 8051 and compare it with array values instead of long if else statements
do this the go to nrxt to decode the message
Tue Nov 30 2010, 12:38 pm
Hi mojaka,
Whether i m comparing correctly with \n r it should be '\r'..
In +CMTI: "SM",3(\r or \n is there).
I m getting junk values on LCD from above program.
Whether i m comparing correctly with \n r it should be '\r'..
unsigned read_notification(unsigned char *msg) { unsigned char array[15],i; i=0; do msg++; while(*msg!='+'); // to check for first '+'. do { array[i]=*msg++; i++; }while(*msg!='\n'); // Check for new line. i--; if(array[0]=='C' && array[1]== 'M' && array[2]=='T' && array[3]== 'I' && array[4]== ':' && array[5]== ' ' && array[6]== '"' && array[7]== 'S' && array[8]== 'M' && array[9]== "'" && array[10]== ',' && array[11]== '3' && array[12]== '\n') { lcdcmd(0xc0); lcdstr("New Msg"); delay(100); } return 0; }
In +CMTI: "SM",3(\r or \n is there).
I m getting junk values on LCD from above program.
Tue Nov 30 2010, 12:52 pm
in the above code lcd should display a new message otherwise not any thing do a step by step
first just receive a notification from modem compare it and display it is ok etc to confirm this step
then goto next one
first just receive a notification from modem compare it and display it is ok etc to confirm this step
then goto next one
Tue Nov 30 2010, 03:10 pm
Hi Mojaka,
Its working !! I have given displays at each loop just to check whether it enter it or not.
LCD displays "New MSG"
Now how to read that index no and send it to modem.
As per abv function index no will be in array[12] loc.
Now how to send this no. after the instruction AT+CMGR=?
Its working !! I have given displays at each loop just to check whether it enter it or not.
LCD displays "New MSG"
unsigned read_notification(unsigned char *msg) { unsigned char array[15],i; i=0; do { msg++; i++; lcdcmd(0x80); lcdstr("InLoop1"); delay(40); }while(*msg!='+' && i!=15); // If + doesnt aries then it ll hanged so i used a counter(i).. i=0; do { array[i]=*msg++; lcdcmd(0x80); lcdstr("InLoop2"); delay(40); i++; }while(*msg!='\n' && i!=15); // Check for new line. i--; lcdcmd(0x80); lcdstr("OutLoop2"); delay(40); if(array[0]=='+' && array[1]=='C' && array[2]== 'M' && array[3]=='T' && array[4]== 'I' && array[5]== ':' && array[6]== ' ' && array[7]== '"' && array[8]== 'S' && array[9]== 'M' && array[10]== '"' && array[11]== ',' && array[12]== '3' /*&& array[13]== '\n'*/) { lcdcmd(0x80); lcdstr(" New MSG "); delay(200); } lcdcmd(0x80); lcdstr("OutLoop3"); delay(40); return 0; } void main(){ clear(); lcdinit(); lcdcmd(0x80); lcddata('K'); delay(10); init(); SMSString("AT\r"); // AT commands to initialize gsm modem delay(50); SMSString( "ATe0\r"); // turn off echo delay(50); SMSString( "AT&W\r"); // save settings delay(50); SMSString( "AT+CMGF=1\r"); // select text mode for sms delay(50); SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms delay(40); while(1) { IE=0X90; // Enable serial interrupt delay(10); read_notification(msg1); } }
Now how to read that index no and send it to modem.
As per abv function index no will be in array[12] loc.
Now how to send this no. after the instruction AT+CMGR=?
Tue Nov 30 2010, 04:45 pm
you can replace this
with a better loop, coz its not compulsory that you always get 3 in new sms indication. so check it like this..
if(array[0]=='+' && array[1]=='C' && array[2]== 'M' && array[3]=='T' && array[4]== 'I' && array[5]== ':' && array[6]== ' ' && array[7]== '"' && array[8]== 'S' && array[9]== 'M' && array[10]== '"' && array[11]== ',' && array[12]== '3' /*&& array[13]== '\n'*/)
with a better loop, coz its not compulsory that you always get 3 in new sms indication. so check it like this..
if(strncmp(array, "+CMTI", 5) == 0){ //Yes its a new message .. //Now lets read the index //we first have to truncate the array... to use string functions array[14] = '\0'; //coz array[12] and array[13] may contain your index index = atoi(&array[12]); //now index is having 3 or 10 or whatever index comes with notification. }
kirangowle like this.
Wed Dec 01 2010, 12:26 pm
Hi
index = atoi(&array[12]);
atoi is an built in function?
While compling error missing prototype.
I have added header file string.h & absacc.h
Wed Dec 01 2010, 12:32 pm
hi
it is an built in fuction of STDLIB.h
it Converts string to integer
syntax is as
int atoi ( const char * str );
it is an built in fuction of STDLIB.h
it Converts string to integer
syntax is as
int atoi ( const char * str );
Powered by e107 Forum System