NimBLE-Arduino 1.4.2
|
A model of a BLE descriptor. More...
#include <NimBLEDescriptor.h>
Inherited by NimBLE2904.
Public Member Functions | |
NimBLEDescriptor (const char *uuid, uint16_t properties, uint16_t max_len, NimBLECharacteristic *pCharacteristic=nullptr) | |
Construct a descriptor. More... | |
NimBLEDescriptor (NimBLEUUID uuid, uint16_t properties, uint16_t max_len, NimBLECharacteristic *pCharacteristic=nullptr) | |
Construct a descriptor. More... | |
~NimBLEDescriptor () | |
NimBLEDescriptor destructor. | |
uint16_t | getHandle () |
Get the BLE handle for this descriptor. More... | |
NimBLEUUID | getUUID () |
Get the UUID of the descriptor. | |
std::string | toString () |
Return a string representation of the descriptor. More... | |
void | setCallbacks (NimBLEDescriptorCallbacks *pCallbacks) |
Set the callback handlers for this descriptor. More... | |
NimBLECharacteristic * | getCharacteristic () |
Get the characteristic this descriptor belongs to. More... | |
size_t | getLength () |
Get the length of the value of this descriptor. More... | |
NimBLEAttValue | getValue (time_t *timestamp=nullptr) |
Get the value of this descriptor. More... | |
std::string | getStringValue () |
Get the value of this descriptor as a string. More... | |
void | setValue (const uint8_t *data, size_t size) |
Set the value of the descriptor. More... | |
void | setValue (const std::vector< uint8_t > &vec) |
Set the value of the descriptor from a std::vector<uint8_t> .. More... | |
template<typename T > | |
void | setValue (const T &s) |
Template to set the characteristic value to <type>val. More... | |
template<typename T > | |
T | getValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
Template to convert the descriptor data to <type>. More... | |
A model of a BLE descriptor.
NimBLEDescriptor::NimBLEDescriptor | ( | const char * | uuid, |
uint16_t | properties, | ||
uint16_t | max_len, | ||
NimBLECharacteristic * | pCharacteristic = nullptr |
||
) |
Construct a descriptor.
[in] | uuid | - UUID (const char*) for the descriptor. |
[in] | properties | - Properties for the descriptor. |
[in] | max_len | - The maximum length in bytes that the descriptor value can hold. (Default: 512 bytes for esp32, 20 for all others). |
[in] | pCharacteristic | - pointer to the characteristic instance this descriptor belongs to. |
NimBLEDescriptor::NimBLEDescriptor | ( | NimBLEUUID | uuid, |
uint16_t | properties, | ||
uint16_t | max_len, | ||
NimBLECharacteristic * | pCharacteristic = nullptr |
||
) |
Construct a descriptor.
[in] | uuid | - UUID (const char*) for the descriptor. |
[in] | properties | - Properties for the descriptor. |
[in] | max_len | - The maximum length in bytes that the descriptor value can hold. (Default: 512 bytes for esp32, 20 for all others). |
[in] | pCharacteristic | - pointer to the characteristic instance this descriptor belongs to. |
NimBLECharacteristic * NimBLEDescriptor::getCharacteristic | ( | ) |
Get the characteristic this descriptor belongs to.
uint16_t NimBLEDescriptor::getHandle | ( | ) |
Get the BLE handle for this descriptor.
size_t NimBLEDescriptor::getLength | ( | ) |
Get the length of the value of this descriptor.
std::string NimBLEDescriptor::getStringValue | ( | ) |
Get the value of this descriptor as a string.
NimBLEAttValue NimBLEDescriptor::getValue | ( | time_t * | timestamp = nullptr | ) |
Get the value of this descriptor.
|
inline |
Template to convert the descriptor data to <type>.
T | The type to convert the data to. |
[in] | timestamp | (Optional) A pointer to a time_t struct to store the time the value was read. |
[in] | skipSizeCheck | (Optional) If true it will skip checking if the data size is less than sizeof(<type>) . |
sizeof(<type>)
.Use: getValue<type>(×tamp, skipSizeCheck);
void NimBLEDescriptor::setCallbacks | ( | NimBLEDescriptorCallbacks * | pCallbacks | ) |
Set the callback handlers for this descriptor.
[in] | pCallbacks | An instance of a callback structure used to define any callbacks for the descriptor. |
void NimBLEDescriptor::setValue | ( | const std::vector< uint8_t > & | vec | ) |
Set the value of the descriptor from a std::vector<uint8_t>
.
.
[in] | vec | The std::vector<uint8_t> reference to set the descriptor value from. |
|
inline |
Template to set the characteristic value to <type>val.
[in] | s | The value to set. |
void NimBLEDescriptor::setValue | ( | const uint8_t * | data, |
size_t | length | ||
) |
Set the value of the descriptor.
[in] | data | The data to set for the descriptor. |
[in] | length | The length of the data in bytes. |
std::string NimBLEDescriptor::toString | ( | ) |
Return a string representation of the descriptor.