High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Revision:
2:ffc5216bd2cc
Parent:
1:fd3ec64b2345
Child:
7:5e1f0d7f7c7d
--- a/hw/bleradio.h	Wed Dec 04 07:20:24 2013 +0000
+++ b/hw/bleradio.h	Tue Dec 10 07:32:12 2013 +0000
@@ -2,10 +2,15 @@
 #define __BLE_RADIO_H__
 
 #include "blecommon.h"
-#include "bleservice.h"
+#include "GattService.h"
+#include "GapAdvertisingData.h"
+#include "GapAdvertisingParams.h"
 
 class BLERadio
 {
+    protected:
+        FunctionPointer _callback_event;
+        
     public:
         typedef enum radio_event_e
         {
@@ -20,12 +25,23 @@
         /* ToDo: Force constructor with event handler callback */
 
         /* These functions must be defined in the sub-class */
-        //virtual ble_error_t attach(void (*fptr)(void));
-        virtual ble_error_t addService(BLEService &) = 0;
-        virtual ble_error_t updateValue(uint8_t, uint8_t, uint8_t[], uint16_t) = 0;
+        virtual ble_error_t setAdvertising(GapAdvertisingParams &, GapAdvertisingData &) = 0;
+        virtual ble_error_t addService(GattService &) = 0;
+        virtual ble_error_t readCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
+        virtual ble_error_t writeCharacteristic(GattService &, GattCharacteristic &, uint8_t[], uint16_t) = 0;
         virtual ble_error_t start(void) = 0;
         virtual ble_error_t stop(void) = 0;
         virtual ble_error_t reset(void) = 0;
+
+        /* BLE event callback (connect, disconnect, etc.) */
+        void attach(void (*function)(void)) { 
+            _callback_event.attach( function ); 
+        }
+ 
+        template<typename T>
+        void attach(T *object, void (T::*member)(void)) { 
+            _callback_event.attach( object, member );
+        }
 };
 
 #endif