cjchirag
Newbie level 2
- Joined
- Jul 30, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 11
hii,
my code is working only one time after we burn the program in the controller. i want this to be continuously waiting for cmti response and then read and send message by comparing the string.
please help me.
my code is working only one time after we burn the program in the controller. i want this to be continuously waiting for cmti response and then read and send message by comparing the string.
please help me.
Code:
int main(void)
{
int i,timeout=0;
unsigned char box, message[47], no[14], abc[20];
unsigned char *data;
unsigned char *code = "Temp";
unsigned char gotit[5];
UART_Init();
ADCSRA |= 1<<ADEN;
ADCSRA |= 1<<ADPS2;
ADMUX=0x40;
ADCSRA |= 1<<ADIE;
sei();
ADCSRA |= 1<<ADSC;
while(1)
{
i=0;
while(i<8)
{
box=UART_Receive();
abc[i]=box;
i++;
}
while(abc[6]=='I')
{
UART_Transmit_string("ATE0\r\n");
_delay_ms(1000);
UART_Transmit_string("AT\r\n");
_delay_ms(1000);
UART_Transmit_string("AT+CMGF=1;\r\n");
_delay_ms(1000);
UART_Transmit_string("AT+CMGR=1;\r\n");
_delay_ms(1000);
while((UART_Receive()!=',')&&(timeout<100000))
{
timeout++;
}
timeout=0;
for(i=0;i<48;i++)
{
box=UART_Receive();
message[i]=box;
}
for(i=1;i<14;i++)
{
no[i-1]=message[i];
}
data = strstr(message, code);
for(i=0;i<4;i++)
{
gotit[i]=data[i];
}
if ( strcmp(gotit, code) == 0 )
{
//UART_Transmit_string("AT\r\n");
//_delay_ms(40);
//UART_Transmit_string("AT+CMGF=1;\r\n");
//_delay_ms(40);
UART_Transmit_string("AT+CMGS=\"");
UART_Transmit_string(no);
UART_Transmit_string("\"\r\n");
_delay_ms(200);
UART_Transmit_string("coming");
UART_Transmit_string("\r\n");
_delay_ms(500);
uart_transmitchar(0x1A);
_delay_ms(200);
}
else
{
UART_Transmit_string("AT\r\n");
_delay_ms(1000);
UART_Transmit_string("AT+CMGF=1;\r\n");
_delay_ms(1000);
UART_Transmit_string("AT+CMGS=\"");
UART_Transmit_string(no);
UART_Transmit_string("\"\r\n");
UART_Transmit_string("u r nt authorised");
UART_Transmit_string("\r\n");
_delay_ms(500);
uart_transmitchar(0x1A);
_delay_ms(200);
}
UART_Transmit_string("AT+CMGD=1;\r\n");
_delay_ms(1000);
memset( abc, '\0', sizeof(abc) );
memset( message, 0, sizeof(message) );
memset( gotit, 0, sizeof(gotit) );
memset( no, 0, sizeof(no) );
memset( data, 0, sizeof(data) );
_delay_ms(2000);
}
}
}
Last edited by a moderator: