1 #include "ble_descriptor.h" 2 #include "ble_characteristic.h" 3 #include "ble_service.h" 11 namespace esp32_ble_server {
13 static const char *
const TAG =
"esp32_ble_server.descriptor";
18 this->
value_.attr_max_len = max_len;
19 this->
value_.attr_value = (uint8_t *) malloc(max_len);
26 esp_attr_control_t control;
27 control.auto_rsp = ESP_GATT_AUTO_RSP;
29 ESP_LOGV(TAG,
"Creating descriptor - %s", this->
uuid_.
to_string().c_str());
34 ESP_LOGE(TAG,
"esp_ble_gatts_add_char_descr failed: %d", err);
43 if (length > this->
value_.attr_max_len) {
44 ESP_LOGE(TAG,
"Size %d too large, must be no bigger than %d", length, this->
value_.attr_max_len);
48 memcpy(this->
value_.attr_value, data, length);
52 esp_ble_gatts_cb_param_t *param) {
54 case ESP_GATTS_ADD_CHAR_DESCR_EVT: {
56 this->characteristic_->get_service()->get_handle() == param->add_char_descr.service_handle &&
58 this->
handle_ = param->add_char_descr.attr_handle;
63 case ESP_GATTS_WRITE_EVT: {
64 if (this->
handle_ == param->write.handle) {
65 this->
value_.attr_len = param->write.len;
66 memcpy(this->
value_.attr_value, param->write.value, param->write.len);
esp_gatt_perm_t permissions_
BLEService * get_service()
static ESPBTUUID from_uuid(esp_bt_uuid_t uuid)
BLECharacteristic * get_last_created_characteristic()
void set_value(const std::string &value)
void do_create(BLECharacteristic *characteristic)
void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
BLECharacteristic * characteristic_
std::string to_string() const
Implementation of SPI Controller mode.
BLEDescriptor(ESPBTUUID uuid, uint16_t max_len=100)
esp_bt_uuid_t get_uuid() const