High level Bluetooth Low Energy API and radio abstraction layer

Fork of BLE_API by Bluetooth Low Energy

Revision:
1053:ec4a5b9b254e
Parent:
1052:b55e1ad3e1b3
Child:
1056:ce2fb3d09929
--- a/ble/DiscoveredCharacteristic.h	Mon Jan 11 08:51:31 2016 +0000
+++ b/ble/DiscoveredCharacteristic.h	Mon Jan 11 08:51:32 2016 +0000
@@ -21,9 +21,6 @@
 #include "Gap.h"
 #include "GattAttribute.h"
 #include "GattClient.h"
-#include "CharacteristicDescriptorDiscovery.h"
-#include "ble/DiscoveredCharacteristicDescriptor.h"
-
 
 /**
  * Structure for holding information about the service and the characteristics
@@ -49,26 +46,31 @@
         bool indicate(void)        const {return _indicate;       }
         bool authSignedWrite(void) const {return _authSignedWrite;}
 
-        friend bool operator==(Properties_t rhs, Properties_t lhs) {
-            return rhs._broadcast == lhs._broadcast &&
-                   rhs._read == lhs._read &&
-                   rhs._writeWoResp == lhs._writeWoResp &&
-                   rhs._write == lhs._write &&
-                   rhs._notify == lhs._notify &&
-                   rhs._indicate == lhs._indicate &&
-                   rhs._authSignedWrite == lhs._authSignedWrite;
-        }
-
-        friend bool operator!=(Properties_t rhs, Properties_t lhs) { 
-            return !(rhs == lhs);
-        }
-
     private:
         operator uint8_t()  const; /* Disallow implicit conversion into an integer. */
         operator unsigned() const; /* Disallow implicit conversion into an integer. */
     };
 
     /**
+     * Structure for holding information about the service and the characteristics
+     * found during the discovery process.
+     */
+    struct DiscoveredDescriptor {
+        GattAttribute::Handle_t handle; /**< Descriptor Handle. */
+        UUID                    uuid;   /**< Descriptor UUID. */
+    };
+
+    /**
+     * Callback type for when a characteristic descriptor is found during descriptor-
+     * discovery. The receiving function is passed in a pointer to a
+     * DiscoveredDescriptor object which will remain valid for the lifetime
+     * of the callback. Memory for this object is owned by the BLE_API eventing
+     * framework. The application can safely make a persistent shallow-copy of
+     * this object in order to work with the characteristic beyond the callback.
+     */
+    typedef void (*DescriptorCallback_t)(const DiscoveredDescriptor *);
+
+    /**
      * Initiate (or continue) a read for the value attribute, optionally at a
      * given offset. If the characteristic or descriptor to be read is longer
      * than ATT_MTU - 1, this function must be called multiple times with
@@ -108,13 +110,13 @@
     /**
      * Initiate a GATT Characteristic Descriptor Discovery procedure for descriptors within this characteristic.
      *
-     * @param onCharacteristicDiscovered This callback will be called every time a descriptor is discovered
-     * @param onTermination This callback will be called when the discovery process is over.
+     * @param  callback
+     * @param  matchingUUID
+     *           Filter for descriptors. Defaults to wildcard which will discover all descriptors.
      *
      * @return  BLE_ERROR_NONE if descriptor discovery is launched successfully; else an appropriate error.
      */
-    ble_error_t discoverDescriptors(const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& onCharacteristicDiscovered, 
-                                    const CharacteristicDescriptorDiscovery::TerminationCallback_t& onTermination) const;
+    ble_error_t discoverDescriptors(DescriptorCallback_t callback, const UUID &matchingUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) const;
 
     /**
      * Perform a write procedure.
@@ -153,56 +155,19 @@
         return props;
     }
 
-    GattAttribute::Handle_t getDeclHandle(void) const {
+    const GattAttribute::Handle_t& getDeclHandle(void) const {
         return declHandle;
     }
-
-    GattAttribute::Handle_t getValueHandle(void) const {
+    const GattAttribute::Handle_t& getValueHandle(void) const {
         return valueHandle;
     }
 
-    GattAttribute::Handle_t getLastHandle(void) const {
-        return lastHandle;
-    }
-
-    void setLastHandle(GattAttribute::Handle_t last) { 
-        lastHandle = last;
-    }
-
-    GattClient* getGattClient() { 
-        return gattc;
-    }
-
-    const GattClient* getGattClient() const { 
-        return gattc;
-    }
-
-    Gap::Handle_t getConnectionHandle() const {
-        return connHandle;
-    }
-
-    friend bool operator==(const DiscoveredCharacteristic& rhs, const DiscoveredCharacteristic& lhs) {
-        return rhs.gattc == lhs.gattc && 
-               rhs.uuid == lhs.uuid &&
-               rhs.props == lhs.props &&
-               rhs.declHandle == lhs.declHandle &&
-               rhs.valueHandle == lhs.valueHandle &&
-               rhs.lastHandle == lhs.lastHandle &&
-               rhs.connHandle == lhs.connHandle;
-    }
-
-    friend bool operator !=(const DiscoveredCharacteristic& rhs, const DiscoveredCharacteristic& lhs) {
-        return !(rhs == lhs);
-    }
-
 public:
     DiscoveredCharacteristic() : gattc(NULL),
                                  uuid(UUID::ShortUUIDBytes_t(0)),
                                  props(),
                                  declHandle(GattAttribute::INVALID_HANDLE),
-                                 valueHandle(GattAttribute::INVALID_HANDLE),
-                                 lastHandle(GattAttribute::INVALID_HANDLE),
-                                 connHandle() {
+                                 valueHandle(GattAttribute::INVALID_HANDLE) {
         /* empty */
     }
 
@@ -214,7 +179,6 @@
     Properties_t             props;
     GattAttribute::Handle_t  declHandle;
     GattAttribute::Handle_t  valueHandle;
-    GattAttribute::Handle_t  lastHandle;
 
     Gap::Handle_t            connHandle;
 };