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"
50 typedef std::function<void(
NimBLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData,
size_t length,
bool isNotify)> notify_callback;
52 bool subscribe(
bool notifications =
true,
const notify_callback notifyCallback =
nullptr,
bool response =
true)
const;
55 std::vector<NimBLERemoteDescriptor*>::iterator
begin()
const;
56 std::vector<NimBLERemoteDescriptor*>::iterator
end()
const;
58 const std::vector<NimBLERemoteDescriptor*>&
getDescriptors(
bool refresh =
false)
const;
67 bool setNotify(uint16_t val, notify_callback notifyCallback =
nullptr,
bool response =
true)
const;
68 bool retrieveDescriptors(
const NimBLEUUID* uuidFilter =
nullptr)
const;
70 static int descriptorDiscCB(
71 uint16_t conn_handle,
const ble_gatt_error* error, uint16_t chr_val_handle,
const ble_gatt_dsc* dsc,
void* arg);
74 uint8_t m_properties{0};
75 mutable notify_callback m_notifyCallback{
nullptr};
76 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:34
size_t deleteDescriptor(const NimBLEUUID &uuid) const
Delete descriptor by UUID.
Definition NimBLERemoteCharacteristic.cpp:293
bool canWriteNoResponse() const
Does the characteristic support writing without a response?
Definition NimBLERemoteCharacteristic.cpp:328
bool canBroadcast() const
Does the characteristic support value broadcasting?
Definition NimBLERemoteCharacteristic.cpp:312
std::vector< NimBLERemoteDescriptor * >::iterator begin() const
Get iterator to the beginning of the vector of remote descriptor pointers.
Definition NimBLERemoteCharacteristic.cpp:208
std::vector< NimBLERemoteDescriptor * >::iterator end() const
Get iterator to the end of the vector of remote descriptor pointers.
Definition NimBLERemoteCharacteristic.cpp:216
void deleteDescriptors() const
Delete the descriptors in the descriptor vector.
Definition NimBLERemoteCharacteristic.cpp:277
const NimBLERemoteService * getRemoteService() const
Get the remote service associated with this characteristic.
Definition NimBLERemoteCharacteristic.cpp:224
const std::vector< NimBLERemoteDescriptor * > & getDescriptors(bool refresh=false) const
Get a pointer to the vector of found descriptors.
Definition NimBLERemoteCharacteristic.cpp:195
bool canWrite() const
Does the characteristic support writing?
Definition NimBLERemoteCharacteristic.cpp:336
bool canRead() const
Does the characteristic support reading?
Definition NimBLERemoteCharacteristic.cpp:320
bool unsubscribe(bool response=true) const
Unsubscribe for notifications or indications.
Definition NimBLERemoteCharacteristic.cpp:267
bool canIndicate() const
Does the characteristic support indication?
Definition NimBLERemoteCharacteristic.cpp:352
NimBLERemoteDescriptor * getDescriptor(const NimBLEUUID &uuid) const
Get the descriptor instance with the given UUID that belongs to this characteristic.
Definition NimBLERemoteCharacteristic.cpp:138
std::string toString() const
Convert a NimBLERemoteCharacteristic to a string representation;.
Definition NimBLERemoteCharacteristic.cpp:376
bool subscribe(bool notifications=true, const notify_callback notifyCallback=nullptr, bool response=true) const
Subscribe for notifications or indications.
Definition NimBLERemoteCharacteristic.cpp:258
bool canNotify() const
Does the characteristic support reading with encryption?
Definition NimBLERemoteCharacteristic.cpp:344
bool canWriteSigned() const
Does the characteristic support signed writing?
Definition NimBLERemoteCharacteristic.cpp:360
bool hasExtendedProps() const
Does the characteristic support extended properties?
Definition NimBLERemoteCharacteristic.cpp:368
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