forked from h2zero/esp-nimble-cpp
Add NimBLEAttValue class. (#67)
This is a specialized container class to hold BLE attribute values. - Removes the use of std::string previously used to store the values. - Allows for setting/getting/notifying values from std::string, std::vector<uint8_t>, Arduino String, const char*, and uint8_t buffers. - Has operators retrieve the value as std::string, Arduino String, std::vector<uint8_t>, uint8_t* or char pointers. - Includes iterators and subscript/random access operator. - Introduces a max length parameter to the creation of server characteristics/descriptors to limit the size of the memory footprint. - Nearly Seamless integration with existing code. - Adds a config option to enable/disable timestamp storage when the value is updated. - Adds a config option to specify the initial size of the value container if not specified in the constructor.
This commit is contained in:
@@ -250,10 +250,11 @@ uint16_t NimBLEService::getHandle() {
|
||||
* @brief Create a new BLE Characteristic associated with this service.
|
||||
* @param [in] uuid - The UUID of the characteristic.
|
||||
* @param [in] properties - The properties of the characteristic.
|
||||
* @param [in] max_len - The maximum length in bytes that the characteristic value can hold.
|
||||
* @return The new BLE characteristic.
|
||||
*/
|
||||
NimBLECharacteristic* NimBLEService::createCharacteristic(const char* uuid, uint32_t properties) {
|
||||
return createCharacteristic(NimBLEUUID(uuid), properties);
|
||||
NimBLECharacteristic* NimBLEService::createCharacteristic(const char* uuid, uint32_t properties, uint16_t max_len) {
|
||||
return createCharacteristic(NimBLEUUID(uuid), properties, max_len);
|
||||
}
|
||||
|
||||
|
||||
@@ -261,10 +262,11 @@ NimBLECharacteristic* NimBLEService::createCharacteristic(const char* uuid, uint
|
||||
* @brief Create a new BLE Characteristic associated with this service.
|
||||
* @param [in] uuid - The UUID of the characteristic.
|
||||
* @param [in] properties - The properties of the characteristic.
|
||||
* @param [in] max_len - The maximum length in bytes that the characteristic value can hold.
|
||||
* @return The new BLE characteristic.
|
||||
*/
|
||||
NimBLECharacteristic* NimBLEService::createCharacteristic(const NimBLEUUID &uuid, uint32_t properties) {
|
||||
NimBLECharacteristic* pCharacteristic = new NimBLECharacteristic(uuid, properties, this);
|
||||
NimBLECharacteristic* NimBLEService::createCharacteristic(const NimBLEUUID &uuid, uint32_t properties, uint16_t max_len) {
|
||||
NimBLECharacteristic* pCharacteristic = new NimBLECharacteristic(uuid, properties, max_len, this);
|
||||
|
||||
if (getCharacteristic(uuid) != nullptr) {
|
||||
NIMBLE_LOGD(LOG_TAG, "<< Adding a duplicate characteristic with UUID: %s",
|
||||
|
||||
Reference in New Issue
Block a user