esp-nimble-cpp
1.4.1
|
A model of a remote BLE characteristic. More...
Public Member Functions | |
~NimBLERemoteCharacteristic () | |
Destructor. | |
bool | canBroadcast () |
Does the characteristic support broadcasting? More... | |
bool | canIndicate () |
Does the characteristic support indications? More... | |
bool | canNotify () |
Does the characteristic support notifications? More... | |
bool | canRead () |
Does the characteristic support reading? More... | |
bool | canWrite () |
Does the characteristic support writing? More... | |
bool | canWriteNoResponse () |
Does the characteristic support writing with no response? More... | |
std::vector< NimBLERemoteDescriptor * >::iterator | begin () |
Get iterator to the beginning of the vector of remote descriptor pointers. More... | |
std::vector< NimBLERemoteDescriptor * >::iterator | end () |
Get iterator to the end of the vector of remote descriptor pointers. More... | |
NimBLERemoteDescriptor * | getDescriptor (const NimBLEUUID &uuid) |
Get the descriptor instance with the given UUID that belongs to this characteristic. More... | |
std::vector< NimBLERemoteDescriptor * > * | getDescriptors (bool refresh=false) |
Get a pointer to the vector of found descriptors. More... | |
void | deleteDescriptors () |
Delete the descriptors in the descriptor vector. More... | |
size_t | deleteDescriptor (const NimBLEUUID &uuid) |
Delete descriptor by UUID. More... | |
uint16_t | getHandle () |
Get the handle for this characteristic. More... | |
uint16_t | getDefHandle () |
Get the handle for this characteristics definition. More... | |
NimBLEUUID | getUUID () |
Get the UUID for this characteristic. More... | |
NimBLEAttValue | readValue (time_t *timestamp=nullptr) |
Read the value of the remote characteristic. More... | |
std::string | toString () |
Convert a NimBLERemoteCharacteristic to a string representation;. More... | |
NimBLERemoteService * | getRemoteService () |
Get the remote service associated with this characteristic. More... | |
uint8_t | readUInt8 () __attribute__((deprecated("Use template readValue<uint8_t>()"))) |
Read a byte value. More... | |
uint16_t | readUInt16 () __attribute__((deprecated("Use template readValue<uint16_t>()"))) |
Read an unsigned 16 bit value. More... | |
uint32_t | readUInt32 () __attribute__((deprecated("Use template readValue<uint32_t>()"))) |
Read an unsigned 32 bit value. More... | |
float | readFloat () __attribute__((deprecated("Use template readValue<float>()"))) |
Read a float value. More... | |
NimBLEAttValue | getValue (time_t *timestamp=nullptr) |
Get the value of the remote characteristic. More... | |
bool | subscribe (bool notifications=true, notify_callback notifyCallback=nullptr, bool response=false) |
Subscribe for notifications or indications. More... | |
bool | unsubscribe (bool response=false) |
Unsubscribe for notifications or indications. More... | |
bool | registerForNotify (notify_callback notifyCallback, bool notifications=true, bool response=true) __attribute__((deprecated("Use subscribe()/unsubscribe()"))) |
backward-compatibility method for subscribe/unsubscribe notifications/indications More... | |
bool | writeValue (const uint8_t *data, size_t length, bool response=false) |
Write a new value to the remote characteristic from a data buffer. More... | |
bool | writeValue (const std::vector< uint8_t > &v, bool response=false) |
Write a new value to the remote characteristic from a std::vector<uint8_t>. More... | |
bool | writeValue (const char *s, bool response=false) |
Write a new value to the remote characteristic from a const char*. More... | |
template<typename T > | |
bool | writeValue (const T &s, bool response=false) |
Template to set the remote characteristic value to <type>val. More... | |
template<typename T > | |
bool | writeValue (const T &s, bool response=false) |
Template to set the remote characteristic value to <type>val. More... | |
template<typename T > | |
T | getValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
Template to convert the remote characteristic data to <type>. More... | |
template<typename T > | |
T | readValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
Template to convert the remote characteristic data to <type>. More... | |
A model of a remote BLE characteristic.
std::vector< NimBLERemoteDescriptor * >::iterator NimBLERemoteCharacteristic::begin | ( | ) |
Get iterator to the beginning of the vector of remote descriptor pointers.
bool NimBLERemoteCharacteristic::canBroadcast | ( | ) |
Does the characteristic support broadcasting?
bool NimBLERemoteCharacteristic::canIndicate | ( | ) |
Does the characteristic support indications?
bool NimBLERemoteCharacteristic::canNotify | ( | ) |
Does the characteristic support notifications?
bool NimBLERemoteCharacteristic::canRead | ( | ) |
Does the characteristic support reading?
bool NimBLERemoteCharacteristic::canWrite | ( | ) |
Does the characteristic support writing?
bool NimBLERemoteCharacteristic::canWriteNoResponse | ( | ) |
Does the characteristic support writing with no response?
size_t NimBLERemoteCharacteristic::deleteDescriptor | ( | const NimBLEUUID & | uuid | ) |
Delete descriptor by UUID.
[in] | uuid | The UUID of the descriptor to be deleted. |
void NimBLERemoteCharacteristic::deleteDescriptors | ( | ) |
Delete the descriptors in the descriptor vector.
We maintain a vector called m_descriptorVector that contains pointers to NimBLERemoteDescriptors object references. Since we allocated these in this class, we are also responsible for deleting them. This method does just that.
std::vector< NimBLERemoteDescriptor * >::iterator NimBLERemoteCharacteristic::end | ( | ) |
Get iterator to the end of the vector of remote descriptor pointers.
uint16_t NimBLERemoteCharacteristic::getDefHandle | ( | ) |
Get the handle for this characteristics definition.
NimBLERemoteDescriptor * NimBLERemoteCharacteristic::getDescriptor | ( | const NimBLEUUID & | uuid | ) |
Get the descriptor instance with the given UUID that belongs to this characteristic.
[in] | uuid | The UUID of the descriptor to find. |
std::vector< NimBLERemoteDescriptor * > * NimBLERemoteCharacteristic::getDescriptors | ( | bool | refresh = false | ) |
Get a pointer to the vector of found descriptors.
[in] | refresh | If true the current descriptor vector will be cleared and all descriptors for this characteristic retrieved from the peripheral. If false the vector will be returned with the currently stored descriptors of this characteristic. |
uint16_t NimBLERemoteCharacteristic::getHandle | ( | ) |
Get the handle for this characteristic.
NimBLERemoteService * NimBLERemoteCharacteristic::getRemoteService | ( | ) |
Get the remote service associated with this characteristic.
NimBLEUUID NimBLERemoteCharacteristic::getUUID | ( | ) |
Get the UUID for this characteristic.
NimBLEAttValue NimBLERemoteCharacteristic::getValue | ( | time_t * | timestamp = nullptr | ) |
Get the value of the remote characteristic.
[in] | timestamp | A pointer to a time_t struct to store the time the value was read. |
|
inline |
Template to convert the remote characteristic data to <type>.
T | The type to convert the data to. |
[in] | timestamp | A pointer to a time_t struct to store the time the value was read. |
[in] | skipSizeCheck | If true it will skip checking if the data size is less than sizeof(<type>) . |
sizeof(<type>)
.Use: getValue<type>(×tamp, skipSizeCheck);
float NimBLERemoteCharacteristic::readFloat | ( | ) |
Read a float value.
uint16_t NimBLERemoteCharacteristic::readUInt16 | ( | ) |
Read an unsigned 16 bit value.
uint32_t NimBLERemoteCharacteristic::readUInt32 | ( | ) |
Read an unsigned 32 bit value.
uint8_t NimBLERemoteCharacteristic::readUInt8 | ( | ) |
NimBLEAttValue NimBLERemoteCharacteristic::readValue | ( | time_t * | timestamp = nullptr | ) |
Read the value of the remote characteristic.
[in] | timestamp | A pointer to a time_t struct to store the time the value was read. |
|
inline |
Template to convert the remote characteristic data to <type>.
T | The type to convert the data to. |
[in] | timestamp | A pointer to a time_t struct to store the time the value was read. |
[in] | skipSizeCheck | If true it will skip checking if the data size is less than sizeof(<type>) . |
sizeof(<type>)
.Use: readValue<type>(×tamp, skipSizeCheck);
bool NimBLERemoteCharacteristic::registerForNotify | ( | notify_callback | notifyCallback, |
bool | notifications = true , |
||
bool | response = true |
||
) |
backward-compatibility method for subscribe/unsubscribe notifications/indications
[in] | notifyCallback | A callback to be invoked for a notification. If NULL is provided then we will unregister for notifications. |
[in] | notifications | If true, register for notifications, false register for indications. |
[in] | response | If true, require a write response from the descriptor write operation. |
bool NimBLERemoteCharacteristic::subscribe | ( | bool | notifications = true , |
notify_callback | notifyCallback = nullptr , |
||
bool | response = false |
||
) |
Subscribe for notifications or indications.
[in] | notifications | If true, subscribe for notifications, false subscribe for indications. |
[in] | notifyCallback | A callback to be invoked for a notification. |
[in] | response | If true, require a write response from the descriptor write operation. If NULL is provided then no callback is performed. |
std::string NimBLERemoteCharacteristic::toString | ( | ) |
Convert a NimBLERemoteCharacteristic to a string representation;.
bool NimBLERemoteCharacteristic::unsubscribe | ( | bool | response = false | ) |
Unsubscribe for notifications or indications.
[in] | response | bool if true, require a write response from the descriptor write operation. |
bool NimBLERemoteCharacteristic::writeValue | ( | const char * | char_s, |
bool | response = false |
||
) |
Write a new value to the remote characteristic from a const char*.
[in] | char_s | A character string to write to the remote characteristic. |
[in] | response | Whether we require a response from the write. |
bool NimBLERemoteCharacteristic::writeValue | ( | const std::vector< uint8_t > & | vec, |
bool | response = false |
||
) |
Write a new value to the remote characteristic from a std::vector<uint8_t>.
[in] | vec | A std::vector<uint8_t> value to write to the remote characteristic. |
[in] | response | Whether we require a response from the write. |
|
inline |
Template to set the remote characteristic value to <type>val.
[in] | s | The value to write. |
[in] | response | True == request write response. |
Only used for non-arrays and types without a c_str()
method.
|
inline |
Template to set the remote characteristic value to <type>val.
[in] | s | The value to write. |
[in] | response | True == request write response. |
Only used if the <type> has a c_str()
method.
bool NimBLERemoteCharacteristic::writeValue | ( | const uint8_t * | data, |
size_t | length, | ||
bool | response = false |
||
) |
Write a new value to the remote characteristic from a data buffer.
[in] | data | A pointer to a data buffer. |
[in] | length | The length of the data in the data buffer. |
[in] | response | Whether we require a response from the write. |