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

#include <ble_service.h>

Public Member Functions

 BLEService (ESPBTUUID uuid, uint16_t num_handles, uint8_t inst_id, bool advertise)
 
 ~BLEService ()
 
BLECharacteristicget_characteristic (ESPBTUUID uuid)
 
BLECharacteristicget_characteristic (uint16_t uuid)
 
BLECharacteristiccreate_characteristic (const std::string &uuid, esp_gatt_char_prop_t properties)
 
BLECharacteristiccreate_characteristic (uint16_t uuid, esp_gatt_char_prop_t properties)
 
BLECharacteristiccreate_characteristic (ESPBTUUID uuid, esp_gatt_char_prop_t properties)
 
ESPBTUUID get_uuid ()
 
BLECharacteristicget_last_created_characteristic ()
 
uint16_t get_handle ()
 
BLEServerget_server ()
 
void do_create (BLEServer *server)
 
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 start ()
 
void stop ()
 
bool is_created ()
 
bool is_failed ()
 
bool is_running ()
 
bool is_starting ()
 
bool is_deleted ()
 

Protected Types

enum  InitState : uint8_t {
  FAILED = 0x00, INIT, CREATING, CREATING_DEPENDENTS,
  CREATED, DELETING, DELETED
}
 
enum  RunningState : uint8_t { STARTING, RUNNING, STOPPING, STOPPED }
 

Protected Member Functions

bool do_create_characteristics_ ()
 
void stop_ ()
 

Protected Attributes

std::vector< BLECharacteristic * > characteristics_
 
BLECharacteristiclast_created_characteristic_ {nullptr}
 
uint32_t created_characteristic_count_ {0}
 
BLEServerserver_
 
ESPBTUUID uuid_
 
uint16_t num_handles_
 
uint16_t handle_ {0xFFFF}
 
uint8_t inst_id_
 
bool advertise_ {false}
 
bool should_start_ {false}
 
enum esphome::esp32_ble_server::BLEService::InitState INIT
 
enum esphome::esp32_ble_server::BLEService::RunningState STOPPED
 

Detailed Description

Definition at line 23 of file ble_service.h.

Member Enumeration Documentation

◆ InitState

Enumerator
FAILED 
INIT 
CREATING 
CREATING_DEPENDENTS 
CREATED 
DELETING 
DELETED 

Definition at line 69 of file ble_service.h.

◆ RunningState

Enumerator
STARTING 
RUNNING 
STOPPING 
STOPPED 

Definition at line 79 of file ble_service.h.

Constructor & Destructor Documentation

◆ BLEService()

esphome::esp32_ble_server::BLEService::BLEService ( ESPBTUUID  uuid,
uint16_t  num_handles,
uint8_t  inst_id,
bool  advertise 
)

Definition at line 12 of file ble_service.cpp.

◆ ~BLEService()

esphome::esp32_ble_server::BLEService::~BLEService ( )

Definition at line 15 of file ble_service.cpp.

Member Function Documentation

◆ create_characteristic() [1/3]

BLECharacteristic * esphome::esp32_ble_server::BLEService::create_characteristic ( const std::string &  uuid,
esp_gatt_char_prop_t  properties 
)

Definition at line 34 of file ble_service.cpp.

◆ create_characteristic() [2/3]

BLECharacteristic * esphome::esp32_ble_server::BLEService::create_characteristic ( uint16_t  uuid,
esp_gatt_char_prop_t  properties 
)

Definition at line 31 of file ble_service.cpp.

◆ create_characteristic() [3/3]

BLECharacteristic * esphome::esp32_ble_server::BLEService::create_characteristic ( ESPBTUUID  uuid,
esp_gatt_char_prop_t  properties 
)

Definition at line 37 of file ble_service.cpp.

◆ do_create()

void esphome::esp32_ble_server::BLEService::do_create ( BLEServer server)

Definition at line 44 of file ble_service.cpp.

◆ do_create_characteristics_()

bool esphome::esp32_ble_server::BLEService::do_create_characteristics_ ( )
protected

Definition at line 75 of file ble_service.cpp.

