Hi
I am trying to parse the following string:
Code:
+CMT: "+44phonenumber",,"11/02/16,00:58:16+00"
MessageHere
The first line and second line are separated by a \r and \n.
Now, each of these messages will be proceeded by either OK or ERROR, as this is from a GSM module.
Could anyone help me parse out the whole thing and check?
I've got the following so far:
Code:
for(int i=0;i<78;i++)
{
data[i] = getch();
if((data[i] == 'O' || data[i] == 'K') && flag <2)
{
flag++;
}
if(flag==2)
{
break;
}
}
if(strstr(data,"stat")!=NULL)
{
__delay_ms(1000);
printf("AT+CMGF=1\r\n");
__delay_ms(1000);
printf("AT+CMGS=PHONENUMBERHERE\r\n");
__delay_ms(1000);
printf("I'm fine!\r\n");
__delay_ms(1000);
printf("\x001A");
__delay_ms(15000);
}
This works in practice when everything is on one line, but when OK and the message I'm trying to parse are on separate lines, the check against "stat" being in the string fails.
Any help with this would be greatly appreciated.
Thanks