Code APP3

Dependencies:   mbed EthernetInterface WebSocketClient mbed-rtos BufferedSerial

Fork of APP3_Lab by Jean-Philippe Fournier

Revision:
19:75e600a40741
Parent:
17:8abdbfa6019c
Child:
21:04fae6a95131
Child:
22:7edae38d0758
--- a/main.cpp	Mon Oct 02 15:01:34 2017 +0000
+++ b/main.cpp	Mon Oct 02 15:18:13 2017 +0000
@@ -19,6 +19,8 @@
 
 void set_pan_id(long pan_id);
 
+int process_frame(frame_t* frame);
+
 #if IS_COORDINATOR   
 void coordinator();
 #else
@@ -53,7 +55,6 @@
 #if IS_COORDINATOR
 void coordinator()
 {    
-    Serial pc(USBTX, USBRX); // tx, rx
 
     coordinator_config_t config = read_coordinator_config();
     
@@ -68,12 +69,9 @@
         
         if (finished_packet)
         {
-            pc.printf("data start::: ");
-            for (int i = 0; i < current_frame.length && i < BUFFER_SIZE; i++)
-            {
-                pc.putc(current_frame.buffer[i]);            
-            }
-            pc.printf(" :::end\n\r");
+            
+            process_frame(&current_frame);
+            
             
             //remote_at_command_query('N', 'D', 0x02);
         }
@@ -118,3 +116,28 @@
     }
     at_command_set('I', 'D', pan_id_buffer, 8);
 }
+
+int process_frame(frame_t* frame)
+{
+    Serial pc(USBTX, USBRX); // tx, rx
+    if (frame->length <= 0)
+    {
+        return -1;
+    }
+    /*for (int i = 0; i < frame->length; i++)
+    {
+        char current = frame->buffer[i];        
+    }    */
+    if (frame->buffer[0] == 0x90)
+    {
+        // Manage source address
+        // Detect the source address and list it dynamically
+        
+        //Data starts at 12
+        for (int i = 12; i <  frame->length; i++)
+        {
+            pc.putc(frame->buffer[i]);   
+        }        
+    }    
+    return 0;
+}
\ No newline at end of file