Skip to content

Commit f631751

Browse files
author
carlescufi
committed
Add optional descriptors to the char constructor
1 parent fdfd14c commit f631751

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

public/GattCharacteristic.h

+11-14
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class GattCharacteristic : public GattAttribute
297297
uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0', see @ref BLE_GATT_CPF_NAMESPACES. */
298298
} presentation_format_t;
299299

300-
/**
300+
/**
301301
* @brief Creates a new GattCharacteristic using the specified 16-bit
302302
* UUID, value length, and properties
303303
*
@@ -313,31 +313,28 @@ class GattCharacteristic : public GattAttribute
313313
* The max length in bytes of this characteristic's value
314314
* @param[in] props
315315
* The 8-bit bit field containing the characteristic's properties
316-
*
317-
* @section EXAMPLE
318-
*
319-
* @code
320-
*
321-
* // UUID = 0x2A19, Min length 2, Max len = 2, Properties = write
322-
* GattCharacteristic c = GattCharacteristic( 0x2A19, 2, 2, BLE_GATT_CHAR_PROPERTIES_WRITE );
323-
*
324-
* @endcode
316+
* @param[in] descriptors
317+
* A pointer to an array of descriptors to be included within this characteristic
318+
* @param[in] numDescriptors
319+
* The number of descriptors
325320
*/
326321
/**************************************************************************/
327322
GattCharacteristic(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0,
328-
uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE) :
329-
GattAttribute(uuid, valuePtr, initialLen, maxLen), _properties(props) {
330-
/* empty */
323+
uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
324+
GattAttribute *descriptors[] = NULL, unsigned numDescriptors = 0) :
325+
GattAttribute(uuid, valuePtr, initialLen, maxLen), _properties(props), _descriptors(descriptors), _descriptorCount(numDescriptors) {
326+
331327
}
332328

333329
public:
334330
uint8_t getProperties(void) const {
335331
return _properties;
336332
}
337333

338-
339334
private:
340335
uint8_t _properties;
336+
GattAttribute ** _descriptors;
337+
uint8_t _descriptorCount;
341338
};
342339

343340
#endif // ifndef __GATT_CHARACTERISTIC_H__

public/GattService.h

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
class GattService
3232
{
3333
public:
34+
/**
35+
* @brief Creates a new GattCharacteristic using the specified 16-bit
36+
* UUID, value length, and properties
37+
*
38+
* @note The UUID value must be unique in the service and is normally >1
39+
*
40+
* @param[in] uuid
41+
* The UUID to use for this characteristic
42+
* @param[in] characteristics
43+
* A pointer to an array of characteristics to be included within this service
44+
* @param[in] numCharacteristics
45+
* The number of characteristics
46+
*/
47+
/**************************************************************************/
3448
GattService(const UUID &uuid, GattCharacteristic *characteristics[], unsigned numCharacteristics);
3549

3650
enum {

0 commit comments

Comments
 (0)