18#ifndef NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
19#define NIMBLE_LOCAL_VALUE_ATTRIBUTE_H_
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
24# if defined(CONFIG_NIMBLE_CPP_IDF)
25# include "host/ble_hs.h"
27# include "nimble/nimble/host/include/host/ble_hs.h"
36 READ = BLE_GATT_CHR_F_READ,
37 READ_ENC = BLE_GATT_CHR_F_READ_ENC,
38 READ_AUTHEN = BLE_GATT_CHR_F_READ_AUTHEN,
39 READ_AUTHOR = BLE_GATT_CHR_F_READ_AUTHOR,
40 WRITE = BLE_GATT_CHR_F_WRITE,
41 WRITE_NR = BLE_GATT_CHR_F_WRITE_NO_RSP,
42 WRITE_ENC = BLE_GATT_CHR_F_WRITE_ENC,
43 WRITE_AUTHEN = BLE_GATT_CHR_F_WRITE_AUTHEN,
44 WRITE_AUTHOR = BLE_GATT_CHR_F_WRITE_AUTHOR,
45 BROADCAST = BLE_GATT_CHR_F_BROADCAST,
46 NOTIFY = BLE_GATT_CHR_F_NOTIFY,
47 INDICATE = BLE_GATT_CHR_F_INDICATE
50# include "NimBLELocalAttribute.h"
51# include "NimBLEAttValue.h"
60 uint16_t getProperties()
const {
return m_properties; }
66 size_t getLength()
const {
return m_value.size(); }
73 NimBLEAttValue getValue(time_t* timestamp =
nullptr)
const {
return m_value; }
80 void setValue(
const uint8_t* data,
size_t size) { m_value.
setValue(data, size); }
86 void setValue(
const char* str) { m_value.setValue(str); }
92 void setValue(
const std::vector<uint8_t>& vec) { m_value.setValue(vec); }
99 void setValue(
const T& val) {
100 m_value.setValue<T>(val);
111 template <
typename T>
112 T getValue(time_t* timestamp =
nullptr,
bool skipSizeCheck =
false)
const {
113 return m_value.getValue<T>(timestamp, skipSizeCheck);
126 NimBLELocalValueAttribute(
const NimBLEUUID& uuid,
129 uint16_t initLen = CONFIG_NIMBLE_CPP_ATT_VALUE_INIT_LENGTH)
135 virtual ~NimBLELocalValueAttribute() =
default;
151 virtual void writeEvent(
const uint8_t* val, uint16_t len,
NimBLEConnInfo& connInfo) = 0;
164 void setProperties(uint16_t properties) { m_properties = properties; }
167 uint16_t m_properties{0};
A specialized container class to hold BLE attribute values.
Definition NimBLEAttValue.h:72
bool setValue(const uint8_t *value, uint16_t len)
Set the value from a buffer.
Definition NimBLEAttValue.cpp:96
Connection information.
Definition NimBLEConnInfo.h:32
A base class for local BLE attributes.
Definition NimBLELocalAttribute.h:29
The model of a BLE server.
Definition NimBLEServer.h:60
A model of a BLE UUID.
Definition NimBLEUUID.h:41