void main (void)
{
rw=0;
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,2,0,0,0\r"); // notification of new sms
delay_sms(1000);
SMSString( "AT+CMGR=1\r"); // AT command to read sms
IE=0X90; // Enable serial interrupt
delay_sms(5000);
// read sms and store in buffer msg1
read_text(msg1,rec_no,time_date);
clear();
IE=0X00; // Disable all interrupt
while(1);
}
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(msg1); // array having message
}