Library set up as dummy module on mbed to mimic Nordic.

Dependencies:   mbed-rtos mbed

Revision:
1:d6b18299a715
Parent:
0:226550611f0d
Child:
2:9ab591cf81b8
--- a/main.cpp	Mon Dec 12 23:06:58 2016 +0000
+++ b/main.cpp	Mon Dec 12 23:19:30 2016 +0000
@@ -6,6 +6,7 @@
 #include "comms.h"
 #include "rs485.h"
 #include "uart1.h"
+#include "BTpacket.h"
 
 #define FX 0x02
 
@@ -86,21 +87,29 @@
 
 int Bluetooth_ReceivePacket( Packet *_packet ){
 
-        #ifdef DEBUG
-            pc.printf( "Process Packet\n\r" );
-                    
-            pc.printf( "\t%x - Device ID\n\r" , _packet->deviceID );
-            pc.printf( "\t%x - Source ID\n\r" , _packet->sourceID );
-            pc.printf( "\t%x - Command\n\r" , _packet->command );
-            pc.printf( "\t%x - Length\n\r" , _packet->packetLength );
-            unsigned char *ptr = (unsigned char *)&_packet->packetData;
-            for( int i = 0 ; i < _packet->packetLength ; i++ ){
-                pc.printf( "\t%x - Data[%d]\n\r" , *ptr++ , i );   
-            }
+    #ifdef DEBUG
+        PrintPacket( _packet );
+    #endif // DEBUG   
+    
+    switch ( _packet->command ){
+        
+        case 0x01:        
+            CheckFunction( _packet );
+            break;
             
-        #endif // DEBUG    
+        case 0x02:
+        
+            break;
+            
+        case 0x03:
+        
+            break;
+            
+        default:
+            break;   
+        
+    } 
     
-    CheckFunction( _packet );
     
     return 0;
 }
@@ -110,6 +119,19 @@
     return 0;
 }
 
+void PrintPacket( Packet *_packet ){
+        pc.printf( "Process Packet\n\r" );
+                
+        pc.printf( "\t%x - Device ID\n\r" , _packet->deviceID );
+        pc.printf( "\t%x - Source ID\n\r" , _packet->sourceID );
+        pc.printf( "\t%x - Command\n\r" , _packet->command );
+        pc.printf( "\t%x - Length\n\r" , _packet->packetLength );
+        unsigned char *ptr = (unsigned char *)&_packet->packetData;
+        for( int i = 0 ; i < _packet->packetLength ; i++ ){
+            pc.printf( "\t%x - Data[%d]\n\r" , *ptr++ , i );   
+        }   
+}
+
 void Test( void ){
     
             Packet commandPacket;
@@ -155,7 +177,9 @@
                 }
                 
                 //  create message
-                SetResponse( 0xF0 , 0x10 , 0x01 );
+                Bluetooth_SendChar( 0xF0 );
+                Bluetooth_SendChar( 0x01 );
+                Bluetooth_SendChar( 0x10 );
                 
                 //  poll with message
                 ptr = buf1;