ESPHome 2026.8.0b4
Loading...
Searching...
No Matches
esphome::bk72xx_ble_tracker::BK72xxBLETracker Class Reference

#include <bk72xx_ble_tracker.h>

Inheritance diagram for esphome::bk72xx_ble_tracker::BK72xxBLETracker:
esphome::Component esphome::bk72xx_ble::BLEScanListener esphome::Parented< bk72xx_ble::BK72xxBLE > esphome::ota::OTAGlobalStateListener

Public Member Functions

void setup () override
 
void loop () override
 
void dump_config () override
 
float get_setup_priority () const override
 
void on_ota_global_state (ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) override
 
void set_scan_interval (uint32_t scan_interval)
 
void set_scan_window (uint32_t scan_window)
 
void set_scan_duration (uint32_t scan_duration)
 
void set_scan_active (bool scan_active)
 Set from YAML (scan_parameters.active); runtime mode requests change only the resolved mode.
 
void set_configured_continuous (bool scan_continuous)
 Set from YAML (scan_parameters.continuous); also the value configured_continuous() reports and a bare start_scan action restores.
 
void set_scan_continuous (bool scan_continuous)
 Runtime control (esp32_ble_tracker lambda parity): does not change the configured value, so configured_continuous() still reports what YAML asked for.
 
bool scan_continuous () const
 
bool configured_continuous () const
 
void restart_scan_duration ()
 Re-anchor the one-shot duration clock of a running scan to now — used when an action changes the scan mode without stopping the radio.
 
void start_scan ()
 
void stop_scan ()
 
void register_listener (ble_device_base::ESPBTDeviceListener *listener)
 
void set_raw_advertisement_callback (ble_device_base::RawAdvertisementCallback callback)
 
bool request_scan_mode (bool active)
 
void get_adapter_mac (uint8_t out[MAC_ADDRESS_SIZE])
 
bool scan_running ()
 
bool scan_active ()
 
void on_scan_report (const bk72xx_ble::BLEScanReport &report) override
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual bool teardown ()
 Called during teardown to allow component to gracefully finish operations.
 
virtual void on_powerdown ()
 Called after teardown is complete to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
bool is_idle () const
 Check if this component is idle.
 
void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const LogString *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning ()
 
void status_set_warning (const char *message)
 
void status_set_warning (const LogString *message)
 
void status_set_error ()
 
void status_set_error (const LogString *message)
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const char *name, uint32_t length=5000)
 Set warning status flag and automatically clear it after a timeout.
 
void status_momentary_error (const char *name, uint32_t length=5000)
 Set error status flag and automatically clear it after a timeout.
 
bool has_overridden_loop () const
 
const LogString * get_component_log_str () const ESPHOME_ALWAYS_INLINE
 Get the integration where this component was declared as a LogString for logging.
 
bool should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out)
 
- Public Member Functions inherited from esphome::bk72xx_ble::BLEScanListener
- Public Member Functions inherited from esphome::Parented< bk72xx_ble::BK72xxBLE >
 Parented ()
 
 Parented (bk72xx_ble::BK72xxBLE *parent)
 
bk72xx_ble::BK72xxBLEget_parent () const
 Get the parent of this object.
 
void set_parent (bk72xx_ble::BK72xxBLE *parent)
 Set the parent of this object.
 
- Public Member Functions inherited from esphome::ota::OTAGlobalStateListener
virtual ~OTAGlobalStateListener ()=default
 

Static Public Member Functions

static constexpr ble_device_base::HubCapabilities get_capabilities ()
 

Protected Member Functions

void start_scan_ ()
 
void stop_scan_ ()
 
void fire_scan_end_ ()
 
void mark_scan_ended_ (uint32_t now)
 
bk72xx_ble::ScanOpResult controller_scan_start_ ()
 Stamp-and-start for every controller scan attempt, so the retry rate limit covers all callers.
 
