Projet_S5 / Mbed 2 deprecated Repo_Noeud_Mobile_refactor

Dependencies:   mbed-rtos mbed

Fork of Repo_Noeud_Mobile by Projet_S5

Revision:
22:cccb77300fd5
Parent:
19:19adf49351b0
Child:
23:5bb76b7c35da
--- a/Communication/Xbee.cpp	Sun Mar 22 17:32:47 2015 +0000
+++ b/Communication/Xbee.cpp	Sun Mar 22 19:57:40 2015 +0000
@@ -1,5 +1,7 @@
 #include "Xbee.h"
 
+Serial x_pc(USBTX, USBRX);
+
 Xbee::Xbee()
 {
     PanId = 0x1337;
@@ -8,10 +10,9 @@
 
 Xbee::Xbee(short panId, PinName pinTx, PinName pinRx)
 {
+    this->XbeePin = new Serial(pinTx, pinRx);
     PanId = panId;
     SetPanId(PanId);
-
-    this->XbeePin = new Serial(pinTx, pinRx);
 }
 
 Xbee::~Xbee()
@@ -77,7 +78,6 @@
 void Xbee::Recevoir()
 {
     Mobile_Vers_Fixe receivedData;    
-    int index = 0;
     while(true) {
         if (XbeePin->readable()) {
             //Start byte
@@ -86,17 +86,20 @@
                 
                 //GantsID
                 receivedData.gants = XbeePin->getc();
-                //Accelero
-                while (index < 6) {
-                    receivedData.xyz[index] = XbeePin->getc();
-                    index++;
-                }
-                index = 0;
+                
+                //AccelData                
+                receivedData.accelData.x = XbeePin->getc();
+                receivedData.accelData.y = XbeePin->getc();
+                receivedData.accelData.z = XbeePin->getc();
+                
                 //Should be the byte containing the states of the flexo
-                receivedData.majeur = XbeePin->getc();
-                receivedData.index = XbeePin->getc();
-                receivedData.annulaire = XbeePin->getc();
-
+                receivedData.flexSensor.index = XbeePin->getc();
+                receivedData.flexSensor.majeur = XbeePin->getc();
+                receivedData.flexSensor.annulaire = XbeePin->getc();
+                receivedData.flexSensor.indexU32 = XbeePin->getc();
+                receivedData.flexSensor.majeurU32 = XbeePin->getc();
+                receivedData.flexSensor.annulaireU32 = XbeePin->getc();
+                
                 //Validate end byte
                 if (XbeePin->getc() == 0x7E) {
                     message *emile = Mailbox.alloc();
@@ -125,6 +128,9 @@
     char array[] = {0x7E, 0x00, 0x06, 0x08, 0x01, 0x49, 0x44, c1, c2, checksum};
     char wr[] = {0x7E, 0x00, 0x04, 0x08, 0x01, 0x57, 0x52, 0x4D};
 
+    x_pc.printf("SetPanID \r\n");
     Envoyer(array, sizeof(array)); //send ID AT Command frame
+    x_pc.printf("ID AT cmd \r\n");
     Envoyer(wr, sizeof(wr)); //send WR AT Command frame
+    x_pc.printf("WR AR cmd \r\n");
 }
\ No newline at end of file