esp-nimble-cpp
1.3.2
|
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... | |
std::string | readValue (time_t *timestamp=nullptr) |
Read the value of the remote characteristic. More... | |
template<typename T > | |
T | readValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
A template to convert the remote characteristic data to <type>. 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... | |
std::string | getValue (time_t *timestamp=nullptr) |
Get the value of the remote characteristic. More... | |
template<typename T > | |
T | getValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
A template to convert the remote characteristic data to <type>. 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 the new value for the characteristic from a data buffer. More... | |
bool | writeValue (const std::string &newValue, bool response=false) |
Write the new value for the characteristic. More... | |
template<typename T > | |
bool | writeValue (const T &s, bool response=false) |
Convenience template to set the remote characteristic value to <type>val. More... | |
std::string | toString () |
Convert a NimBLERemoteCharacteristic to a string representation;. More... | |
NimBLERemoteService * | getRemoteService () |
Get the remote service associated with this characteristic. 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.
std::string 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 |
A 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 | ( | ) |
std::string 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 |
A 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 std::string & | newValue, |
bool | response = false |
||
) |
Write the new value for the characteristic.
[in] | newValue | The new value to write. |
[in] | response | Do we expect a response? |
|
inline |
Convenience template to set the remote characteristic value to <type>val.
[in] | s | The value to write. |
[in] | response | True == request write response. |
bool NimBLERemoteCharacteristic::writeValue | ( | const uint8_t * | data, |
size_t | length, | ||
bool | response = false |
||
) |
Write the new value for the 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. |