Holla back

Fork of BLE_API by Bluetooth Low Energy

Branch:
2chains
Revision:
123:d2cdf4ebe524
Parent:
121:035516234a33
--- a/public/BLEDevice.h	Tue Sep 30 01:03:56 2014 +0100
+++ b/public/BLEDevice.h	Fri Oct 10 17:32:22 2014 -0700
@@ -199,11 +199,14 @@
     /* APIs to set GAP callbacks. */
     void onTimeout(Gap::EventCallback_t timeoutCallback);
 
-    void onConnection(Gap::ConnectionEventCallback_t connectionCallback);
+    void onConnection(void (*callback)(Gap::Handle_t handle, const Gap::ConnectionParams_t *eventDataP));
+    template <typename T> void onConnection(T *objPtr, void (T::*memberPtr)(Gap::Handle_t handle, const Gap::ConnectionParams_t *context));
+
     /**
      * Used to setup a callback for GAP disconnection.
      */
-    void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback);
+     void onDisconnection(void (*callback)(Gap::Handle_t handle, Gap::DisconnectionReason_t reason));
+     template <typename T> void onDisconnection(T *objPtr, void (T::*memberPtr)(Gap::Handle_t handle, Gap::DisconnectionReason_t reason));
 
     /**
      * Setup a callback for the GATT event DATA_SENT.
@@ -469,15 +472,23 @@
 }
 
 inline void
-BLEDevice::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
-{
-    transport->getGap().setOnConnection(connectionCallback);
+BLEDevice::onConnection(void (*callback)(Gap::Handle_t handle, const Gap::ConnectionParams_t *eventDataP)) {
+    transport->getGap().setOnConnection(callback);
+}
+
+template <typename T> inline void
+BLEDevice::onConnection(T *objPtr, void (T::*memberPtr)(Gap::Handle_t handle, const Gap::ConnectionParams_t *context)) {
+    transport->getGap().setOnConnection(objPtr, memberPtr);
 }
 
 inline void
-BLEDevice::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback)
-{
-    transport->getGap().setOnDisconnection(disconnectionCallback);
+BLEDevice::onDisconnection(void (*callback)(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)) {
+    transport->getGap().setOnDisconnection(callback);
+}
+
+template <typename T> inline void
+BLEDevice::onDisconnection(T *objPtr, void (T::*memberPtr)(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)) {
+    transport->getGap().setOnDisconnection(objPtr, memberPtr);
 }
 
 inline void