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
130 this->gap_scan_event_handlers_.push_back(handler);
132#ifdef USE_ESP32_BLE_CLIENT
135#ifdef USE_ESP32_BLE_SERVER
139 this->ble_status_event_handlers_.push_back(handler);
144#ifdef USE_ESP32_BLE_SERVER
145 static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
147#ifdef USE_ESP32_BLE_CLIENT
148 static void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param);
150 static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
155#ifdef USE_ESP32_BLE_ADVERTISING
163 std::vector<GAPEventHandler *> gap_event_handlers_;
164 std::vector<GAPScanEventHandler *> gap_scan_event_handlers_;
165#ifdef USE_ESP32_BLE_CLIENT
166 std::vector<GATTcEventHandler *> gattc_event_handlers_;
168#ifdef USE_ESP32_BLE_SERVER
169 std::vector<GATTsEventHandler *> gatts_event_handlers_;
171 std::vector<BLEStatusEventHandler *> ble_status_event_handlers_;
181#ifdef USE_ESP32_BLE_ADVERTISING
184 esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
185 uint32_t advertising_cycle_time_{};
188 uint16_t appearance_{0};
192 bool enable_on_boot_{};
Base class for all automation conditions.
void play(Ts... x) override
void play(Ts... x) override
bool check(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)