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

#include <ble_characteristic.h>

Public Member Functions

 BLECharacteristic (ESPBTUUID uuid, uint32_t properties)
 
 ~BLECharacteristic ()
 
void set_value (const uint8_t *data, size_t length)
 
void set_value (std::vector< uint8_t > value)
 
void set_value (const std::string &value)
 
void set_value (uint8_t &data)
 
void set_value (uint16_t &data)
 
void set_value (uint32_t &data)
 
void set_value (int &data)
 
void set_value (float &data)
 
void set_value (double &data)
 
void set_value (bool &data)
 
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 (bool notification=true)
 
void do_create (BLEService *service)
 
void gatts_event_handler (esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
 
void on_write (const std::function< void(const std::vector< uint8_t > &)> &&func)
 
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 ()
 

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::function< void(const std::vector< uint8_t > &)> on_write_
 
esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE
 
enum esphome::esp32_ble_server::BLECharacteristic::State INIT
 

Detailed Description

Definition at line 25 of file ble_characteristic.h.

Member Enumeration Documentation

◆ State

Enumerator
FAILED 
INIT 
CREATING 
CREATING_DEPENDENTS 
CREATED 

Definition at line 89 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 106 of file ble_characteristic.cpp.

◆ do_create()

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

Definition at line 113 of file ble_characteristic.cpp.

◆ 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 204 of file ble_characteristic.cpp.

◆ get_service()

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

Definition at line 58 of file ble_characteristic.h.

◆ get_uuid()

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

Definition at line 59 of file ble_characteristic.h.

◆ get_value()

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

Definition at line 60 of file ble_characteristic.h.

◆ is_created()

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

Definition at line 132 of file ble_characteristic.cpp.

◆ is_failed()

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

Definition at line 148 of file ble_characteristic.cpp.

◆ notify()

void esphome::esp32_ble_server::BLECharacteristic::notify ( bool  notification = true)

Definition at line 87 of file ble_characteristic.cpp.

◆ on_write()

void esphome::esp32_ble_server::BLECharacteristic::on_write ( const std::function< void(const std::vector< uint8_t > &)> &&  func)
inline

Definition at line 53 of file ble_characteristic.h.

◆ remove_descriptor()

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

Definition at line 108 of file ble_characteristic.cpp.

◆ set_broadcast_property()

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

Definition at line 161 of file ble_characteristic.cpp.

◆ set_indicate_property()

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

Definition at line 168 of file ble_characteristic.cpp.

◆ set_notify_property()

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

Definition at line 175 of file ble_characteristic.cpp.

◆ set_read_property()

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

Definition at line 182 of file ble_characteristic.cpp.

◆ set_value() [1/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( const uint8_t *  data,
size_t  length 
)

Definition at line 43 of file ble_characteristic.cpp.

◆ set_value() [2/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( std::vector< uint8_t >  value)

Definition at line 35 of file ble_characteristic.cpp.

◆ set_value() [3/10]

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

Definition at line 40 of file ble_characteristic.cpp.

◆ set_value() [4/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( uint8_t &  data)

Definition at line 46 of file ble_characteristic.cpp.

◆ set_value() [5/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( uint16_t &  data)

Definition at line 51 of file ble_characteristic.cpp.

◆ set_value() [6/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( uint32_t &  data)

Definition at line 57 of file ble_characteristic.cpp.

◆ set_value() [7/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( int &  data)

Definition at line 65 of file ble_characteristic.cpp.

◆ set_value() [8/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( float &  data)

Definition at line 73 of file ble_characteristic.cpp.

◆ set_value() [9/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( double &  data)

Definition at line 77 of file ble_characteristic.cpp.

◆ set_value() [10/10]

void esphome::esp32_ble_server::BLECharacteristic::set_value ( bool &  data)

Definition at line 81 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 196 of file ble_characteristic.cpp.

◆ set_write_property()

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

Definition at line 189 of file ble_characteristic.cpp.

Field Documentation

◆ descriptors_

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

Definition at line 83 of file ble_characteristic.h.

◆ handle_

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

Definition at line 77 of file ble_characteristic.h.

◆ INIT

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

◆ on_write_

std::function<void(const std::vector<uint8_t> &)> esphome::esp32_ble_server::BLECharacteristic::on_write_
protected

Definition at line 85 of file ble_characteristic.h.

◆ permissions_

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

Definition at line 87 of file ble_characteristic.h.

◆ properties_

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

Definition at line 76 of file ble_characteristic.h.

◆ PROPERTY_BROADCAST

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

Definition at line 65 of file ble_characteristic.h.

◆ PROPERTY_INDICATE

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

Definition at line 66 of file ble_characteristic.h.

◆ PROPERTY_NOTIFY

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

Definition at line 64 of file ble_characteristic.h.

◆ PROPERTY_READ

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

Definition at line 62 of file ble_characteristic.h.

◆ PROPERTY_WRITE

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

Definition at line 63 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 67 of file ble_characteristic.h.

◆ service_

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

Definition at line 74 of file ble_characteristic.h.

◆ set_value_lock_

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

Definition at line 81 of file ble_characteristic.h.

◆ uuid_

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

Definition at line 75 of file ble_characteristic.h.

◆ value_

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

Definition at line 80 of file ble_characteristic.h.

◆ value_read_offset_

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

Definition at line 79 of file ble_characteristic.h.

◆ write_event_

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

Definition at line 73 of file ble_characteristic.h.


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