ESPHome  2025.2.0
Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes
esphome::esp32_ble_server::BLECharacteristic Class Reference

#include <ble_characteristic.h>

Inheritance diagram for esphome::esp32_ble_server::BLECharacteristic:
esphome::event_emitter::EventEmitter< BLECharacteristicEvt::VectorEvt, std::vector< uint8_t >, uint16_t > esphome::event_emitter::EventEmitter< BLECharacteristicEvt::EmptyEvt, uint16_t >

Public Member Functions

 BLECharacteristic (ESPBTUUID uuid, uint32_t properties)
 
 ~BLECharacteristic ()
 
void set_value (ByteBuffer buffer)
 
void set_value (const std::vector< uint8_t > &buffer)
 
void set_value (const std::string &buffer)
 
void set_broadcast_property (bool value)
 
void set_indicate_property (bool value)
 
void set_notify_property (bool value)
 
void set_read_property (bool value)
 
void set_write_property (bool value)
 
void set_write_no_response_property (bool value)
 
void notify ()
 
void do_create (BLEService *service)
 
void do_delete ()
 
void gatts_event_handler (esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
 
void add_descriptor (BLEDescriptor *descriptor)
 
void remove_descriptor (BLEDescriptor *descriptor)
 
BLEServiceget_service ()
 
ESPBTUUID get_uuid ()
 
std::vector< uint8_t > & get_value ()
 
bool is_created ()
 
bool is_failed ()
 
- Public Member Functions inherited from esphome::event_emitter::EventEmitter< BLECharacteristicEvt::VectorEvt, std::vector< uint8_t >, uint16_t >
EventEmitterListenerID on (BLECharacteristicEvt::VectorEvt event, std::function< void(Args...)> listener)
 
void off (BLECharacteristicEvt::VectorEvt event, EventEmitterListenerID id)
 
- Public Member Functions inherited from esphome::event_emitter::EventEmitter< BLECharacteristicEvt::EmptyEvt, uint16_t >
EventEmitterListenerID on (BLECharacteristicEvt::EmptyEvt event, std::function< void(Args...)> listener)
 
void off (BLECharacteristicEvt::EmptyEvt event, EventEmitterListenerID id)
 

Static Public Attributes

static const uint32_t PROPERTY_READ = 1 << 0
 
static const uint32_t PROPERTY_WRITE = 1 << 1
 
static const uint32_t PROPERTY_NOTIFY = 1 << 2
 
static const uint32_t PROPERTY_BROADCAST = 1 << 3
 
static const uint32_t PROPERTY_INDICATE = 1 << 4
 
static const uint32_t PROPERTY_WRITE_NR = 1 << 5
 

Protected Types

enum  State : uint8_t {
  FAILED = 0x00, INIT, CREATING, CREATING_DEPENDENTS,
  CREATED
}
 

Protected Attributes

bool write_event_ {false}
 
BLEServiceservice_ {}
 
ESPBTUUID uuid_
 
esp_gatt_char_prop_t properties_
 
uint16_t handle_ {0xFFFF}
 
uint16_t value_read_offset_ {0}
 
std::vector< uint8_t > value_
 
SemaphoreHandle_t set_value_lock_
 
std::vector< BLEDescriptor * > descriptors_
 
std::unordered_map< uint16_t, bool > clients_to_notify_
 
esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE
 
enum esphome::esp32_ble_server::BLECharacteristic::State INIT
 

Additional Inherited Members

- Protected Member Functions inherited from esphome::event_emitter::EventEmitter< BLECharacteristicEvt::VectorEvt, std::vector< uint8_t >, uint16_t >
void emit_ (BLECharacteristicEvt::VectorEvt event, Args... args)
 
EventEmitterListenerID get_next_id_ (BLECharacteristicEvt::VectorEvt event)
 
- Protected Member Functions inherited from esphome::event_emitter::EventEmitter< BLECharacteristicEvt::EmptyEvt, uint16_t >
void emit_ (BLECharacteristicEvt::EmptyEvt event, Args... args)
 
EventEmitterListenerID get_next_id_ (BLECharacteristicEvt::EmptyEvt event)
 

Detailed Description

Definition at line 40 of file ble_characteristic.h.

Member Enumeration Documentation

◆ State

Enumerator
FAILED 
INIT 
CREATING 
CREATING_DEPENDENTS 
CREATED 

Definition at line 96 of file ble_characteristic.h.

Constructor & Destructor Documentation

◆ BLECharacteristic()

esphome::esp32_ble_server::BLECharacteristic::BLECharacteristic ( ESPBTUUID  uuid,
uint32_t  properties 
)

Definition at line 21 of file ble_characteristic.cpp.

◆ ~BLECharacteristic()

esphome::esp32_ble_server::BLECharacteristic::~BLECharacteristic ( )

Definition at line 14 of file ble_characteristic.cpp.

Member Function Documentation

◆ add_descriptor()

void esphome::esp32_ble_server::BLECharacteristic::add_descriptor ( BLEDescriptor descriptor)

Definition at line 72 of file ble_characteristic.cpp.

◆ do_create()

void esphome::esp32_ble_server::BLECharacteristic::do_create ( BLEService service)

Definition at line 96 of file ble_characteristic.cpp.

◆ do_delete()

void esphome::esp32_ble_server::BLECharacteristic::do_delete ( )
inline

Definition at line 60 of file ble_characteristic.h.

◆ gatts_event_handler()

void esphome::esp32_ble_server::BLECharacteristic::gatts_event_handler ( esp_gatts_cb_event_t  event,
esp_gatt_if_t  gatts_if,
esp_ble_gatts_cb_param_t *  param 
)

Definition at line 187 of file ble_characteristic.cpp.

◆ get_service()

BLEService* esphome::esp32_ble_server::BLECharacteristic::get_service ( )
inline

Definition at line 66 of file ble_characteristic.h.

◆ get_uuid()

ESPBTUUID esphome::esp32_ble_server::BLECharacteristic::get_uuid ( )
inline

Definition at line 67 of file ble_characteristic.h.

◆ get_value()

std::vector<uint8_t>& esphome::esp32_ble_server::BLECharacteristic::get_value ( )
inline

Definition at line 68 of file ble_characteristic.h.

◆ is_created()

bool esphome::esp32_ble_server::BLECharacteristic::is_created ( )

Definition at line 115 of file ble_characteristic.cpp.

◆ is_failed()

bool esphome::esp32_ble_server::BLECharacteristic::is_failed ( )

Definition at line 131 of file ble_characteristic.cpp.

◆ notify()

void esphome::esp32_ble_server::BLECharacteristic::notify ( )

Definition at line 46 of file ble_characteristic.cpp.

◆ remove_descriptor()

void esphome::esp32_ble_server::BLECharacteristic::remove_descriptor ( BLEDescriptor descriptor)

Definition at line 91 of file ble_characteristic.cpp.

◆ set_broadcast_property()

void esphome::esp32_ble_server::BLECharacteristic::set_broadcast_property ( bool  value)

Definition at line 144 of file ble_characteristic.cpp.

◆ set_indicate_property()

void esphome::esp32_ble_server::BLECharacteristic::set_indicate_property ( bool  value)

Definition at line 151 of file ble_characteristic.cpp.

◆ set_notify_property()

void esphome::esp32_ble_server::BLECharacteristic::set_notify_property ( bool  value)

Definition at line 158 of file ble_characteristic.cpp.

◆ set_read_property()

void esphome::esp32_ble_server::BLECharacteristic::set_read_property ( bool  value)

Definition at line 165 of file ble_characteristic.cpp.

◆ set_value() [1/3]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( ByteBuffer  buffer)

Definition at line 35 of file ble_characteristic.cpp.

◆ set_value() [2/3]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( const std::vector< uint8_t > &  buffer)

Definition at line 37 of file ble_characteristic.cpp.

◆ set_value() [3/3]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( const std::string &  buffer)

Definition at line 42 of file ble_characteristic.cpp.

◆ set_write_no_response_property()

void esphome::esp32_ble_server::BLECharacteristic::set_write_no_response_property ( bool  value)

Definition at line 179 of file ble_characteristic.cpp.

◆ set_write_property()

void esphome::esp32_ble_server::BLECharacteristic::set_write_property ( bool  value)

Definition at line 172 of file ble_characteristic.cpp.

Field Documentation

◆ clients_to_notify_

std::unordered_map<uint16_t, bool> esphome::esp32_ble_server::BLECharacteristic::clients_to_notify_
protected

Definition at line 92 of file ble_characteristic.h.

◆ descriptors_

std::vector<BLEDescriptor *> esphome::esp32_ble_server::BLECharacteristic::descriptors_
protected

Definition at line 91 of file ble_characteristic.h.

◆ handle_

uint16_t esphome::esp32_ble_server::BLECharacteristic::handle_ {0xFFFF}
protected

Definition at line 85 of file ble_characteristic.h.

◆ INIT

enum esphome::esp32_ble_server::BLECharacteristic::State esphome::esp32_ble_server::BLECharacteristic::INIT
protected

◆ permissions_

esp_gatt_perm_t esphome::esp32_ble_server::BLECharacteristic::permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE
protected

Definition at line 94 of file ble_characteristic.h.

◆ properties_

esp_gatt_char_prop_t esphome::esp32_ble_server::BLECharacteristic::properties_
protected

Definition at line 84 of file ble_characteristic.h.

◆ PROPERTY_BROADCAST

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_BROADCAST = 1 << 3
static

Definition at line 73 of file ble_characteristic.h.

◆ PROPERTY_INDICATE

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_INDICATE = 1 << 4
static

Definition at line 74 of file ble_characteristic.h.

◆ PROPERTY_NOTIFY

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_NOTIFY = 1 << 2
static

Definition at line 72 of file ble_characteristic.h.

◆ PROPERTY_READ

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_READ = 1 << 0
static

Definition at line 70 of file ble_characteristic.h.

◆ PROPERTY_WRITE

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_WRITE = 1 << 1
static

Definition at line 71 of file ble_characteristic.h.

◆ PROPERTY_WRITE_NR

const uint32_t esphome::esp32_ble_server::BLECharacteristic::PROPERTY_WRITE_NR = 1 << 5
static

Definition at line 75 of file ble_characteristic.h.

◆ service_

BLEService* esphome::esp32_ble_server::BLECharacteristic::service_ {}
protected

Definition at line 82 of file ble_characteristic.h.

◆ set_value_lock_

SemaphoreHandle_t esphome::esp32_ble_server::BLECharacteristic::set_value_lock_
protected

Definition at line 89 of file ble_characteristic.h.

◆ uuid_

ESPBTUUID esphome::esp32_ble_server::BLECharacteristic::uuid_
protected

Definition at line 83 of file ble_characteristic.h.

◆ value_

std::vector<uint8_t> esphome::esp32_ble_server::BLECharacteristic::value_
protected

Definition at line 88 of file ble_characteristic.h.

◆ value_read_offset_

uint16_t esphome::esp32_ble_server::BLECharacteristic::value_read_offset_ {0}
protected

Definition at line 87 of file ble_characteristic.h.

◆ write_event_

bool esphome::esp32_ble_server::BLECharacteristic::write_event_ {false}
protected

Definition at line 81 of file ble_characteristic.h.


The documentation for this class was generated from the following files: