7#ifdef USE_ESP32_BLE_ADVERTISING
23#include <esp_gap_ble_api.h>
24#include <esp_gattc_api.h>
25#include <esp_gatts_api.h>
32static constexpr uint8_t MAX_BLE_QUEUE_SIZE = 100;
34static constexpr uint8_t MAX_BLE_QUEUE_SIZE = 88;
69 virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0;
80 esp_ble_gattc_cb_param_t *param) = 0;
86 esp_ble_gatts_cb_param_t *param) = 0;
99 this->advertising_cycle_time_ = advertising_cycle_time;
106 void setup()
override;
107 void loop()
override;
110 void set_name(
const std::string &name) { this->name_ = name; }
112#ifdef USE_ESP32_BLE_ADVERTISING
124 this->gap_scan_event_handlers_.push_back(handler);
129 this->ble_status_event_handlers_.push_back(handler);
134 static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
135 static void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param);
136 static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
141#ifdef USE_ESP32_BLE_ADVERTISING
149 std::vector<GAPEventHandler *> gap_event_handlers_;
150 std::vector<GAPScanEventHandler *> gap_scan_event_handlers_;
151 std::vector<GATTcEventHandler *> gattc_event_handlers_;
152 std::vector<GATTsEventHandler *> gatts_event_handlers_;
153 std::vector<BLEStatusEventHandler *> ble_status_event_handlers_;
163#ifdef USE_ESP32_BLE_ADVERTISING
166 esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
167 uint32_t advertising_cycle_time_{};
170 uint16_t appearance_{0};
174 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 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)