Hello world program showing use of xbee-lib. Sends data read from serial terminal, then waits for a response.
main.cpp
00001 #include "mbed.h" 00002 #include "xbee.h" 00003 00004 xbee xbee1(p9,p10,p11); //Initalise xbee_lib 00005 Serial pc(USBTX, USBRX); //Initalise PC serial comms 00006 00007 int main() 00008 { 00009 char send_data[202]; //Xbee buffer size is 202 bytes 00010 char read_data[202]; //Xbee buffer size is 202 bytes 00011 00012 while(1) { 00013 pc.scanf("%s",send_data); //Read data from serial console 00014 xbee1.SendData(send_data); //Send data to XBee 00015 xbee1.RecieveData(read_data,0); //Read data from the XBee 00016 pc.printf("You said:%s",read_data); 00017 } 00018 }
Generated on Tue Jul 12 2022 16:35:00 by 1.7.2