#Include #Include #Include "UART.h": "/r/ncommand: %S" "Response:"
#Include #Include #Include "UART.h": "/r/ncommand: %S" "Response:"
1 #include <lpc214x.h>
2 #include <stdio.h>
3 #include "UART.h"
4
5 void delay(unsigned int time)
6 {
7 unsigned int i,j;
8 for(i=0;i<time;i++)
9 for(j=0;j<10000;j++);
10 }
11
12 void xbeeString(unsigned char *ch) //function to send a command to zigbee
13 {
14 printf("\r\ncommand: %s",ch);
15 printf("response:");
16 UART1_PutS(ch);
17 }
18
19 int main()
20 {
21 Uart0Init(9600);
22 Uart1Init(9600);
23 xbeeString("+++"); //enter command mode
24 delay(1000);
25 xbeeString("AT\r\n"); //check if all ok
26 delay(1000);
27 xbeeString("ATID 10\r\n"); //change network id to 10
28 delay(1000);
29 xbeeString("ATCN\r\n"); //exit command mode
30 delay(1000);
31 xbeeString("HELLO.... This is PAN ID 10\r\n"); //send a string on network id 10
32 delay(1000);
33 xbeeString("+++"); //enter command mode
34 delay(1000);
35 xbeeString("ATID 15\r\n"); //change network id to 15
36 delay(1000);
37 xbeeString("ATCN\r\n"); //exit command mode
38 delay(1000);
39 xbeeString("HELLO.... This is PAN ID 15\r\n"); //send a string on network id 15
40 delay(1000);
41
42 while(1);
43 }