XBee ZigBee communicator receives reports from other XBee modules from the Personal Network and writes it to the PC though the default Serial channel.
Dependencies: mbed BufferedSerial
Diff: main.cpp
- Revision:
- 0:b130d24d6fa3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 16 12:42:47 2021 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "BufferedSerial.h" + +BufferedSerial pc(USBTX,USBRX); +BufferedSerial xbee(PA_0, PA_1); + +char fb[1024]; + +int main() +{ + pc.baud(115200); + xbee.baud(38400); + int i = 0; + pc.printf("\r\nXbee COORDINATOR1 received:\r\n"); + while(1) { + while(xbee.readable()) { + fb[i++] = xbee.getc(); + } + if(i<20) { + wait(0.5); + } else { + for(int c=0; c<i; c++) { + pc.printf("%02x ",fb[c]); + } + pc.printf("\r\n"); + i = 0; + } + } +}