Skip to content

Commit d66ca4c

Browse files
authored
feat(ble): Adds Characteristic User Description
Adds Descriptor 0x2901 This is the Characteristic User Description, commomnly used in BLE. Adds the implementation for make it easier to be used.
1 parent 2ce5075 commit d66ca4c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

libraries/BLE/src/BLE2901.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
BLE2901.h
3+
4+
GATT Descriptor 0x2901 Characteristic User Description
5+
6+
The value of this description is a user-readable string
7+
describing the characteristic.
8+
9+
The Characteristic User Description descriptor
10+
provides a textual user description for a characteristic
11+
value.
12+
If the Writable Auxiliary bit of the Characteristics
13+
Properties is set then this descriptor is written. Only one
14+
User Description descriptor exists in a characteristic
15+
definition.
16+
*/
17+
18+
#include "soc/soc_caps.h"
19+
#if SOC_BLE_SUPPORTED
20+
21+
#include "sdkconfig.h"
22+
#if defined(CONFIG_BLUEDROID_ENABLED)
23+
24+
#include "BLE2901.h"
25+
26+
BLE2901::BLE2901() : BLEDescriptor(BLEUUID((uint16_t)0x2901)) {
27+
} // BLE2901
28+
29+
/**
30+
* @brief Set the Characteristic User Description
31+
*/
32+
void BLE2901::setDescription(String userDesc) {
33+
if (userDesc.length() > ESP_GATT_MAX_ATTR_LEN) {
34+
log_e("Size %d too large, must be no bigger than %d", userDesc.length(), ESP_GATT_MAX_ATTR_LEN);
35+
return;
36+
}
37+
setValue(userDesc);
38+
}
39+
40+
#endif
41+
#endif /* SOC_BLE_SUPPORTED */

0 commit comments

Comments
 (0)