MBED code for Xbee unit running on chase car

Dependencies:   CUER_CAN XBeeLib mbed

Revision:
12:c492d4bc45cd
Parent:
11:c10bc0fb801a
Child:
13:a6f0f8990842
--- a/main.cpp	Mon Sep 11 06:42:21 2017 +0000
+++ b/main.cpp	Wed Sep 13 05:37:30 2017 +0000
@@ -12,18 +12,22 @@
 
 #include "mbed.h"
 #include "XBeeLib.h"
+#include "CAN_Parser_Telemetry.h"
 #if defined(ENABLE_LOGGING)
 #include "DigiLoggerMbedSerial.h"
 using namespace DigiLog;
+using namespace CAN_IDs;
 #endif
 
+#define DEBUG                   1
+
 using namespace XBeeLib;
 
 Serial *log_serial;
  
 static void receive_cb(const RemoteXBee802& remote, bool broadcast, const uint8_t *const data, uint16_t len)
 {
-    if (remote.is_valid_addr16b()) {
+    /*if (remote.is_valid_addr16b()) {
         log_serial->printf("\r\nGot a %s 16-bit RX packet [%04x], len %d\r\nData: ", broadcast ? "BROADCAST" : "UNICAST", remote.get_addr16(), len);
     } else {
         log_serial->printf("\r\nGot a %s 64-bit RX packet [%08x:%08x], len %d\r\nData: ", broadcast ? "BROADCAST" : "UNICAST", remote.get_addr64(), len);
@@ -32,7 +36,11 @@
     for (int i = 0; i < len; i++)
         log_serial->printf("%02x", data[i]);
 
-    log_serial->printf("\r\n");
+    log_serial->printf("\r\n");*/
+    if (DEBUG) log_serial->printf("Incoming Xbee packet received! \r\n");
+
+    can_send(generateCANPackets(data));
+    if (DEBUG) log_serial->printf("\r\n");
 }
 
 int main()
@@ -56,8 +64,8 @@
 
     while (true) {
         xbee.process_rx_frames();
-        wait_ms(100);
-        log_serial->printf(".");
+        wait_ms(50);
+        if (DEBUG) log_serial->printf(".");
     }
 
     delete(log_serial);