ESPHome
2024.10.2
esphome
esphome
components
esp32_ble_server
ble_descriptor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/components/esp32_ble/ble_uuid.h
"
4
5
#ifdef USE_ESP32
6
7
#include <esp_gatt_defs.h>
8
#include <esp_gatts_api.h>
9
10
namespace
esphome
{
11
namespace
esp32_ble_server {
12
13
using namespace
esp32_ble;
14
15
class
BLECharacteristic;
16
17
class
BLEDescriptor
{
18
public
:
19
BLEDescriptor
(
ESPBTUUID
uuid, uint16_t max_len = 100);
20
virtual
~
BLEDescriptor
();
21
void
do_create(
BLECharacteristic
*characteristic);
22
23
void
set_value(
const
std::string &value);
24
void
set_value(
const
uint8_t *data,
size_t
length
);
25
26
void
gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
27
28
bool
is_created
() {
return
this->state_ == CREATED; }
29
bool
is_failed
() {
return
this->state_ == FAILED; }
30
31
protected
:
32
BLECharacteristic
*characteristic_{
nullptr
};
33
ESPBTUUID
uuid_
;
34
uint16_t handle_{0xFFFF};
35
36
esp_attr_value_t
value_
;
37
38
esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
39
40
enum
State
: uint8_t {
41
FAILED = 0x00,
42
INIT
,
43
CREATING
,
44
CREATED
,
45
} state_{INIT};
46
};
47
48
}
// namespace esp32_ble_server
49
}
// namespace esphome
50
51
#endif
esphome::esp32_ble_server::BLEDescriptor::value_
esp_attr_value_t value_
Definition:
ble_descriptor.h:36
esphome::esp32_ble::ESPBTUUID
Definition:
ble_uuid.h:14
esphome::esp32_ble_server::BLEDescriptor::uuid_
ESPBTUUID uuid_
Definition:
ble_descriptor.h:33
esphome::esp32_ble_server::BLEDescriptor
Definition:
ble_descriptor.h:17
esphome::esp32_ble_server::BLEDescriptor::INIT
Definition:
ble_descriptor.h:42
esphome::esp32_ble_server::BLEDescriptor::State
State
Definition:
ble_descriptor.h:40
ble_uuid.h
esphome::esp32_ble_server::BLECharacteristic
Definition:
ble_characteristic.h:25
esphome::esp32_ble_server::BLEDescriptor::CREATING
Definition:
ble_descriptor.h:43
length
uint16_t length
Definition:
tt21100.cpp:12
esphome::esp32_ble_server::BLEDescriptor::CREATED
Definition:
ble_descriptor.h:44
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::esp32_ble_server::BLEDescriptor::is_failed
bool is_failed()
Definition:
ble_descriptor.h:29
esphome::esp32_ble_server::BLEDescriptor::is_created
bool is_created()
Definition:
ble_descriptor.h:28
Generated by
1.8.13