7#ifdef USE_ESP32_BLE_ADVERTISING
24#include <esp_gap_ble_api.h>
25#include <esp_gattc_api.h>
26#include <esp_gatts_api.h>
33static constexpr uint8_t MAX_BLE_QUEUE_SIZE = 100;
35static constexpr uint8_t MAX_BLE_QUEUE_SIZE = 88;
70 virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0;
78#ifdef USE_ESP32_BLE_CLIENT
82 esp_ble_gattc_cb_param_t *param) = 0;
86#ifdef USE_ESP32_BLE_SERVER
90 esp_ble_gatts_cb_param_t *param) = 0;
104 this->advertising_cycle_time_ = advertising_cycle_time;
111 void setup()
override;
112 void loop()
override;
115 void set_name(
const std::string &name) { this->name_ = name; }
117#ifdef USE_ESP32_BLE_ADVERTISING
128#ifdef ESPHOME_ESP32_BLE_GAP_EVENT_HANDLER_COUNT
131#ifdef ESPHOME_ESP32_BLE_GAP_SCAN_EVENT_HANDLER_COUNT
133 this->gap_scan_event_handlers_.push_back(handler);
136#if defined(USE_ESP32_BLE_CLIENT) && defined(ESPHOME_ESP32_BLE_GATTC_EVENT_HANDLER_COUNT)
139#if defined(USE_ESP32_BLE_SERVER) && defined(ESPHOME_ESP32_BLE_GATTS_EVENT_HANDLER_COUNT)
142#ifdef ESPHOME_ESP32_BLE_BLE_STATUS_EVENT_HANDLER_COUNT
144 this->ble_status_event_handlers_.push_back(handler);
150#ifdef USE_ESP32_BLE_SERVER
151 static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
153#ifdef USE_ESP32_BLE_CLIENT
154 static void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param);
156 static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
161#ifdef USE_ESP32_BLE_ADVERTISING
174#ifdef ESPHOME_ESP32_BLE_GAP_EVENT_HANDLER_COUNT
177#ifdef ESPHOME_ESP32_BLE_GAP_SCAN_EVENT_HANDLER_COUNT
180#if defined(USE_ESP32_BLE_CLIENT) && defined(ESPHOME_ESP32_BLE_GATTC_EVENT_HANDLER_COUNT)
183#if defined(USE_ESP32_BLE_SERVER) && defined(ESPHOME_ESP32_BLE_GATTS_EVENT_HANDLER_COUNT)
186#ifdef ESPHOME_ESP32_BLE_BLE_STATUS_EVENT_HANDLER_COUNT
198#ifdef USE_ESP32_BLE_ADVERTISING
201 esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
202 uint32_t advertising_cycle_time_{};
205 uint16_t appearance_{0};
209 bool enable_on_boot_{};
Base class for all automation conditions.
Minimal static vector - saves memory by avoiding std::vector overhead.
void play(const Ts &...x) override
void play(const Ts &...x) override
bool check(const Ts &...x) override
virtual void ble_before_disabled_event_handler()=0
void advertising_set_manufacturer_data(const std::vector< uint8_t > &data)
void register_gap_event_handler(GAPEventHandler *handler)
void set_enable_on_boot(bool enable_on_boot)
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
void register_gattc_event_handler(GATTcEventHandler *handler)
void register_gap_scan_event_handler(GAPScanEventHandler *handler)
static void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param)
friend void enqueue_ble_event(Args... args)
void advertising_register_raw_advertisement_callback(std::function< void(bool)> &&callback)
void advertising_set_service_data_and_name(std::span< const uint8_t > data, bool include_name)
void set_advertising_cycle_time(uint32_t advertising_cycle_time)
void register_ble_status_event_handler(BLEStatusEventHandler *handler)
void advertising_add_service_uuid(ESPBTUUID uuid)
void dump_config() override
static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void register_gatts_event_handler(GATTsEventHandler *handler)
void advertising_set_service_data(const std::vector< uint8_t > &data)
void set_io_capability(IoCapability io_capability)
void advertising_set_appearance(uint16_t appearance)
float get_setup_priority() const override
void set_name(const std::string &name)
uint32_t get_advertising_cycle_time() const
void advertising_remove_service_uuid(ESPBTUUID uuid)
virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)=0
virtual void gap_scan_event_handler(const BLEScanResult &scan_result)=0
virtual void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param)=0
virtual void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)=0
@ BLE_COMPONENT_STATE_DISABLE
BLE should be disabled on next loop.
@ BLE_COMPONENT_STATE_OFF
Nothing has been initialized yet.
@ BLE_COMPONENT_STATE_ENABLE
BLE should be enabled on next loop.
@ BLE_COMPONENT_STATE_DISABLED
BLE is disabled.
@ BLE_COMPONENT_STATE_ACTIVE
BLE is active.
uint64_t ble_addr_to_uint64(const esp_bd_addr_t address)