mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	dry
This commit is contained in:
		| @@ -430,14 +430,7 @@ void ESP32BLETracker::gap_scan_event_handler(const BLEScanResult &scan_result) { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     // Scan completed naturally, perform cleanup and transition to IDLE |     // Scan completed naturally, perform cleanup and transition to IDLE | ||||||
|     ESP_LOGD(TAG, "Scan completed, set scanner state to IDLE."); |     this->cleanup_scan_state_(false); | ||||||
|     this->already_discovered_.clear(); |  | ||||||
|     this->cancel_timeout("scan"); |  | ||||||
|  |  | ||||||
|     for (auto *listener : this->listeners_) |  | ||||||
|       listener->on_scan_end(); |  | ||||||
|  |  | ||||||
|     this->set_scanner_state_(ScannerState::IDLE); |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -494,14 +487,7 @@ void ESP32BLETracker::gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_ | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Perform cleanup and transition to IDLE |   // Perform cleanup and transition to IDLE | ||||||
|   ESP_LOGD(TAG, "Scan stop complete, set scanner state to IDLE."); |   this->cleanup_scan_state_(true); | ||||||
|   this->already_discovered_.clear(); |  | ||||||
|   this->cancel_timeout("scan"); |  | ||||||
|  |  | ||||||
|   for (auto *listener : this->listeners_) |  | ||||||
|     listener->on_scan_end(); |  | ||||||
|  |  | ||||||
|   this->set_scanner_state_(ScannerState::IDLE); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void ESP32BLETracker::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, | void ESP32BLETracker::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, | ||||||
| @@ -875,6 +861,17 @@ bool ESPBTDevice::resolve_irk(const uint8_t *irk) const { | |||||||
| } | } | ||||||
| #endif  // USE_ESP32_BLE_DEVICE | #endif  // USE_ESP32_BLE_DEVICE | ||||||
|  |  | ||||||
|  | void ESP32BLETracker::cleanup_scan_state_(bool is_stop_complete) { | ||||||
|  |   ESP_LOGD(TAG, "Scan %scomplete, set scanner state to IDLE.", is_stop_complete ? "stop " : ""); | ||||||
|  |   this->already_discovered_.clear(); | ||||||
|  |   this->cancel_timeout("scan"); | ||||||
|  |  | ||||||
|  |   for (auto *listener : this->listeners_) | ||||||
|  |     listener->on_scan_end(); | ||||||
|  |  | ||||||
|  |   this->set_scanner_state_(ScannerState::IDLE); | ||||||
|  | } | ||||||
|  |  | ||||||
| }  // namespace esphome::esp32_ble_tracker | }  // namespace esphome::esp32_ble_tracker | ||||||
|  |  | ||||||
| #endif  // USE_ESP32 | #endif  // USE_ESP32 | ||||||
|   | |||||||
| @@ -270,6 +270,8 @@ class ESP32BLETracker : public Component, | |||||||
|   void gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param ¶m); |   void gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param ¶m); | ||||||
|   /// Called to set the scanner state. Will also call callbacks to let listeners know when state is changed. |   /// Called to set the scanner state. Will also call callbacks to let listeners know when state is changed. | ||||||
|   void set_scanner_state_(ScannerState state); |   void set_scanner_state_(ScannerState state); | ||||||
|  |   /// Common cleanup logic when transitioning scanner to IDLE state | ||||||
|  |   void cleanup_scan_state_(bool is_stop_complete); | ||||||
|  |  | ||||||
|   uint8_t app_id_{0}; |   uint8_t app_id_{0}; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user