A model of a remote BLE characteristic.
More...
#include <BLERemoteCharacteristic.hpp>
A model of a remote BLE characteristic.
◆ canBroadcast()
bool BLERemoteCharacteristic::canBroadcast |
( |
| ) |
|
Does the characteristic support broadcasting?
- Returns
- True if the characteristic supports broadcasting.
74 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_BROADCAST) != 0;
◆ canIndicate()
bool BLERemoteCharacteristic::canIndicate |
( |
| ) |
|
Does the characteristic support indications?
- Returns
- True if the characteristic supports indications.
83 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_INDICATE) != 0;
◆ canNotify()
bool BLERemoteCharacteristic::canNotify |
( |
| ) |
|
Does the characteristic support notifications?
- Returns
- True if the characteristic supports notifications.
92 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_NOTIFY) != 0;
◆ canRead()
bool BLERemoteCharacteristic::canRead |
( |
| ) |
|
Does the characteristic support reading?
- Returns
- True if the characteristic supports reading.
101 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_READ) != 0;
◆ canWrite()
bool BLERemoteCharacteristic::canWrite |
( |
| ) |
|
Does the characteristic support writing?
- Returns
- True if the characteristic supports writing.
110 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_WRITE) != 0;
◆ canWriteNoResponse()
bool BLERemoteCharacteristic::canWriteNoResponse |
( |
| ) |
|
Does the characteristic support writing with no response?
- Returns
- True if the characteristic supports writing with no response.
119 return (m_charProp & BLE_GATT_CHAR_PROP_BIT_WRITE_NR) != 0;
◆ getDescriptor()
Get the descriptor instance with the given UUID that belongs to this characteristic.
- Parameters
-
[in] | uuid | The UUID of the descriptor to find. |
- Returns
- The Remote descriptor (if present) or null if not present.
173 _debug_print_s(TAG,
">> getDescriptor: uuid", uuid.
toString().c_str());
176 for (
auto &myPair : m_descriptorMap) {
177 if (myPair.first == v) {
178 _debug_print(TAG,
"<< getDescriptor: found");
179 return myPair.second;
183 _debug_print(TAG,
"<< getDescriptor: Not found");
◆ getHandle()
uint16_t BLERemoteCharacteristic::getHandle |
( |
| ) |
|
Get the handle for this characteristic.
- Returns
- The handle for this characteristic.
◆ getRemoteService()
Get the remote service associated with this characteristic.
- Returns
- The remote service associated with this characteristic.
193 return m_pRemoteService;
◆ getUUID()
BLEUUID BLERemoteCharacteristic::getUUID |
( |
| ) |
|
Get the UUID for this characteristic.
- Returns
- The UUID for this characteristic.
◆ readRawData()
uint8_t * BLERemoteCharacteristic::readRawData |
( |
| ) |
|
Read raw data from remote characteristic as hex bytes.
- Returns
- return pointer data read
◆ readUInt16()
uint16_t BLERemoteCharacteristic::readUInt16 |
( |
| ) |
|
Read an unsigned 16 bit value.
- Returns
- The unsigned 16 bit value.
211 std::string value = readValue();
212 if (value.length() >= 2) {
213 return *(uint16_t*)(value.data());
◆ readUInt32()
uint32_t BLERemoteCharacteristic::readUInt32 |
( |
| ) |
|
Read an unsigned 32 bit value.
- Returns
- the unsigned 32 bit value.
224 std::string value = readValue();
225 if (value.length() >= 4) {
226 return *(uint32_t*)(value.data());
◆ readUInt8()
uint8_t BLERemoteCharacteristic::readUInt8 |
( |
| ) |
|
Read a byte value.
- Returns
- The value as a byte
237 std::string value = readValue();
238 if (value.length() >= 1) {
239 return (uint8_t)value[0];
◆ toString()
std::string BLERemoteCharacteristic::toString |
( |
| ) |
|
Convert a BLERemoteCharacteristic to a string representation;.
- Returns
- a String representation.
267 std::ostringstream ss;
268 ss <<
"Characteristic: uuid: " << m_uuid.
toString() <<
270 ", props: " <<
" 0x" << std::hex << m_charProp;
◆ writeValue() [1/2]
bool BLERemoteCharacteristic::writeValue |
( |
std::string |
newValue, |
|
|
bool |
response = false |
|
) |
| |
Write the new value for the characteristic.
- Parameters
-
[in] | newValue | The new value to write. |
[in] | response | Do we expect a response? |
- Returns
- false if not connected or cant perform write for some reason.
282 return writeValue((uint8_t*)newValue.c_str(), strlen(newValue.c_str()), response);
◆ writeValue() [2/2]
bool BLERemoteCharacteristic::writeValue |
( |
uint8_t |
newValue, |
|
|
bool |
response = false |
|
) |
| |
Write the new value for the characteristic.
This is a convenience function. Many BLE characteristics are a single byte of data.
- Parameters
-
[in] | newValue | The new byte value to write. |
[in] | response | Whether we require a response from the write. |
- Returns
- false if not connected or cant perform write for some reason.
295 return writeValue(&newValue, 1, response);
The documentation for this class was generated from the following files: