mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 00:07:32 +00:00
[esp32_ble] Honour an enable made during the disable callbacks
The before-disabled callbacks can run user automations (on_scan_end fires when the tracker settles the scanner), so an enable issued there was flipped to ACTIVE and then overwritten by the DISABLED write after the teardown. Turn it into a bring-up instead. ble_client also skips advertisements until its app is registered, so the tracker does not stop the scan for a connect that would be rejected.
This commit is contained in:
@@ -586,7 +586,10 @@ void ESP32BLE::loop_handle_state_transition_not_active_() {
|
||||
return;
|
||||
}
|
||||
this->drain_ble_events_();
|
||||
this->state_ = BLE_COMPONENT_STATE_DISABLED;
|
||||
// A status callback may have asked for BLE back; the stack is down now, so
|
||||
// that request becomes a bring-up.
|
||||
this->state_ =
|
||||
this->state_ == BLE_COMPONENT_STATE_ACTIVE ? BLE_COMPONENT_STATE_ENABLE : BLE_COMPONENT_STATE_DISABLED;
|
||||
} else if (this->state_ == BLE_COMPONENT_STATE_ENABLE) {
|
||||
ESP_LOGD(TAG, "Enabling");
|
||||
this->state_ = BLE_COMPONENT_STATE_OFF;
|
||||
|
||||
@@ -108,6 +108,10 @@ bool BLEClientBase::parse_device(const espbt::ESPBTDevice &device) {
|
||||
return false;
|
||||
if (this->state() != espbt::ClientState::IDLE)
|
||||
return false;
|
||||
// Not registered on this stack yet; promoting now would stop the scan for a
|
||||
// connect that connect() rejects anyway.
|
||||
if (this->gattc_if_ == ESP_GATT_IF_NONE)
|
||||
return false;
|
||||
|
||||
this->log_event_("Found device");
|
||||
if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user