14#include <esp_bt_defs.h>
15#include <esp_gap_ble_api.h>
16#include <esp_gattc_api.h>
18#include <freertos/FreeRTOS.h>
19#include <freertos/semphr.h>
25namespace esp32_ble_tracker {
27using namespace esp32_ble;
65 void parse_scan_rst(
const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m);
101 void parse_adv_(
const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m);
118class ESP32BLETracker;
124 virtual bool parse_devices(esp_ble_gap_cb_param_t::ble_scan_result_evt_param *advertisements,
size_t count) {
187 esp_ble_gattc_cb_param_t *param) = 0;
188 virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0;
225 void setup()
override;
229 void loop()
override;
241 esp_ble_gattc_cb_param_t *param)
override;
242 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
override;
257 void gap_scan_result_(
const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m);
302#ifdef USE_ESP32_BLE_SOFTWARE_COEXISTENCE
Helper class to easily give an object a parent of type T.
static ESPBTUUID from_raw_reversed(const uint8_t *data)
std::vector< uint64_t > already_discovered_
Vector of addresses that have already been printed in print_bt_device_info.
void set_scan_active(bool scan_active)
bool get_scan_active() const
uint8_t scan_start_fail_count_
void gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param ¶m)
Called when a ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT event is received.
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
static const u_int8_t SCAN_RESULT_BUFFER_SIZE
float get_setup_priority() const override
void register_client(ESPBTClient *client)
bool parse_advertisements_
void dump_config() override
void recalculate_advertisement_parser_types()
esp_ble_gap_cb_param_t::ble_scan_result_evt_param * scan_result_buffer_
ScannerState get_scanner_state() const
ScannerState scanner_state_
esp_ble_scan_params_t scan_params_
A structure holding the ESP BLE scan parameters.
void register_listener(ESPBTDeviceListener *listener)
void end_of_scan_()
Called when a scan ends.
CallbackManager< void(ScannerState)> scanner_state_callbacks_
void gap_scan_set_param_complete_(const esp_ble_gap_cb_param_t::ble_scan_param_cmpl_evt_param ¶m)
Called when a ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT event is received.
uint32_t scan_duration_
The interval in seconds to perform scans.
void setup() override
Setup the FreeRTOS task and the Bluetooth stack.
esp_bt_status_t scan_start_failed_
esp_bt_status_t scan_set_param_failed_
void ble_before_disabled_event_handler() override
size_t scan_result_index_
void set_scanner_state_(ScannerState state)
Called to set the scanner state. Will also call callbacks to let listeners know when state is changed...
void set_scan_continuous(bool scan_continuous)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
void print_bt_device_info(const ESPBTDevice &device)
void set_scan_duration(uint32_t scan_duration)
void set_scan_interval(uint32_t scan_interval)
void gap_scan_start_complete_(const esp_ble_gap_cb_param_t::ble_scan_start_cmpl_evt_param ¶m)
Called when a ESP_GAP_BLE_SCAN_START_COMPLETE_EVT event is received.
SemaphoreHandle_t scan_result_lock_
std::vector< ESPBTClient * > clients_
Client parameters.
void gap_scan_result_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m)
Called when a ESP_GAP_BLE_SCAN_RESULT_EVT event is received.
void set_scan_window(uint32_t scan_window)
void add_scanner_state_callback(std::function< void(ScannerState)> &&callback)
std::vector< ESPBTDeviceListener * > listeners_
void start_scan_(bool first)
Start a single scan by setting up the parameters and doing some esp-idf calls.
struct esphome::esp32_ble_tracker::ESPBLEiBeacon::@78 beacon_data_
uint8_t proximity_uuid[16]
int8_t get_signal_power()
static optional< ESPBLEiBeacon > from_manufacturer_data(const ServiceData &data)
void cancel_pending_disconnect()
ClientState state() const
virtual void disconnect()=0
virtual void set_state(ClientState st)
bool disconnect_pending() const
virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)=0
virtual bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param)=0
uint64_t address_uint64() const
esp_ble_addr_type_t get_address_type() const
void parse_scan_rst(const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m)
esp_ble_addr_type_t address_type_
const uint8_t * address() const
const esp_ble_gap_cb_param_t::ble_scan_result_evt_param & get_scan_result() const
optional< uint16_t > appearance_
optional< uint8_t > ad_flag_
std::vector< ServiceData > manufacturer_datas_
const optional< uint8_t > & get_ad_flag() const
std::vector< ESPBTUUID > service_uuids_
const std::vector< int8_t > & get_tx_powers() const
const std::vector< ServiceData > & get_service_datas() const
const std::string & get_name() const
const optional< uint16_t > & get_appearance() const
esp_ble_gap_cb_param_t::ble_scan_result_evt_param scan_result_
std::string address_str() const
const std::vector< ServiceData > & get_manufacturer_datas() const
bool resolve_irk(const uint8_t *irk) const
void parse_adv_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m)
const std::vector< ESPBTUUID > & get_service_uuids() const
std::vector< int8_t > tx_powers_
std::vector< ServiceData > service_datas_
optional< ESPBLEiBeacon > get_ibeacon() const
virtual void on_scan_end()
virtual AdvertisementParserType get_advertisement_parser_type()
virtual bool parse_devices(esp_ble_gap_cb_param_t::ble_scan_result_evt_param *advertisements, size_t count)
void set_parent(ESP32BLETracker *parent)
virtual bool parse_device(const ESPBTDevice &device)=0
ESP32BLETracker * parent_
ESP32BLETracker * global_esp32_ble_tracker
std::vector< uint8_t > adv_data_t
Providing packet encoding functions for exchanging data with a remote host.