Lancaster University's fork of the mbed BLE API. Lives on github, https://github.com/lancaster-university/BLE_API

Dependents:   microbit-dal microbit-dal microbit-ble-open microbit-dal ... more

Fork of BLE_API by Bluetooth Low Energy

Revision:
1131:73c11a85c6d6
Parent:
1090:148d8b9b56a5
Child:
1136:82ebef119484
--- a/ble/GattServer.h	Tue Jan 12 19:47:52 2016 +0000
+++ b/ble/GattServer.h	Wed Apr 06 18:40:26 2016 +0100
@@ -26,19 +26,17 @@
 
 class GattServer {
 public:
+
     /* Event callback handlers. */
     typedef FunctionPointerWithContext<unsigned> DataSentCallback_t;
     typedef CallChainOfFunctionPointersWithContext<unsigned> DataSentCallbackChain_t;
 
     typedef FunctionPointerWithContext<const GattWriteCallbackParams*> DataWrittenCallback_t;
-    typedef CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams*> DataWrittenCallbackChain_t;
+    typedef CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams*> DataWrittenCallbackChain_t;    
 
     typedef FunctionPointerWithContext<const GattReadCallbackParams*> DataReadCallback_t;
     typedef CallChainOfFunctionPointersWithContext<const GattReadCallbackParams *> DataReadCallbackChain_t;
 
-    typedef FunctionPointerWithContext<const GattServer *> GattServerShutdownCallback_t;
-    typedef CallChainOfFunctionPointersWithContext<const GattServer *> GattServerShutdownCallbackChain_t;
-
     typedef FunctionPointerWithContext<GattAttribute::Handle_t> EventCallback_t;
 
 protected:
@@ -256,9 +254,9 @@
     }
 
     /**
-     * @brief get the callback chain called when the event DATA_EVENT is triggered.
+     * @brief get the callback chain called when the event DATA_EVENT is triggered. 
      */
-    DataSentCallbackChain_t& onDataSent() {
+    DataSentCallbackChain_t& onDataSent() { 
         return dataSentCallChain;
     }
 
@@ -276,7 +274,7 @@
      *
      * @Note: It is also possible to set up a callback into a member function of
      * some object.
-     *
+     * 
      * @Note It is possible to unregister a callback using onDataWritten().detach(callback)
      */
     void onDataWritten(const DataWrittenCallback_t& callback) {dataWrittenCallChain.add(callback);}
@@ -288,9 +286,9 @@
     /**
      * @brief provide access to the callchain of data written event callbacks
      * It is possible to register callbacks using onDataWritten().add(callback);
-     * It is possible to unregister callbacks using onDataWritten().detach(callback)
+     * It is possible to unregister callbacks using onDataWritten().detach(callback) 
      * @return The data written event callbacks chain
-     */
+     */    
     DataWrittenCallbackChain_t& onDataWritten() {
         return dataWrittenCallChain;
     }
@@ -337,7 +335,7 @@
     /**
      * @brief provide access to the callchain of data read event callbacks
      * It is possible to register callbacks using onDataRead().add(callback);
-     * It is possible to unregister callbacks using onDataRead().detach(callback)
+     * It is possible to unregister callbacks using onDataRead().detach(callback) 
      * @return The data read event callbacks chain
      */
     DataReadCallbackChain_t& onDataRead() {
@@ -345,38 +343,6 @@
     }
 
     /**
-     * Setup a callback to be invoked to notify the user application that the
-     * GattServer instance is about to shutdown (possibly as a result of a call
-     * to BLE::shutdown()).
-     *
-     * @Note: It is possible to chain together multiple onShutdown callbacks
-     * (potentially from different modules of an application) to be notified
-     * before the GattServer is shutdown.
-     *
-     * @Note: It is also possible to set up a callback into a member function of
-     * some object.
-     *
-     * @Note It is possible to unregister a callback using onShutdown().detach(callback)
-     */
-    void onShutdown(const GattServerShutdownCallback_t& callback) {
-        shutdownCallChain.add(callback);
-    }
-    template <typename T>
-    void onShutdown(T *objPtr, void (T::*memberPtr)(void)) {
-        shutdownCallChain.add(objPtr, memberPtr);
-    }
-
-    /**
-     * @brief provide access to the callchain of shutdown event callbacks
-     * It is possible to register callbacks using onShutdown().add(callback);
-     * It is possible to unregister callbacks using onShutdown().detach(callback)
-     * @return The shutdown event callbacks chain
-     */
-    GattServerShutdownCallbackChain_t& onShutdown() {
-        return shutdownCallChain;
-    }
-
-    /**
      * Set up a callback for when notifications or indications are enabled for a
      * characteristic on the local GATT server.
      */
@@ -430,50 +396,17 @@
         dataSentCallChain.call(count);
     }
 
-public:
-    /**
-     * Notify all registered onShutdown callbacks that the GattServer is
-     * about to be shutdown and clear all GattServer state of the
-     * associated object.
-     *
-     * This function is meant to be overridden in the platform-specific
-     * sub-class. Nevertheless, the sub-class is only expected to reset its
-     * state and not the data held in GattServer members. This shall be achieved
-     * by a call to GattServer::reset() from the sub-class' reset()
-     * implementation.
-     *
-     * @return BLE_ERROR_NONE on success.
-     */
-    virtual ble_error_t reset(void) {
-        /* Notify that the instance is about to shutdown */
-        shutdownCallChain.call(this);
-        shutdownCallChain.clear();
-
-        serviceCount = 0;
-        characteristicCount = 0;
-
-        dataSentCallChain.clear();
-        dataWrittenCallChain.clear();
-        dataReadCallChain.clear();
-        updatesEnabledCallback       = NULL;
-        updatesDisabledCallback      = NULL;
-        confirmationReceivedCallback = NULL;
-
-        return BLE_ERROR_NONE;
-    }
-
 protected:
     uint8_t serviceCount;
     uint8_t characteristicCount;
 
 private:
-    DataSentCallbackChain_t           dataSentCallChain;
-    DataWrittenCallbackChain_t        dataWrittenCallChain;
-    DataReadCallbackChain_t           dataReadCallChain;
-    GattServerShutdownCallbackChain_t shutdownCallChain;
-    EventCallback_t                   updatesEnabledCallback;
-    EventCallback_t                   updatesDisabledCallback;
-    EventCallback_t                   confirmationReceivedCallback;
+    DataSentCallbackChain_t    dataSentCallChain;
+    DataWrittenCallbackChain_t dataWrittenCallChain;
+    DataReadCallbackChain_t    dataReadCallChain;
+    EventCallback_t            updatesEnabledCallback;
+    EventCallback_t            updatesDisabledCallback;
+    EventCallback_t            confirmationReceivedCallback;
 
 private:
     /* Disallow copy and assignment. */