mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 23:21:54 +00:00 
			
		
		
		
	[esp32_ble_client] Fix V3_WITH_CACHE connections unnecessarily populating services vector
preen
This commit is contained in:
		| @@ -377,7 +377,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ | |||||||
|       this->service_count_++; |       this->service_count_++; | ||||||
|       if (this->connection_type_ == espbt::ConnectionType::V3_WITHOUT_CACHE) { |       if (this->connection_type_ == espbt::ConnectionType::V3_WITHOUT_CACHE) { | ||||||
|         // V3 clients don't need services initialized since |         // V3 clients don't need services initialized since | ||||||
|         // they only request by handle after receiving the services. |         // as they use the ESP APIs to get services. | ||||||
|         break; |         break; | ||||||
|       } |       } | ||||||
|       BLEService *ble_service = new BLEService();  // NOLINT(cppcoreguidelines-owning-memory) |       BLEService *ble_service = new BLEService();  // NOLINT(cppcoreguidelines-owning-memory) | ||||||
| @@ -392,21 +392,20 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ | |||||||
|       if (this->conn_id_ != param->search_cmpl.conn_id) |       if (this->conn_id_ != param->search_cmpl.conn_id) | ||||||
|         return false; |         return false; | ||||||
|       this->log_gattc_event_("SEARCH_CMPL"); |       this->log_gattc_event_("SEARCH_CMPL"); | ||||||
|  |       // For V3 connections, restore to medium connection parameters after service discovery | ||||||
|  |       // This balances performance with bandwidth usage after the critical discovery phase | ||||||
|  |       if (this->connection_type_ == espbt::ConnectionType::V3_WITHOUT_CACHE || | ||||||
|  |           this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) { | ||||||
|  |         this->restore_medium_conn_params_(); | ||||||
|  |       } else { | ||||||
|         for (auto &svc : this->services_) { |         for (auto &svc : this->services_) { | ||||||
|           ESP_LOGV(TAG, "[%d] [%s] Service UUID: %s", this->connection_index_, this->address_str_.c_str(), |           ESP_LOGV(TAG, "[%d] [%s] Service UUID: %s", this->connection_index_, this->address_str_.c_str(), | ||||||
|                    svc->uuid.to_string().c_str()); |                    svc->uuid.to_string().c_str()); | ||||||
|           ESP_LOGV(TAG, "[%d] [%s]  start_handle: 0x%x  end_handle: 0x%x", this->connection_index_, |           ESP_LOGV(TAG, "[%d] [%s]  start_handle: 0x%x  end_handle: 0x%x", this->connection_index_, | ||||||
|                    this->address_str_.c_str(), svc->start_handle, svc->end_handle); |                    this->address_str_.c_str(), svc->start_handle, svc->end_handle); | ||||||
|         } |         } | ||||||
|       ESP_LOGI(TAG, "[%d] [%s] Service discovery complete", this->connection_index_, this->address_str_.c_str()); |  | ||||||
|  |  | ||||||
|       // For V3 connections, restore to medium connection parameters after service discovery |  | ||||||
|       // This balances performance with bandwidth usage after the critical discovery phase |  | ||||||
|       if (this->connection_type_ == espbt::ConnectionType::V3_WITHOUT_CACHE || |  | ||||||
|           this->connection_type_ == espbt::ConnectionType::V3_WITH_CACHE) { |  | ||||||
|         this->restore_medium_conn_params_(); |  | ||||||
|       } |       } | ||||||
|  |       ESP_LOGI(TAG, "[%d] [%s] Service discovery complete", this->connection_index_, this->address_str_.c_str()); | ||||||
|       this->state_ = espbt::ClientState::ESTABLISHED; |       this->state_ = espbt::ClientState::ESTABLISHED; | ||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user