|
esp-nimble-cpp / NimBLE-Arduino
1.3.1
|
The model of a BLE Characteristic. More...
Public Member Functions | |
| NimBLECharacteristic (const char *uuid, uint16_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, NimBLEService *pService=nullptr) | |
| Construct a characteristic. More... | |
| NimBLECharacteristic (const NimBLEUUID &uuid, uint16_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, NimBLEService *pService=nullptr) | |
| Construct a characteristic. More... | |
| ~NimBLECharacteristic () | |
| Destructor. | |
| uint16_t | getHandle () |
| Get the handle of the characteristic. More... | |
| NimBLEUUID | getUUID () |
| Get the UUID of the characteristic. More... | |
| std::string | toString () |
| Return a string representation of the characteristic. More... | |
| void | setCallbacks (NimBLECharacteristicCallbacks *pCallbacks) |
| Set the callback handlers for this characteristic. More... | |
| NimBLECharacteristicCallbacks * | getCallbacks () |
| Get the callback handlers for this characteristic. | |
| void | indicate () |
| Send an indication. An indication is a transmission of up to the first 20 bytes of the characteristic value. An indication will block waiting for a positive confirmation from the client. | |
| void | notify (bool is_notification=true) |
| Send a notification. A notification is a transmission of up to the first 20 bytes of the characteristic value. A notification will not block; it is a fire and forget. More... | |
| size_t | getSubscribedCount () |
| Get the number of clients subscribed to the characteristic. More... | |
| NimBLEDescriptor * | createDescriptor (const char *uuid, uint32_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, uint16_t max_len=100) |
| Create a new BLE Descriptor associated with this characteristic. More... | |
| NimBLEDescriptor * | createDescriptor (const NimBLEUUID &uuid, uint32_t properties=NIMBLE_PROPERTY::READ|NIMBLE_PROPERTY::WRITE, uint16_t max_len=100) |
| Create a new BLE Descriptor associated with this characteristic. More... | |
| void | addDescriptor (NimBLEDescriptor *pDescriptor) |
| Add a descriptor to the characteristic. More... | |
| NimBLEDescriptor * | getDescriptorByUUID (const char *uuid) |
| Return the BLE Descriptor for the given UUID. More... | |
| NimBLEDescriptor * | getDescriptorByUUID (const NimBLEUUID &uuid) |
| Return the BLE Descriptor for the given UUID. More... | |
| NimBLEDescriptor * | getDescriptorByHandle (uint16_t handle) |
| Return the BLE Descriptor for the given handle. More... | |
| void | removeDescriptor (NimBLEDescriptor *pDescriptor, bool deleteDsc=false) |
| Remove a descriptor from the characterisitc. More... | |
| std::string | getValue (time_t *timestamp=nullptr) |
| Retrieve the current value of the characteristic. More... | |
| size_t | getDataLength () |
| Retrieve the the current data length of the characteristic. More... | |
| template<typename T > | |
| T | getValue (time_t *timestamp=nullptr, bool skipSizeCheck=false) |
| A template to convert the characteristic data to <type>. More... | |
| void | setValue (const uint8_t *data, size_t size) |
| Set the value of the characteristic. More... | |
| void | setValue (const std::string &value) |
| Set the value of the characteristic from string data. We set the value of the characteristic from the bytes contained in the string. More... | |
| template<typename T > | |
| void | setValue (const T &s) |
| Convenience template to set the characteristic value to <type>val. More... | |
| NimBLEService * | getService () |
| Get the service associated with this characteristic. | |
| uint16_t | getProperties () |
| Get the properties of the characteristic. More... | |
The model of a BLE Characteristic.
A BLE Characteristic is an identified value container that manages a value. It is exposed by a BLE server and can be read and written to by a BLE client.
| NimBLECharacteristic::NimBLECharacteristic | ( | const char * | uuid, |
| uint16_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE, |
||
| NimBLEService * | pService = nullptr |
||
| ) |
Construct a characteristic.
| [in] | uuid | - UUID (const char*) for the characteristic. |
| [in] | properties | - Properties for the characteristic. |
| [in] | pService | - pointer to the service instance this characteristic belongs to. |
| NimBLECharacteristic::NimBLECharacteristic | ( | const NimBLEUUID & | uuid, |
| uint16_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE, |
||
| NimBLEService * | pService = nullptr |
||
| ) |
Construct a characteristic.
| [in] | uuid | - UUID for the characteristic. |
| [in] | properties | - Properties for the characteristic. |
| [in] | pService | - pointer to the service instance this characteristic belongs to. |
| void NimBLECharacteristic::addDescriptor | ( | NimBLEDescriptor * | pDescriptor | ) |
Add a descriptor to the characteristic.
| [in] | pDescriptor | A pointer to the descriptor to add. |
| NimBLEDescriptor * NimBLECharacteristic::createDescriptor | ( | const char * | uuid, |
| uint32_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE, |
||
| uint16_t | max_len = 100 |
||
| ) |
Create a new BLE Descriptor associated with this characteristic.
| [in] | uuid | - The UUID of the descriptor. |
| [in] | properties | - The properties of the descriptor. |
| [in] | max_len | - The max length in bytes of the descriptor value. |
| NimBLEDescriptor * NimBLECharacteristic::createDescriptor | ( | const NimBLEUUID & | uuid, |
| uint32_t | properties = NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE, |
||
| uint16_t | max_len = 100 |
||
| ) |
Create a new BLE Descriptor associated with this characteristic.
| [in] | uuid | - The UUID of the descriptor. |
| [in] | properties | - The properties of the descriptor. |
| [in] | max_len | - The max length in bytes of the descriptor value. |
| size_t NimBLECharacteristic::getDataLength | ( | ) |
Retrieve the the current data length of the characteristic.
| NimBLEDescriptor * NimBLECharacteristic::getDescriptorByHandle | ( | uint16_t | handle | ) |
Return the BLE Descriptor for the given handle.
| [in] | handle | The handle of the descriptor. |
| NimBLEDescriptor * NimBLECharacteristic::getDescriptorByUUID | ( | const char * | uuid | ) |
Return the BLE Descriptor for the given UUID.
| [in] | uuid | The UUID of the descriptor. |
| NimBLEDescriptor * NimBLECharacteristic::getDescriptorByUUID | ( | const NimBLEUUID & | uuid | ) |
Return the BLE Descriptor for the given UUID.
| [in] | uuid | The UUID of the descriptor. |
| uint16_t NimBLECharacteristic::getHandle | ( | ) |
Get the handle of the characteristic.
| uint16_t NimBLECharacteristic::getProperties | ( | ) |
Get the properties of the characteristic.
| size_t NimBLECharacteristic::getSubscribedCount | ( | ) |
Get the number of clients subscribed to the characteristic.
| NimBLEUUID NimBLECharacteristic::getUUID | ( | ) |
Get the UUID of the characteristic.
| std::string NimBLECharacteristic::getValue | ( | time_t * | timestamp = nullptr | ) |
Retrieve the current value of the characteristic.
|
inline |
A template to convert the 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);
| void NimBLECharacteristic::notify | ( | bool | is_notification = true | ) |
Send a notification.
A notification is a transmission of up to the first 20 bytes of the characteristic value.
A notification will not block; it is a fire and forget.
| [in] | is_notification | if true sends a notification, false sends an indication. |
| void NimBLECharacteristic::removeDescriptor | ( | NimBLEDescriptor * | pDescriptor, |
| bool | deleteDsc = false |
||
| ) |
Remove a descriptor from the characterisitc.
| [in] | pDescriptor | A pointer to the descriptor instance to remove from the characterisitc. |
| [in] | deleteDsc | If true it will delete the descriptor instance and free it's resources. |
| void NimBLECharacteristic::setCallbacks | ( | NimBLECharacteristicCallbacks * | pCallbacks | ) |
Set the callback handlers for this characteristic.
| [in] | pCallbacks | An instance of a NimBLECharacteristicCallbacks class used to define any callbacks for the characteristic. |
| void NimBLECharacteristic::setValue | ( | const std::string & | value | ) |
Set the value of the characteristic from string data.
We set the value of the characteristic from the bytes contained in the string.
| [in] | value | the std::string value of the characteristic. |
|
inline |
Convenience template to set the characteristic value to <type>val.
| [in] | s | The value to set. |
| void NimBLECharacteristic::setValue | ( | const uint8_t * | data, |
| size_t | length | ||
| ) |
Set the value of the characteristic.
| [in] | data | The data to set for the characteristic. |
| [in] | length | The length of the data in bytes. |
| std::string NimBLECharacteristic::toString | ( | ) |
Return a string representation of the characteristic.