Hello world program showing use of xbee-lib. Sends data read from serial terminal, then waits for a response.

Dependencies:   mbed xbee_lib

Dependents:   potSend

Committer:
tristanjph
Date:
Fri Aug 31 14:46:32 2012 +0000
Revision:
0:9cbddcc86466
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 0:9cbddcc86466 1 #include "mbed.h"
tristanjph 0:9cbddcc86466 2 #include "xbee.h"
tristanjph 0:9cbddcc86466 3
tristanjph 0:9cbddcc86466 4 xbee xbee1(p9,p10,p11); //Initalise xbee_lib
tristanjph 0:9cbddcc86466 5 Serial pc(USBTX, USBRX); //Initalise PC serial comms
tristanjph 0:9cbddcc86466 6
tristanjph 0:9cbddcc86466 7 int main()
tristanjph 0:9cbddcc86466 8 {
tristanjph 0:9cbddcc86466 9 char send_data[202]; //Xbee buffer size is 202 bytes
tristanjph 0:9cbddcc86466 10 char read_data[202]; //Xbee buffer size is 202 bytes
tristanjph 0:9cbddcc86466 11
tristanjph 0:9cbddcc86466 12 while(1) {
tristanjph 0:9cbddcc86466 13 pc.scanf("%s",send_data); //Read data from serial console
tristanjph 0:9cbddcc86466 14 xbee1.SendData(send_data); //Send data to XBee
tristanjph 0:9cbddcc86466 15 xbee1.RecieveData(read_data,0); //Read data from the XBee
tristanjph 0:9cbddcc86466 16 pc.printf("You said:%s",read_data);
tristanjph 0:9cbddcc86466 17 }
tristanjph 0:9cbddcc86466 18 }