bool try_start_with_backoff_ (uint32_t now, bool force=false)
 Rate-limited (re)start; true when the scan is running (the caller must not reuse a now older than the stamps this refreshed).
 
void count_failed_start_ ()
 
- Protected Member Functions inherited from esphome::Component
friend void::setup ()
 
friend void::original_setup ()
 
void set_component_source_ (uint8_t index)
 Set where this component was loaded from for some debug messages.
 
virtual void call_setup ()
 
void call_dump_config_ ()
 
void enable_loop_slow_path_ ()
 
void set_component_state_ (uint8_t state)
 Helper to set component state (clears state bits and sets new state)
 
bool set_status_flag_ (uint8_t flag)
 Helper to set a status LED flag on both this component and the app.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a numeric ID (zero heap allocation).
 
void set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f)
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const char *name)
 Cancel an interval function.
 
bool cancel_interval (uint32_t id)
 
bool cancel_interval (InternalSchedulerID id)
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a numeric ID (zero heap allocation).
 
void set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const char *name)
 Cancel a timeout function.
 
bool cancel_timeout (uint32_t id)
 
bool cancel_timeout (InternalSchedulerID id)
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (uint32_t id, std::function< void()> &&f)
 Defer a callback with a numeric ID (zero heap allocation)
 
bool cancel_defer (const char *name)
 Cancel a defer callback using the specified name, name must not be empty.
 
bool cancel_defer (uint32_t id)
 
void status_clear_warning_slow_path_ ()
 
void status_clear_error_slow_path_ ()
 
- Protected Member Functions inherited from esphome::bk72xx_ble::BLEScanListener
 ~BLEScanListener ()=default
 

Protected Attributes

bool scan_running_ {false}
 
bool scan_requested_ {false}
 
bool start_attempt_open_ {false}
 
uint32_t scan_interval_ {160}
 
uint32_t scan_window_ {48}
 
uint32_t scan_duration_ {300000}
 
bool scan_continuous_ {true}
 
bool scan_continuous_configured_ {true}
 
bool scan_active_ {true}
 
bool scan_active_configured_ {true}
 
bool scan_continuous_before_ota_ {false}
 
bool scan_requested_before_ota_ {false}
 
uint32_t scan_start_time_ {0}
 
uint32_t last_scan_start_attempt_ {0}
 
uint8_t failed_start_count_ {0}
 
uint32_t scan_period_start_ {0}
 
bool scan_started_once_ {false}
 
ble_device_base::ScanResponseMerger merger_
 
ble_device_base::AdvDispatcher dispatcher_
 
- Protected Attributes inherited from esphome::Component
uint8_t component_source_index_ {0}
 Index into component source PROGMEM lookup table (0 = not set)
 
uint8_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_CS}
 Warn threshold in centiseconds (max 2550ms)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bit 5: Has overridden loop() (set at registration time) Bits 6-7: Unused - reserved for future expansion.
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
ComponentRuntimeStats runtime_stats_
 
- Protected Attributes inherited from esphome::Parented< bk72xx_ble::BK72xxBLE >
bk72xx_ble::BK72xxBLEparent_
 

Detailed Description

Definition at line 49 of file bk72xx_ble_tracker.h.

Member Function Documentation

◆ configured_continuous()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::configured_continuous ( ) const
inline

Definition at line 91 of file bk72xx_ble_tracker.h.

◆ controller_scan_start_()

bk72xx_ble::ScanOpResult esphome::bk72xx_ble_tracker::BK72xxBLETracker::controller_scan_start_ ( )
protected

Stamp-and-start for every controller scan attempt, so the retry rate limit covers all callers.

Definition at line 297 of file bk72xx_ble_tracker.cpp.

◆ count_failed_start_()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::count_failed_start_ ( )
protected

Definition at line 190 of file bk72xx_ble_tracker.cpp.

◆ dump_config()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 200 of file bk72xx_ble_tracker.cpp.

