mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Fix Bluetooth setup_priorities (#2458)
Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
		| @@ -11,6 +11,8 @@ namespace ble_client { | |||||||
|  |  | ||||||
| static const char *const TAG = "ble_client"; | static const char *const TAG = "ble_client"; | ||||||
|  |  | ||||||
|  | float BLEClient::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; } | ||||||
|  |  | ||||||
| void BLEClient::setup() { | void BLEClient::setup() { | ||||||
|   auto ret = esp_ble_gattc_app_register(this->app_id); |   auto ret = esp_ble_gattc_app_register(this->app_id); | ||||||
|   if (ret) { |   if (ret) { | ||||||
|   | |||||||
| @@ -81,6 +81,7 @@ class BLEClient : public espbt::ESPBTClient, public Component { | |||||||
|   void setup() override; |   void setup() override; | ||||||
|   void dump_config() override; |   void dump_config() override; | ||||||
|   void loop() override; |   void loop() override; | ||||||
|  |   float get_setup_priority() const override; | ||||||
|  |  | ||||||
|   void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, |   void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, | ||||||
|                            esp_ble_gattc_cb_param_t *param) override; |                            esp_ble_gattc_cb_param_t *param) override; | ||||||
|   | |||||||
| @@ -57,7 +57,7 @@ void ESP32BLEBeacon::setup() { | |||||||
|   ); |   ); | ||||||
| } | } | ||||||
|  |  | ||||||
| float ESP32BLEBeacon::get_setup_priority() const { return setup_priority::DATA; } | float ESP32BLEBeacon::get_setup_priority() const { return setup_priority::BLUETOOTH; } | ||||||
| void ESP32BLEBeacon::ble_core_task(void *params) { | void ESP32BLEBeacon::ble_core_task(void *params) { | ||||||
|   ble_setup(); |   ble_setup(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -154,7 +154,7 @@ void BLEServer::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t ga | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| float BLEServer::get_setup_priority() const { return setup_priority::BLUETOOTH - 10; } | float BLEServer::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; } | ||||||
|  |  | ||||||
| void BLEServer::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 BLE Server:"); } | void BLEServer::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 BLE Server:"); } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -40,6 +40,8 @@ uint64_t ble_addr_to_uint64(const esp_bd_addr_t address) { | |||||||
|   return u; |   return u; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | float ESP32BLETracker::get_setup_priority() const { return setup_priority::BLUETOOTH; } | ||||||
|  |  | ||||||
| void ESP32BLETracker::setup() { | void ESP32BLETracker::setup() { | ||||||
|   global_esp32_ble_tracker = this; |   global_esp32_ble_tracker = this; | ||||||
|   this->scan_result_lock_ = xSemaphoreCreateMutex(); |   this->scan_result_lock_ = xSemaphoreCreateMutex(); | ||||||
|   | |||||||
| @@ -171,6 +171,7 @@ class ESP32BLETracker : public Component { | |||||||
|   /// Setup the FreeRTOS task and the Bluetooth stack. |   /// Setup the FreeRTOS task and the Bluetooth stack. | ||||||
|   void setup() override; |   void setup() override; | ||||||
|   void dump_config() override; |   void dump_config() override; | ||||||
|  |   float get_setup_priority() const override; | ||||||
|  |  | ||||||
|   void loop() override; |   void loop() override; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user