From b7e6ddfae15ae489225c91743a52f2789a57fde4 Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Fri, 19 Jun 2015 11:49:03 +0100 Subject: [PATCH] DiscoveredCharacteristic: add API for discovering descriptors. --- common/DiscoveredCharacteristic.cpp | 6 ++++++ public/DiscoveredCharacteristic.h | 30 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/common/DiscoveredCharacteristic.cpp b/common/DiscoveredCharacteristic.cpp index 325a81a..081b61d 100644 --- a/common/DiscoveredCharacteristic.cpp +++ b/common/DiscoveredCharacteristic.cpp @@ -61,3 +61,9 @@ DiscoveredCharacteristic::writeWoResponse(uint16_t length, const uint8_t *value) return gattc->write(GattClient::GATT_OP_WRITE_CMD, connHandle, valueHandle, length, value); } + +ble_error_t +DiscoveredCharacteristic::discoverDescriptors(DescriptorCallback_t callback, const UUID &matchingUUID) const +{ + return BLE_ERROR_NOT_IMPLEMENTED; /* TODO: this needs to be filled in. */ +} diff --git a/public/DiscoveredCharacteristic.h b/public/DiscoveredCharacteristic.h index e416a17..51d9ce9 100644 --- a/public/DiscoveredCharacteristic.h +++ b/public/DiscoveredCharacteristic.h @@ -51,6 +51,25 @@ public: 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 @@ -86,6 +105,17 @@ public: */ ble_error_t writeWoResponse(uint16_t length, const uint8_t *value) const; + /** + * Initiate a GATT Characteristic Descriptor Discovery procedure for descriptors within this characteristic. + * + * @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(DescriptorCallback_t callback, const UUID &matchingUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) const; + /** * Perform a write procedure. *