Hepta communication

Dependencies:   mbed HeptaXbee

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

Committer:
HEPTA
Date:
Wed Sep 06 04:36:19 2017 +0000
Revision:
13:b659c07d8755
Parent:
10:4d6870d0caa0
test

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 13:b659c07d8755 9 pc.baud(9600);
HEPTA 13:b659c07d8755 10 xbee.baud(9600);
HEPTA 13:b659c07d8755 11 pc.printf("Xbee Uplink Ok Mode\r\n");
HEPTA 13:b659c07d8755 12 int rcmd=0,cmdflag=0;
HEPTA 13:b659c07d8755 13 for(int i = 0; i < 10; i++) {
HEPTA 13:b659c07d8755 14 xbee.printf("num = %d\r\n",i);
HEPTA 13:b659c07d8755 15 xbee.xbee_recieve(&rcmd,&cmdflag);
HEPTA 13:b659c07d8755 16 pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag);
HEPTA 13:b659c07d8755 17 if (cmdflag == 1) {
HEPTA 13:b659c07d8755 18 if (rcmd == 'a') {
HEPTA 13:b659c07d8755 19 pc.printf("Command Get %d\r\n",rcmd);
HEPTA 13:b659c07d8755 20 xbee.printf("HEPTA Uplink OK\r\n");
HEPTA 13:b659c07d8755 21 }
HEPTA 13:b659c07d8755 22 xbee.initialize();
HEPTA 13:b659c07d8755 23 }
HEPTA 13:b659c07d8755 24 wait(1.0);
HEPTA 13:b659c07d8755 25 }
umeume 2:1c5cdb2c3e0f 26 }