APP3 / Zigbee_communication

Dependents:   Coordinator_node Router_node

Revision:
10:dac25a0076f5
Parent:
9:902d0f74333c
Child:
11:7b5b9c1ab757
--- a/xbee.cpp	Tue Feb 14 19:47:20 2017 +0000
+++ b/xbee.cpp	Tue Feb 14 20:23:39 2017 +0000
@@ -321,29 +321,46 @@
     char adresse16bit[2];
     char receiveOptions;
     char checksum;
+    char data = 0;
+    char total = 0x90;
         
     while(i < 8)
     {
         adresse64bit[i] = getChar();
+        total += adresse64bit[i];
         i++;
     }
     
     adresse16bit[0] = getChar();
     adresse16bit[1] = getChar();
     
-    receiveOptions = getChar();
+    total += adresse16bit[0];
+    total += adresse16bit[1];
     
-    pcPrint("Data received : ");
+    receiveOptions = getChar();
+    total += receiveOptions;
+    
+    printHexa(len - 11);
+    pcPrint(" Data received : ");
     
     i = 11;
     while (i < len)
     {
-        printHexa(getChar());
+        data = getChar();
+        total += data;
+        printHexa(data);
         i++;   
     }
     pcPrint("\r\n");
     
     checksum = getChar();
+    total += checksum;
+    
+    if (total != 0xFF)
+    {
+        pcPrint("Checksum is wrong\0");
+    }
+    pcPrint("\r\n\0");
     // Validate checksum TODO
 }