Los Putacos / Mbed OS WearableDevice_Nucleo_New

Dependencies:   MPU9250_SPI

Fork of WearableDevice_Nucleo by Los Putacos

Revision:
17:f98597cd2efc
Parent:
13:837ea602def0
Child:
18:7f9c2b8541e1
--- a/main.cpp	Tue Oct 17 11:32:45 2017 +0000
+++ b/main.cpp	Tue Oct 17 12:04:41 2017 +0000
@@ -23,6 +23,8 @@
 #include "event.h"
 #include "pin.h"
 #include "MPU9250.h"
+
+#include "XBeeLib.h"
 //-----------------------------------------------------------------
 
 //-----------------------------------------------------------------
@@ -32,7 +34,7 @@
 EventQueue queue(32 * EVENTS_EVENT_SIZE); //Event
 
 Serial pc(USBTX, USBRX); // PC Serial (Debug)
-Serial xbee(PA_2, PA_3); // Xbee
+// Serial xbee(PA_2, PA_3); // Xbee
 
 MPU9250 imu; // IMU MPU-9255 by Kris Winer 
 //-----------------------------------------------------------------
@@ -90,6 +92,8 @@
   
 //-----------------------------------------------------------------
 
+using namespace XBeeLib;
+
 //-----------------------------------------------------------------
 int main()
 {
@@ -97,10 +101,20 @@
     
     //Reading the analog input (Microphone)  array = micro.read_u16();
     
+    XBeeZB xbee = XBeeZB(RADIO_TX, RADIO_RX, RADIO_RESET);
+    xbee.init();
     time_stamp.start(); // Start timer
     
     while (true) {
         queue.dispatch();
+        
+        const uint8_t data[] = "Hello, XBees!";
+    const uint16_t data_len = sizeof data / sizeof data[0] - 1;
+    
+    TxStatus txStatus = xbee.send_data_to_coordinator(data, data_len);
+    if (txStatus != TxStatusSuccess) {
+        printf("send_data_broadcast() failed with error %d\n", (int)txStatus);
+    }
     }
 }
 //-----------------------------------------------------------------