High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Revision:
1074:1fedc77d9add
Parent:
1072:dd09fe419587
Child:
1075:0d0dafb54bc9
--- a/ble/GattClient.h	Mon Jan 11 08:51:41 2016 +0000
+++ b/ble/GattClient.h	Mon Jan 11 08:51:42 2016 +0000
@@ -20,7 +20,6 @@
 #include "Gap.h"
 #include "GattAttribute.h"
 #include "ServiceDiscovery.h"
-#include "CharacteristicDescriptorDiscovery.h"
 
 #include "GattCallbackParamTypes.h"
 
@@ -217,8 +216,8 @@
      * Initiate a GATT Client write procedure.
      *
      * @param[in] cmd
-     *              Command can be either a write-request (which generates a
-     *              matching response from the peripheral), or a write-command
+     *              Command can be either a write-request (which generates a 
+     *              matching response from the peripheral), or a write-command 
      *              (which doesn't require the connected peer to respond).
      * @param[in] connHandle
      *              Connection handle.
@@ -247,8 +246,8 @@
     /* Event callback handlers. */
 public:
     /**
-     * Set up a callback for read response events.
-     * It is possible to remove registered callbacks using
+     * Set up a callback for read response events. 
+     * It is possible to remove registered callbacks using 
      * onDataRead().detach(callbackToRemove)
      */
     void onDataRead(ReadCallback_t callback) {
@@ -258,7 +257,7 @@
     /**
      * @brief provide access to the callchain of read 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 read callbacks chain
      */
     ReadCallbackChain_t& onDataRead() {
@@ -267,7 +266,7 @@
 
     /**
      * Set up a callback for write response events.
-     * It is possible to remove registered callbacks using
+     * It is possible to remove registered callbacks using 
      * onDataWritten().detach(callbackToRemove).
      * @Note: Write commands (issued using writeWoResponse) don't generate a response.
      */
@@ -278,10 +277,10 @@
     /**
      * @brief provide access to the callchain of data written 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 callbacks chain
      */
-    WriteCallbackChain_t& onDataWritten() {
+    WriteCallbackChain_t& onDataWritten() { 
         return onDataWriteCallbackChain;
     }
 
@@ -306,59 +305,6 @@
     }
 
     /**
-     * @brief launch discovery of descriptors for a given characteristic
-     * @details This function will discover all descriptors available for a
-     * specific characteristic.
-     *
-     * @param characteristic[in] The characteristic targeted by this discovery
-     * procedure
-     * @param discoveryCallback[in] User function called each time a descriptor
-     * is found during the procedure.
-     * @param terminationCallback[in] User provided function which will be called
-     * once the discovery procedure is terminating. This will get called when all
-     * the descriptors have been discovered or if an error occur during the discovery
-     * procedure.
-     *
-     * @return
-     *   BLE_ERROR_NONE if characteristic descriptor discovery is launched
-     *   successfully; else an appropriate error.
-     */
-    virtual ble_error_t discoverCharacteristicDescriptors(
-        const DiscoveredCharacteristic& characteristic,
-        const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
-        const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback) {
-        (void) characteristic;
-        (void) discoveryCallback;
-        (void) terminationCallback;
-        /* Requesting action from porter(s): override this API if this capability is supported. */
-        return BLE_ERROR_NOT_IMPLEMENTED;
-    }
-
-    /**
-     * @brief Indicate if the discovery of characteristic descriptors is active for a given characteristic
-     * or not.
-     * @param characteristic[in] The characteristic concerned by the descriptors discovery.
-     * @return true if a descriptors discovery is active for the characteristic in input; otherwise false.
-     */
-    virtual bool isCharacteristicDescriptorsDiscoveryActive(const DiscoveredCharacteristic& characteristic) const
-     {
-        (void) characteristic;
-        return false; /* Requesting action from porter(s): override this API if this capability is supported. */
-    }
-
-    /**
-     * @brief Terminate an ongoing characteristic descriptor discovery.
-     * @detail This should result in an invocation of the TerminationCallback if
-     * the characteristic descriptor discovery is active.
-     * @param characteristic[in] The characteristic on which the running descriptors
-     * discovery should be stopped.
-     */
-    virtual void terminateCharacteristicDescriptorsDiscovery(const DiscoveredCharacteristic& characteristic) {
-        /* Requesting action from porter(s): override this API if this capability is supported. */
-        (void) characteristic;
-    }
-
-    /**
      * Set up a callback for when the GATT client receives an update event
      * corresponding to a change in the value of a characteristic on the remote
      * GATT server.
@@ -372,13 +318,33 @@
     /**
      * @brief provide access to the callchain of HVX callbacks
      * It is possible to register callbacks using onHVX().add(callback);
-     * It is possible to unregister callbacks using onHVX().detach(callback)
+     * It is possible to unregister callbacks using onHVX().detach(callback) 
      * @return The HVX callbacks chain
      */
-    HVXCallbackChain_t& onHVX() {
+    HVXCallbackChain_t& onHVX() { 
         return onHVXCallbackChain;
     }
 
+public:
+    /**
+     * Clear all GattClient 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 GattClient members. This shall be achieved
+     * by a call to GattClient::reset() from the sub-class' reset()
+     * implementation.
+     *
+     * @return BLE_ERROR_NONE on success.
+     */
+    virtual ble_error_t reset(void) {
+        onDataReadCallbackChain.clear();
+        onDataWriteCallbackChain.clear();
+        onHVXCallbackChain.clear();
+
+        return BLE_ERROR_NONE;
+    }
+
 protected:
     GattClient() {
         /* Empty */