◆ fire_scan_end_()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::fire_scan_end_ ( )
protected

Definition at line 354 of file bk72xx_ble_tracker.cpp.

◆ get_adapter_mac()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::get_adapter_mac ( uint8_t out[MAC_ADDRESS_SIZE])
inline

Definition at line 119 of file bk72xx_ble_tracker.h.

◆ get_capabilities()

static constexpr ble_device_base::HubCapabilities esphome::bk72xx_ble_tracker::BK72xxBLETracker::get_capabilities ( )
inlinestaticconstexpr

Definition at line 109 of file bk72xx_ble_tracker.h.

◆ get_setup_priority()

float esphome::bk72xx_ble_tracker::BK72xxBLETracker::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 62 of file bk72xx_ble_tracker.h.

◆ loop()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 93 of file bk72xx_ble_tracker.cpp.

◆ mark_scan_ended_()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::mark_scan_ended_ ( uint32_t now)
protected

Definition at line 348 of file bk72xx_ble_tracker.cpp.

◆ on_ota_global_state()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::on_ota_global_state ( ota::OTAState state,
float progress,
uint8_t error,
ota::OTAComponent * comp )
overridevirtual

Implements esphome::ota::OTAGlobalStateListener.

Definition at line 64 of file bk72xx_ble_tracker.cpp.

◆ on_scan_report()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::on_scan_report ( const bk72xx_ble::BLEScanReport & report)
overridevirtual

Implements esphome::bk72xx_ble::BLEScanListener.

Definition at line 230 of file bk72xx_ble_tracker.cpp.

◆ register_listener()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::register_listener ( ble_device_base::ESPBTDeviceListener * listener)
inline

Definition at line 103 of file bk72xx_ble_tracker.h.

◆ request_scan_mode()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::request_scan_mode ( bool active)

Definition at line 363 of file bk72xx_ble_tracker.cpp.

◆ restart_scan_duration()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::restart_scan_duration ( )

Re-anchor the one-shot duration clock of a running scan to now — used when an action changes the scan mode without stopping the radio.

The continuous-mode on_scan_end period is deliberately not touched.

Definition at line 276 of file bk72xx_ble_tracker.cpp.

◆ scan_active()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_active ( )
inline

Definition at line 126 of file bk72xx_ble_tracker.h.

◆ scan_continuous()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_continuous ( ) const
inline

Definition at line 90 of file bk72xx_ble_tracker.h.

◆ scan_running()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_running ( )
inline

Definition at line 125 of file bk72xx_ble_tracker.h.

◆ set_configured_continuous()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_configured_continuous ( bool scan_continuous)
inline

Set from YAML (scan_parameters.continuous); also the value configured_continuous() reports and a bare start_scan action restores.

Definition at line 82 of file bk72xx_ble_tracker.h.

◆ set_raw_advertisement_callback()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_raw_advertisement_callback ( ble_device_base::RawAdvertisementCallback callback)
inline

Definition at line 106 of file bk72xx_ble_tracker.h.

◆ set_scan_active()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_scan_active ( bool scan_active)
inline

Set from YAML (scan_parameters.active); runtime mode requests change only the resolved mode.

Definition at line 76 of file bk72xx_ble_tracker.h.

◆ set_scan_continuous()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_scan_continuous ( bool scan_continuous)
inline

Runtime control (esp32_ble_tracker lambda parity): does not change the configured value, so configured_continuous() still reports what YAML asked for.

Definition at line 89 of file bk72xx_ble_tracker.h.

◆ set_scan_duration()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_scan_duration ( uint32_t scan_duration)
inline

Definition at line 73 of file bk72xx_ble_tracker.h.

◆ set_scan_interval()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_scan_interval ( uint32_t scan_interval)
inline

Definition at line 71 of file bk72xx_ble_tracker.h.

◆ set_scan_window()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::set_scan_window ( uint32_t scan_window)
inline

