Hepta communication

Dependencies:   mbed HeptaXbee

Fork of Lab7-01_template by HEPTA-Sat Training 2017~2018

Committer:
HEPTA
Date:
Sat Aug 24 05:27:42 2019 +0000
Revision:
18:1d058ffadf51
Parent:
16:b8cbd5235640

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
umeume 2:1c5cdb2c3e0f 2 #include "HeptaXbee.h"
umeume 2:1c5cdb2c3e0f 3
umeume 2:1c5cdb2c3e0f 4 Serial pc(USBTX,USBRX);
umeume 2:1c5cdb2c3e0f 5 HeptaXbee xbee(p9,p10);
umeume 5:c5ccb1b07e8f 6
umeume 2:1c5cdb2c3e0f 7 int main()
umeume 2:1c5cdb2c3e0f 8 {
HEPTA 15:85985edfb201 9 pc.baud(9600);
HEPTA 15:85985edfb201 10 xbee.baud(9600);
HEPTA 15:85985edfb201 11 pc.printf("Xbee Uplink Ok Mode\r\n");
HEPTA 15:85985edfb201 12 int rcmd=0,cmdflag=0;
HEPTA 15:85985edfb201 13 for(int i = 0; i < 10; i++) {
HEPTA 15:85985edfb201 14 xbee.printf("num = %d\r\n",i);
HEPTA 16:b8cbd5235640 15 xbee.xbee_receive(&rcmd,&cmdflag);
HEPTA 15:85985edfb201 16 pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag);
HEPTA 15:85985edfb201 17 if (cmdflag == 1) {
HEPTA 15:85985edfb201 18 if (rcmd == 'a') {
HEPTA 15:85985edfb201 19 pc.printf("Command Get %d\r\n",rcmd);
HEPTA 15:85985edfb201 20 xbee.printf("HEPTA Uplink OK\r\n");
HEPTA 15:85985edfb201 21 }
HEPTA 15:85985edfb201 22 xbee.initialize();
HEPTA 15:85985edfb201 23 }
HEPTA 15:85985edfb201 24 wait(1.0);
HEPTA 15:85985edfb201 25 }
umeume 2:1c5cdb2c3e0f 26 }