i=0;
for (;;)
{ abcce:
usart_buff[i]=USART0_Receive();
if(usart_buff[i]=='+')
{
usart_buff[i]=USART0_Receive();
if(usart_buff[i]=='C')
{
usart_buff[i]=USART0_Receive();
if(usart_buff[i]=='L')
{
do{
usart_buff[i]=USART0_Receive();
}
while (usart_buff[i]!=':');
USART0_Receive();
//USART0_Receive();
USART0_Receive();
//do{
i=7;
for (int d=0;d<8;d++)
numb[i--]=USART0_Receive();
//}
//while(numb[i]!=',');
USART0_TransmitString("\r ATH\r");
_delay_ms(250);
numb[8]='\0';
//USART0_TransmitString(numb);
if(strncmp(numb,sm,8)==0)
USART0_TransmitString("switch on");
else if(match_mstr()==1)
USART0_TransmitString("switch on");
else if(match_user()==1)
USART0_TransmitString("switch on");
goto abcce;
}
else if (usart_buff[i]=='M')
{
usart_buff[i]=USART0_Receive();
if(usart_buff[i]=='T')
{
for(int d=0;d<8;d++)
{
USART0_Receive();
}
i=0;
index[0]=USART0_Receive();
index[1]=USART0_Receive();
//USART0_TransmitString("\r index : \r");
//USART0_TransmitString(index);
// USART0_Transmit('\r');
// index[]="02";
USART0_TransmitString("AT+CMGR=");
USART0_TransmitString(index);
USART0_Transmit('\r');
while(USART0_Receive()!=',');
USART0_Receive();
USART0_Receive();
USART0_Receive();
USART0_Receive();
USART0_Receive();
i=7;
//while(numb[i]!=0x0d)
for (int d=0;d<8;d++)
{
numb[i--]=USART0_Receive();
}
//
USART0_TransmitString(numb);
USART0_TransmitString("\r");
int w=0;
while(USART0_Receive()!=0x0d);
w=-1;
msg[-1]=USART0_Receive();
while(msg[w]!=0x0d)
{
msg[++w]=USART0_Receive();
//w++;
}
msg[w]='\0';
USART0_TransmitString("\r at+cmgd=1,4\r");
USART0_TransmitString(msg);
//char chr[5];