File tree 4 files changed +88
-3
lines changed
Filter options
4 files changed +88
-3
lines changed
Original file line number Diff line number Diff line change @@ -236,6 +236,7 @@ set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp)
236
236
set (ARDUINO_LIBRARY_Wire_SRCS libraries/Wire/src/Wire.cpp)
237
237
238
238
set (ARDUINO_LIBRARY_BLE_SRCS
239
+ libraries/BLE/src/BLE2901.cpp
239
240
libraries/BLE/src/BLE2902.cpp
240
241
libraries/BLE/src/BLE2904.cpp
241
242
libraries/BLE/src/BLEAddress.cpp
Original file line number Diff line number Diff line change 23
23
#include < BLEServer.h>
24
24
#include < BLEUtils.h>
25
25
#include < BLE2902.h>
26
+ #include < BLE2901.h>
26
27
27
28
BLEServer *pServer = NULL ;
28
29
BLECharacteristic *pCharacteristic = NULL ;
30
+ BLE2901 *descriptor_2901 = NULL ;
31
+
29
32
bool deviceConnected = false ;
30
33
bool oldDeviceConnected = false ;
31
34
uint32_t value = 0 ;
@@ -65,9 +68,13 @@ void setup() {
65
68
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE
66
69
);
67
70
68
- // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
69
- // Create a BLE Descriptor
71
+ // Creates BLE Descriptor 0x2902: Client Characteristic Configuration Descriptor (CCCD)
70
72
pCharacteristic->addDescriptor (new BLE2902 ());
73
+ // Adds also the Characteristic User Description - 0x2901 descriptor
74
+ descriptor_2901 = new BLE2901 ();
75
+ descriptor_2901->setDescription (" My own description for this characteristic." );
76
+ descriptor_2901->setAccessPermissions (ESP_GATT_PERM_READ); // enforce read only - default is Read|Write
77
+ pCharacteristic->addDescriptor (descriptor_2901);
71
78
72
79
// Start the service
73
80
pService->start ();
@@ -87,7 +94,7 @@ void loop() {
87
94
pCharacteristic->setValue ((uint8_t *)&value, 4 );
88
95
pCharacteristic->notify ();
89
96
value++;
90
- delay (3 ); // bluetooth stack will go into congestion, if too many packets are sent, in 6 hours test i was able to go as low as 3ms
97
+ delay (500 );
91
98
}
92
99
// disconnecting
93
100
if (!deviceConnected && oldDeviceConnected) {
Original file line number Diff line number Diff line change
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)) {} // BLE2901
27
+
28
+ /* *
29
+ * @brief Set the Characteristic User Description
30
+ */
31
+ void BLE2901::setDescription (String userDesc) {
32
+ if (userDesc.length () > ESP_GATT_MAX_ATTR_LEN) {
33
+ log_e (" Size %d too large, must be no bigger than %d" , userDesc.length (), ESP_GATT_MAX_ATTR_LEN);
34
+ return ;
35
+ }
36
+ setValue (userDesc);
37
+ }
38
+
39
+ #endif
40
+ #endif /* SOC_BLE_SUPPORTED */
Original file line number Diff line number Diff line change
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
+
19
+ #ifndef COMPONENTS_CPP_UTILS_BLE2901_H_
20
+ #define COMPONENTS_CPP_UTILS_BLE2901_H_
21
+ #include " soc/soc_caps.h"
22
+ #if SOC_BLE_SUPPORTED
23
+
24
+ #include " sdkconfig.h"
25
+ #if defined(CONFIG_BLUEDROID_ENABLED)
26
+
27
+ #include " BLEDescriptor.h"
28
+
29
+ class BLE2901 : public BLEDescriptor {
30
+ public:
31
+ BLE2901 ();
32
+ void setDescription (String desc);
33
+ }; // BLE2901
34
+
35
+ #endif /* CONFIG_BLUEDROID_ENABLED */
36
+ #endif /* SOC_BLE_SUPPORTED */
37
+ #endif /* COMPONENTS_CPP_UTILS_BLE2901_H_ */
You can’t perform that action at this time.
0 commit comments