remove duplication in the constructor for GattCharacteristic
This commit is contained in:
parent
ff353f7e02
commit
79da06fc34
2 changed files with 23 additions and 55 deletions
|
@ -26,15 +26,14 @@
|
|||
|
||||
@note The UUID value must be unique in the service and is normally >1
|
||||
|
||||
@param[in] id
|
||||
The 16-bit UUID to use for this characteristic
|
||||
@param[in] minLen
|
||||
@param[in] uuid
|
||||
The UUID to use for this characteristic
|
||||
@param[in] initialLen
|
||||
The min length in bytes of this characteristic's value
|
||||
@param[in] maxLen
|
||||
The max length in bytes of this characteristic's value
|
||||
@param[in] props
|
||||
The 8-bit bit field containing the characteristic's
|
||||
properties
|
||||
The 8-bit bit field containing the characteristic's properties
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
|
@ -46,37 +45,8 @@
|
|||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
GattCharacteristic::GattCharacteristic(uint16_t id,
|
||||
uint16_t minLen,
|
||||
uint16_t maxLen,
|
||||
uint8_t props) :
|
||||
uuid(id),
|
||||
lenMin(minLen),
|
||||
lenMax(maxLen),
|
||||
handle(),
|
||||
properties(props)
|
||||
GattCharacteristic::GattCharacteristic(const UUID &id, uint16_t initialLen, uint16_t maxLen, uint8_t props) :
|
||||
_uuid(id), _lenMin(initialLen), _lenMax(maxLen), _handle(), _properties(props)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
|
||||
GattCharacteristic::GattCharacteristic(const LongUUID_t longUUID,
|
||||
uint16_t minLen,
|
||||
uint16_t maxLen,
|
||||
uint8_t props) :
|
||||
uuid(longUUID),
|
||||
lenMin(minLen),
|
||||
lenMax(maxLen),
|
||||
handle(),
|
||||
properties(props)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
Destructor
|
||||
*/
|
||||
/**************************************************************************/
|
||||
GattCharacteristic::~GattCharacteristic(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -295,43 +295,41 @@ public:
|
|||
/**************************************************************************/
|
||||
typedef struct PresentationFormat
|
||||
{
|
||||
uint8_t gatt_format; /**< Format of the value, see @ref ble_gatt_format_t. */
|
||||
int8_t exponent; /**< Exponent for integer data types. Ex. if Exponent = -3 and the char value is 3892, the actual value is 3.892 */
|
||||
uint16_t gatt_unit; /**< UUID from Bluetooth Assigned Numbers, see @ref ble_gatt_unit_t. */
|
||||
uint8_t gatt_namespace; /**< Namespace from Bluetooth Assigned Numbers, normally '1', see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0', see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint8_t gatt_format; /**< Format of the value, see @ref ble_gatt_format_t. */
|
||||
int8_t exponent; /**< Exponent for integer data types. Ex. if Exponent = -3 and the char value is 3892, the actual value is 3.892 */
|
||||
uint16_t gatt_unit; /**< UUID from Bluetooth Assigned Numbers, see @ref ble_gatt_unit_t. */
|
||||
uint8_t gatt_namespace; /**< Namespace from Bluetooth Assigned Numbers, normally '1', see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0', see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
} presentation_format_t;
|
||||
|
||||
GattCharacteristic(ShortUUID_t uuid = 0, uint16_t minLen = 1, uint16_t maxLen = 1, uint8_t properties = 0);
|
||||
GattCharacteristic(const LongUUID_t longUUID, uint16_t minLen = 1, uint16_t maxLen = 1, uint8_t properties = 0);
|
||||
virtual ~GattCharacteristic(void);
|
||||
GattCharacteristic(const UUID &uuid, uint16_t initialLen = 1, uint16_t maxLen = 1, uint8_t properties = 0);
|
||||
|
||||
public:
|
||||
uint16_t getHandle(void) const {
|
||||
return handle;
|
||||
return _handle;
|
||||
}
|
||||
void setHandle(uint16_t id) {
|
||||
handle = id;
|
||||
_handle = id;
|
||||
}
|
||||
const UUID &getUUID(void) const {
|
||||
return uuid;
|
||||
return _uuid;
|
||||
}
|
||||
uint8_t getProperties(void) const {
|
||||
return properties;
|
||||
return _properties;
|
||||
}
|
||||
uint16_t getMinLength(void) const {
|
||||
return lenMin;
|
||||
return _lenMin;
|
||||
}
|
||||
uint16_t getMaxLength(void) const {
|
||||
return lenMax;
|
||||
return _lenMax;
|
||||
}
|
||||
|
||||
private:
|
||||
UUID uuid; /* Characteristic UUID */
|
||||
uint16_t lenMin; /* Minimum length of the value */
|
||||
uint16_t lenMax; /* Maximum length of the value */
|
||||
uint16_t handle;
|
||||
uint8_t properties;
|
||||
UUID _uuid; /* Characteristic UUID */
|
||||
uint16_t _lenMin; /* Minimum length of the value */
|
||||
uint16_t _lenMax; /* Maximum length of the value */
|
||||
uint16_t _handle;
|
||||
uint8_t _properties;
|
||||
};
|
||||
|
||||
#endif // ifndef __GATT_CHARACTERISTIC_H__
|
||||
|
|
Loading…
Reference in a new issue