Library used to receive data through a wireless channel using XBEE.

Dependencies:   mbed

Dependents:   nxp_can

Fork of frdm_xbee by Jose Pesado

Files at this revision

API Documentation at this revision

Comitter:
JalilChavez
Date:
Mon Oct 20 07:04:24 2014 +0000
Parent:
2:ccf471fbd56c
Commit message:
This programs sends data through CAN bus and interacts with an instrument panel.

Changed in this revision

xbee.cpp Show annotated file Show diff for this revision Revisions of this file
xbee.h Show annotated file Show diff for this revision Revisions of this file
--- a/xbee.cpp	Sat Oct 18 19:58:20 2014 +0000
+++ b/xbee.cpp	Mon Oct 20 07:04:24 2014 +0000
@@ -1,20 +1,19 @@
-#include "mbed.h"
+#include "xbee.h"
 
 #define XBEE_SERVER         0
 #define XBEE_CLIENT         1
 #define SERIAL_BAUDRATE     115200
-#define BUFFER_SIZE         14
 #define BUFFER_FORMAT       "%X %X %X %X %X %X %X %X %X"
-#define BUFFER_FORMAT_RX    "%c%c%c%c%c%c%c%c%c%c%c%c"
+#define BUFFER_FORMAT_RX    "%c%c%c%c%c%c%c%c%c%c%c%c%c%c"
 #define BUFFER_RX_DATA_WR   &CommandRx[0],&CommandRx[1],&CommandRx[2],&CommandRx[3],\
                             &CommandRx[4],&CommandRx[5],&CommandRx[6],&CommandRx[7],\
-                            &CommandRx[8],&CommandRx[9],&CommandRx[10],&CommandRx[11]
+                            &CommandRx[8],&CommandRx[9],&CommandRx[10],&CommandRx[11],&CommandRx[12],&CommandRx[13]
 #define BUFFER_RX_DATA_RD   CommandRx[0],CommandRx[1],CommandRx[2],CommandRx[3],\
                             CommandRx[4],CommandRx[5],CommandRx[6],CommandRx[7],\
                             CommandRx[8]
 
 Serial PC(USBTX, USBRX);
-DigitalOut Indicator(LED_GREEN);
+DigitalOut Indicator(LED2);
 int XBee_u16Loop;
 
 #if XBEE_SERVER == 1
@@ -26,9 +25,10 @@
 #endif
 
 #if XBEE_CLIENT == 1
-Serial XBeeClient(PTE24, PTE25); /* Tx, Rx*/
-DigitalOut RSTClient(PTA1);
+Serial XBeeClient(p9, p10); /* Tx, Rx*/
+DigitalOut RSTClient(p26);
 char CommandRx[BUFFER_SIZE];
+extern char inBuffer[];
 volatile int XBee_u8RxResult;
 int XBee_boRxIndication = 0;
 int XBee_boRxAllowed = 1;
@@ -70,8 +70,10 @@
          
         if(XBee_boRxIndication == 1)
         {
-            PC.printf("\r\nRx done [%i]. ",XBee_u8RxResult);
+            PC.printf("\r\nRx done [%i] %X. ",XBee_u8RxResult,CommandRx[0]);
             PC.printf( BUFFER_FORMAT, BUFFER_RX_DATA_RD );
+            memcpy(inBuffer,CommandRx,BUFFER_SIZE-5);
+            
         }
     }
     return;
@@ -92,7 +94,7 @@
     #endif
     
     #if XBEE_CLIENT == 1
-    PC.printf("\r\nSetting client XBee...");
+    //PC.printf("\r\nSetting client XBee...");
     XBeeClient.baud(SERIAL_BAUDRATE);   
     XBeeClient.attach(&XBeeClientRx, Serial::RxIrq);
     XBee_u8RxResult = 0;
@@ -120,7 +122,7 @@
 void XBee_vMain(void)
 {
     XBee_u16Loop++;
-    PC.printf("\r\n[%i]:",XBee_u16Loop);   
+    //PC.printf("\r\n[%i]:",XBee_u16Loop);   
     
     if(XBee_u8TxRq == 1)
     {
@@ -153,7 +155,7 @@
 }
 #endif /*#if XBEE_SERVER == 1*/
 
-#if 1
+#if 0
 
 int main()
 {
--- a/xbee.h	Sat Oct 18 19:58:20 2014 +0000
+++ b/xbee.h	Mon Oct 20 07:04:24 2014 +0000
@@ -3,9 +3,10 @@
 
 #include "mbed.h"
 
+#define BUFFER_SIZE         14
+
 extern int XBee_u8TxRq;
 extern char CommandTx[];
-
 /**********************************************************************************
 * Global functions
 ***********************************************************************************/