mirror of
https://github.com/esphome/esphome.git
synced 2024-12-28 17:37:44 +01:00
Combine the scanner failure check so we only stop the scanner once (#4111)
This commit is contained in:
parent
873de13b3d
commit
ad0d6f6337
@ -144,28 +144,31 @@ void ESP32BLETracker::loop() {
|
|||||||
xSemaphoreGive(this->scan_result_lock_);
|
xSemaphoreGive(this->scan_result_lock_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->scan_set_param_failed_) {
|
|
||||||
ESP_LOGE(TAG, "Scan set param failed: %d", this->scan_set_param_failed_);
|
|
||||||
esp_ble_gap_stop_scanning();
|
|
||||||
this->scan_set_param_failed_ = ESP_BT_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->scan_start_failed_) {
|
|
||||||
ESP_LOGE(TAG, "Scan start failed: %d", this->scan_start_failed_);
|
|
||||||
esp_ble_gap_stop_scanning();
|
|
||||||
this->scan_start_failed_ = ESP_BT_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!connecting && xSemaphoreTake(this->scan_end_lock_, 0L)) {
|
if (!connecting && xSemaphoreTake(this->scan_end_lock_, 0L)) {
|
||||||
if (this->scan_continuous_) {
|
if (this->scan_continuous_) {
|
||||||
if (!promote_to_connecting) {
|
if (!promote_to_connecting && !this->scan_start_failed_ && !this->scan_set_param_failed_) {
|
||||||
this->start_scan_(false);
|
this->start_scan_(false);
|
||||||
|
} else {
|
||||||
|
// We didn't start the scan, so we need to release the lock
|
||||||
|
xSemaphoreGive(this->scan_end_lock_);
|
||||||
}
|
}
|
||||||
} else if (!this->scanner_idle_) {
|
} else if (!this->scanner_idle_) {
|
||||||
this->end_of_scan_();
|
this->end_of_scan_();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->scan_start_failed_ || this->scan_set_param_failed_) {
|
||||||
|
esp_ble_gap_stop_scanning();
|
||||||
|
if (this->scan_start_failed_) {
|
||||||
|
ESP_LOGE(TAG, "Scan start failed: %d", this->scan_start_failed_);
|
||||||
|
this->scan_start_failed_ = ESP_BT_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
if (this->scan_set_param_failed_) {
|
||||||
|
ESP_LOGE(TAG, "Scan set param failed: %d", this->scan_set_param_failed_);
|
||||||
|
this->scan_set_param_failed_ = ESP_BT_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a discovered client and no connecting
|
// If there is a discovered client and no connecting
|
||||||
|
Loading…
Reference in New Issue
Block a user