-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds BLE Characteristic User Description 0x2901 Descriptor (#9883)
Adds a class for 0x2901 - Characteristic User Descriptor. This Descriptor is usual in BLE and describes with text what each characteristic is about. Improve Notify.ino example by adding the 0x2901 descriptor
- Loading branch information
Showing
4 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
BLE2901.h | ||
GATT Descriptor 0x2901 Characteristic User Description | ||
The value of this description is a user-readable string | ||
describing the characteristic. | ||
The Characteristic User Description descriptor | ||
provides a textual user description for a characteristic | ||
value. | ||
If the Writable Auxiliary bit of the Characteristics | ||
Properties is set then this descriptor is written. Only one | ||
User Description descriptor exists in a characteristic | ||
definition. | ||
*/ | ||
|
||
#include "soc/soc_caps.h" | ||
#if SOC_BLE_SUPPORTED | ||
|
||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BLUEDROID_ENABLED) | ||
|
||
#include "BLE2901.h" | ||
|
||
BLE2901::BLE2901() : BLEDescriptor(BLEUUID((uint16_t)0x2901)) {} // BLE2901 | ||
|
||
/** | ||
* @brief Set the Characteristic User Description | ||
*/ | ||
void BLE2901::setDescription(String userDesc) { | ||
if (userDesc.length() > ESP_GATT_MAX_ATTR_LEN) { | ||
log_e("Size %d too large, must be no bigger than %d", userDesc.length(), ESP_GATT_MAX_ATTR_LEN); | ||
return; | ||
} | ||
setValue(userDesc); | ||
} | ||
|
||
#endif | ||
#endif /* SOC_BLE_SUPPORTED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
BLE2901.h | ||
GATT Descriptor 0x2901 Characteristic User Description | ||
The value of this description is a user-readable string | ||
describing the characteristic. | ||
The Characteristic User Description descriptor | ||
provides a textual user description for a characteristic | ||
value. | ||
If the Writable Auxiliary bit of the Characteristics | ||
Properties is set then this descriptor is written. Only one | ||
User Description descriptor exists in a characteristic | ||
definition. | ||
*/ | ||
|
||
#ifndef COMPONENTS_CPP_UTILS_BLE2901_H_ | ||
#define COMPONENTS_CPP_UTILS_BLE2901_H_ | ||
#include "soc/soc_caps.h" | ||
#if SOC_BLE_SUPPORTED | ||
|
||
#include "sdkconfig.h" | ||
#if defined(CONFIG_BLUEDROID_ENABLED) | ||
|
||
#include "BLEDescriptor.h" | ||
|
||
class BLE2901 : public BLEDescriptor { | ||
public: | ||
BLE2901(); | ||
void setDescription(String desc); | ||
}; // BLE2901 | ||
|
||
#endif /* CONFIG_BLUEDROID_ENABLED */ | ||
#endif /* SOC_BLE_SUPPORTED */ | ||
#endif /* COMPONENTS_CPP_UTILS_BLE2901_H_ */ |