18#ifndef NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
19#define NIMBLE_CPP_REMOTE_CHARACTERISTIC_H_
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
24# include "NimBLERemoteValueAttribute.h"
31struct NimBLEDescriptorFilter;
52 typedef std::function<void(
NimBLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData,
size_t length,
bool isNotify)> notify_callback;
54 bool subscribe(
bool notifications =
true,
const notify_callback notifyCallback =
nullptr,
bool response =
true)
const;
57 std::vector<NimBLERemoteDescriptor*>::iterator
begin()
const;
58 std::vector<NimBLERemoteDescriptor*>::iterator
end()
const;
60 const std::vector<NimBLERemoteDescriptor*>&
getDescriptors(
bool refresh =
false)
const;
69 bool setNotify(uint16_t val, notify_callback notifyCallback =
nullptr,
bool response =
true)
const;
70 bool retrieveDescriptors(NimBLEDescriptorFilter* filter =
nullptr)
const;
72 static int descriptorDiscCB(
73 uint16_t connHandle,
const ble_gatt_error* error, uint16_t chrHandle,
const ble_gatt_dsc* dsc,
void* arg);
76 uint8_t m_properties{0};
77 mutable notify_callback m_notifyCallback{
nullptr};
78 mutable std::vector<NimBLERemoteDescriptor*> m_vDescriptors{};
A model of a BLE client.
Definition NimBLEClient.h:49
A model of a remote BLE characteristic.
Definition NimBLERemoteCharacteristic.h:36
size_t deleteDescriptor(const NimBLEUUID &uuid) const
Delete descriptor by UUID.
Definition NimBLERemoteCharacteristic.cpp:275
bool canWriteNoResponse() const
Does the characteristic support writing without a response?
Definition NimBLERemoteCharacteristic.cpp:310
bool canBroadcast() const
Does the characteristic support value broadcasting?
Definition NimBLERemoteCharacteristic.cpp:294
std::vector< NimBLERemoteDescriptor * >::iterator begin() const
Get iterator to the beginning of the vector of remote descriptor pointers.
Definition NimBLERemoteCharacteristic.cpp:190
std::vector< NimBLERemoteDescriptor * >::iterator end() const
Get iterator to the end of the vector of remote descriptor pointers.
Definition NimBLERemoteCharacteristic.cpp:198
void deleteDescriptors() const
Delete the descriptors in the descriptor vector.
Definition NimBLERemoteCharacteristic.cpp:259
const NimBLERemoteService * getRemoteService() const
Get the remote service associated with this characteristic.
Definition NimBLERemoteCharacteristic.cpp:206
const std::vector< NimBLERemoteDescriptor * > & getDescriptors(bool refresh=false) const
Get a pointer to the vector of found descriptors.
Definition NimBLERemoteCharacteristic.cpp:177
bool canWrite() const
Does the characteristic support writing?
Definition NimBLERemoteCharacteristic.cpp:318
bool canRead() const
Does the characteristic support reading?
Definition NimBLERemoteCharacteristic.cpp:302
bool unsubscribe(bool response=true) const
Unsubscribe for notifications or indications.
Definition NimBLERemoteCharacteristic.cpp:249
bool canIndicate() const
Does the characteristic support indication?
Definition NimBLERemoteCharacteristic.cpp:334
NimBLERemoteDescriptor * getDescriptor(const NimBLEUUID &uuid) const
Get the descriptor instance with the given UUID that belongs to this characteristic.
Definition NimBLERemoteCharacteristic.cpp:135
std::string toString() const
Convert a NimBLERemoteCharacteristic to a string representation;.
Definition NimBLERemoteCharacteristic.cpp:358
bool subscribe(bool notifications=true, const notify_callback notifyCallback=nullptr, bool response=true) const
Subscribe for notifications or indications.
Definition NimBLERemoteCharacteristic.cpp:240
bool canNotify() const
Does the characteristic support reading with encryption?
Definition NimBLERemoteCharacteristic.cpp:326
bool canWriteSigned() const
Does the characteristic support signed writing?
Definition NimBLERemoteCharacteristic.cpp:342
bool hasExtendedProps() const
Does the characteristic support extended properties?
Definition NimBLERemoteCharacteristic.cpp:350
A model of remote BLE descriptor.
Definition NimBLERemoteDescriptor.h:32
A model of a remote BLE service.
Definition NimBLERemoteService.h:34
A model of a BLE UUID.
Definition NimBLEUUID.h:41