Definition at line 72 of file bk72xx_ble_tracker.h.

◆ setup()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 43 of file bk72xx_ble_tracker.cpp.

◆ start_scan()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::start_scan ( )

Definition at line 252 of file bk72xx_ble_tracker.cpp.

◆ start_scan_()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::start_scan_ ( )
protected

Definition at line 303 of file bk72xx_ble_tracker.cpp.

◆ stop_scan()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::stop_scan ( )

Definition at line 287 of file bk72xx_ble_tracker.cpp.

◆ stop_scan_()

void esphome::bk72xx_ble_tracker::BK72xxBLETracker::stop_scan_ ( )
protected

Definition at line 334 of file bk72xx_ble_tracker.cpp.

◆ try_start_with_backoff_()

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::try_start_with_backoff_ ( uint32_t now,
bool force = false )
protected

Rate-limited (re)start; true when the scan is running (the caller must not reuse a now older than the stamps this refreshed).

Force and backoff rules are documented at the definition.

Definition at line 151 of file bk72xx_ble_tracker.cpp.

Field Documentation

◆ dispatcher_

ble_device_base::AdvDispatcher esphome::bk72xx_ble_tracker::BK72xxBLETracker::dispatcher_
protected

Definition at line 177 of file bk72xx_ble_tracker.h.

◆ failed_start_count_

uint8_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::failed_start_count_ {0}
protected

Definition at line 166 of file bk72xx_ble_tracker.h.

◆ last_scan_start_attempt_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::last_scan_start_attempt_ {0}
protected

Definition at line 165 of file bk72xx_ble_tracker.h.

◆ merger_

ble_device_base::ScanResponseMerger esphome::bk72xx_ble_tracker::BK72xxBLETracker::merger_
protected

Definition at line 176 of file bk72xx_ble_tracker.h.

◆ scan_active_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_active_ {true}
protected

Definition at line 157 of file bk72xx_ble_tracker.h.

◆ scan_active_configured_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_active_configured_ {true}
protected

Definition at line 158 of file bk72xx_ble_tracker.h.

◆ scan_continuous_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_continuous_ {true}
protected

Definition at line 155 of file bk72xx_ble_tracker.h.

◆ scan_continuous_before_ota_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_continuous_before_ota_ {false}
protected

Definition at line 160 of file bk72xx_ble_tracker.h.

◆ scan_continuous_configured_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_continuous_configured_ {true}
protected

Definition at line 156 of file bk72xx_ble_tracker.h.

◆ scan_duration_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_duration_ {300000}
protected

Definition at line 154 of file bk72xx_ble_tracker.h.

◆ scan_interval_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_interval_ {160}
protected

Definition at line 152 of file bk72xx_ble_tracker.h.

◆ scan_period_start_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_period_start_ {0}
protected

Definition at line 167 of file bk72xx_ble_tracker.h.

◆ scan_requested_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_requested_ {false}
protected

Definition at line 148 of file bk72xx_ble_tracker.h.

◆ scan_requested_before_ota_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_requested_before_ota_ {false}
protected

Definition at line 161 of file bk72xx_ble_tracker.h.

◆ scan_running_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_running_ {false}
protected

Definition at line 147 of file bk72xx_ble_tracker.h.

◆ scan_start_time_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_start_time_ {0}
protected

Definition at line 163 of file bk72xx_ble_tracker.h.

◆ scan_started_once_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_started_once_ {false}
protected

Definition at line 168 of file bk72xx_ble_tracker.h.

◆ scan_window_

uint32_t esphome::bk72xx_ble_tracker::BK72xxBLETracker::scan_window_ {48}
protected

Definition at line 153 of file bk72xx_ble_tracker.h.

◆ start_attempt_open_

bool esphome::bk72xx_ble_tracker::BK72xxBLETracker::start_attempt_open_ {false}
protected

Definition at line 149 of file bk72xx_ble_tracker.h.


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