Partial implementation of BlueGiga's BGAPI for use with the BLE112/3 modules over UART.

Hi there! I recently started using BLE112 modules with the mbed LPC1768 MCU, and I realized there was no implementation of BlueGiga's BGAPI available for mbed. This library implements only a few commands, but if you're looking to get started, this is a good place to look.

This was developed against BGAPI v1.3.2. I make no guarantees as to how well it will work with newer revisions of the software.

Revision:
3:8f43af513d87
Parent:
2:3ce9a31a6a7e
Child:
4:21eee6881dac
--- a/BGLib.cpp	Mon May 18 01:16:52 2015 +0000
+++ b/BGLib.cpp	Mon May 18 05:49:21 2015 +0000
@@ -25,6 +25,16 @@
     mGetInfoCallback = pCallback;
 }
 
+void BGLib::set_ble_evt_system_boot(boot_callback_t pCallback) {
+    mBootCallback = pCallback;
+}
+
+void BGLib::ble_cmd_system_reset(ble_msg_system_reset_t args) {
+    uint8_t bytes[] = {0x00, 0x01, 0x00, 0x00, 0x00};
+    bytes[4] = args.boot_in_dfu;
+    send_bytes(bytes, 5);
+}
+
 void BGLib::parse() {
     #ifdef DEBUG
     printf("Got data from port!\r\n");
@@ -43,7 +53,7 @@
         if (msg_class == 0x00) { // system_class
             if (msg_id == 0x01) { // system_hello
                 mHelloCallback();
-            } else if (msg_id == 0x08) {
+            } else if (msg_id == 0x08) { //system_get_info
                 
                 #ifdef DEBUG
                 printf("Get Info Response\r\n");
@@ -60,7 +70,26 @@
                 mGetInfoCallback(result);
             }
         }
-    } 
+    } else if (hilen == 0x80) { // event
+        if (msg_class == 0x00) { //system_class
+            if (msg_id == 0x00) { //system_boot
+                #ifdef DEBUG
+                printf("Boot Event\r\n");
+                #endif
+                
+                ble_msg_system_boot_evt_t result; 
+                result.major = mSerial.getc() | (mSerial.getc() << 8);
+                result.minor = mSerial.getc() | (mSerial.getc() << 8);
+                result.patch = mSerial.getc() | (mSerial.getc() << 8);
+                result.build = mSerial.getc() | (mSerial.getc() << 8);
+                result.ll_version = mSerial.getc() | (mSerial.getc() << 8);
+                result.protocol_version = mSerial.getc();
+                result.hw = mSerial.getc();
+                mBootCallback(result);
+            }
+        }
+    }
+        
     
     //safety valve: if there are bytes remaining
 }