1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <stdio.h>
unsigned char phone_number_ok1[10+1]="0610111213";
unsigned char uart_buffer[50] =
{ '\r','\n','+','C','L','I','P',':',' ','"','0','6','1','0','1','1','1','2','1','3','"',',','1','2','9',',','"','"',',','1','2','8',',','"','"',',','0',0};
unsigned int LED1_IO = 0;
unsigned int num1_detected = 0;
void identify_phone_number(void)
{
if (strstr (uart_buffer,phone_number_ok1) == 0) {
LED1_IO = 0;
num1_detected = 0;
} else {
LED1_IO = 1;
num1_detected = 1;
}
}
void display(void) {
printf(" LED1_IO = %d, num1_detected = %d\n",
LED1_IO,num1_detected);
}
int main(void) {
printf("%s \n %s \n",phone_number_ok1,uart_buffer);
display();
identify_phone_number();
display();
return 0;
} |
Partager