◆ do_delete()

void esphome::esp32_ble_server::BLEService::do_delete ( )

Definition at line 61 of file ble_service.cpp.

◆ gatts_event_handler()

void esphome::esp32_ble_server::BLEService::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 135 of file ble_service.cpp.

◆ get_characteristic() [1/2]

BLECharacteristic * esphome::esp32_ble_server::BLEService::get_characteristic ( ESPBTUUID  uuid)

Definition at line 20 of file ble_service.cpp.

◆ get_characteristic() [2/2]

BLECharacteristic * esphome::esp32_ble_server::BLEService::get_characteristic ( uint16_t  uuid)

Definition at line 28 of file ble_service.cpp.

◆ get_handle()

uint16_t esphome::esp32_ble_server::BLEService::get_handle ( )
inline

Definition at line 36 of file ble_service.h.

◆ get_last_created_characteristic()

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

Definition at line 35 of file ble_service.h.

◆ get_server()

BLEServer* esphome::esp32_ble_server::BLEService::get_server ( )
inline

Definition at line 38 of file ble_service.h.

◆ get_uuid()

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

Definition at line 34 of file ble_service.h.

◆ is_created()

bool esphome::esp32_ble_server::BLEService::is_created ( )

Definition at line 122 of file ble_service.cpp.

◆ is_deleted()

bool esphome::esp32_ble_server::BLEService::is_deleted ( )
inline

Definition at line 52 of file ble_service.h.

◆ is_failed()

bool esphome::esp32_ble_server::BLEService::is_failed ( )

Definition at line 123 of file ble_service.cpp.

◆ is_running()

bool esphome::esp32_ble_server::BLEService::is_running ( )
inline

Definition at line 50 of file ble_service.h.

◆ is_starting()

bool esphome::esp32_ble_server::BLEService::is_starting ( )
inline

Definition at line 51 of file ble_service.h.

◆ start()

void esphome::esp32_ble_server::BLEService::start ( )

Definition at line 89 of file ble_service.cpp.

◆ stop()

void esphome::esp32_ble_server::BLEService::stop ( )

Definition at line 104 of file ble_service.cpp.

◆ stop_()

void esphome::esp32_ble_server::BLEService::stop_ ( )
protected

Definition at line 109 of file ble_service.cpp.

Field Documentation

◆ advertise_

bool esphome::esp32_ble_server::BLEService::advertise_ {false}
protected

Definition at line 63 of file ble_service.h.

◆ characteristics_

std::vector<BLECharacteristic *> esphome::esp32_ble_server::BLEService::characteristics_
protected

Definition at line 55 of file ble_service.h.

◆ created_characteristic_count_

uint32_t esphome::esp32_ble_server::BLEService::created_characteristic_count_ {0}
protected

Definition at line 57 of file ble_service.h.

◆ handle_

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

Definition at line 61 of file ble_service.h.

◆ INIT

enum esphome::esp32_ble_server::BLEService::InitState esphome::esp32_ble_server::BLEService::INIT
protected

◆ inst_id_

uint8_t esphome::esp32_ble_server::BLEService::inst_id_
protected

Definition at line 62 of file ble_service.h.

◆ last_created_characteristic_

BLECharacteristic* esphome::esp32_ble_server::BLEService::last_created_characteristic_ {nullptr}
protected

Definition at line 56 of file ble_service.h.

◆ num_handles_

uint16_t esphome::esp32_ble_server::BLEService::num_handles_
protected

Definition at line 60 of file ble_service.h.

◆ server_

BLEServer* esphome::esp32_ble_server::BLEService::server_
protected

Definition at line 58 of file ble_service.h.

◆ should_start_

bool esphome::esp32_ble_server::BLEService::should_start_ {false}
protected

Definition at line 64 of file ble_service.h.

◆ STOPPED

enum esphome::esp32_ble_server::BLEService::RunningState esphome::esp32_ble_server::BLEService::STOPPED
protected

◆ uuid_

ESPBTUUID esphome::esp32_ble_server::BLEService::uuid_
protected

Definition at line 59 of file ble_service.h.


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