Hepta communication

Dependencies:   mbed HeptaBattery SDFileSystem HeptaCamera_GPS Hepta9axis HeptaTemp HeptaXbee

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

Revision:
13:3e9a9114eb8c
Parent:
10:4d6870d0caa0
Child:
14:bf2ca1f15a76
--- a/main.cpp	Tue Sep 05 17:15:38 2017 +0000
+++ b/main.cpp	Fri Sep 08 22:56:42 2017 +0000
@@ -12,14 +12,32 @@
 HeptaCamera_GPS cam_gps(p13, p14,p25,p24);
 Hepta9axis n_axis(p28,p27,0xD0,0x18);
 HeptaTemp temp(p17);
-HeptaBattery bat(p16,p26);
-
-DigitalOut myled(LED1);
+HeptaBattery battery(p16,p26);
 
 int main()
 {
-    myled = 1;
-    wait(0.5);
-    myled = 0;
-    wait(0.5);
+    int rcmd=0,cmdflag=0;
+    while(1) {
+        wait(1.0);
+        xbee.xbee_recieve(&rcmd,&cmdflag);
+        pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag);
+        if (cmdflag == 1) {
+            pc.printf("Command Get %d\r\n",rcmd);
+            if(rcmd == 'h') {
+                cam_gps.gps_setting();
+                char gx[4],gy[4],gz[4],ax[4],ay[4],az[4],mx[4],my[4],mz[4],lad[8],log[8],height[4],bt[4],temper[4];
+                for(int i = 0; i < 50; i++) {
+                    n_axis.sen_gyro_u16(gx,gy,gz);
+                    n_axis.sen_acc_u16(ax,ay,az);
+                    n_axis.sen_mag_u16(mx,my,mz);
+                    battery.vol_u16(bt);
+                    temp.temp_sense_u16(temper);
+                    cam_gps.lat_log_sensing_u16(lad,log,height);
+                    xbee.putc('H');
+                    xbee.xbee_transmit(gx,gy,gz,ax,ay,az,mx,my,mz,lad,log,height,bt,temper);
+                }
+                xbee.initialize();
+            }
+        }
+    }
 }
\ No newline at end of file