
Serial wifi_uart(PA_9, PA_10);
Serial zigbee_uart(PC_6, PC_7);
Serial PC(USBTX, USBRX);
DigitalOut myled(LED1);
DigitalOut zigbee_uart_E(D7);    //zigbee_uart

char s[1024];

void callback()           //The zigbee_uart Receive interrupt handler function
{
    zigbee_uart.scanf("%s",s);
	  wifi_uart.printf("AT+CIPSEND=2,5\r");
	  wait(1);
    wifi_uart.printf("%s\r\n",s);
}
void init_wifi()
{
	wifi_uart.printf("AT+WJAP=TP_LINK,12345678\r");
	wait(1);
	wifi_uart.printf("AT+CIPSTART=2,udp_broadcast,172.16.55.255,8080,4001\r");
	wait(1);
}
int main(void) 
{
	wifi_uart.baud(115200);
	zigbee_uart.baud(115200);
	
	init_wifi();
	
  while(1) 
	{ 
	   zigbee_uart.attach(&callback);
     zigbee_uart_E = 0;               //receive
     myled = !myled;
		 wait(5);
  }
}
