From 05bc9e9f1cca9c41cbc7434379cbd5eb6dbb1034 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Tue, 21 Feb 2023 18:57:07 +0100 Subject: [PATCH] default to just-works encryption This patch will turn on encryption when making active connections in order to comply with just-works BLE encryption. --- esphome/components/esp32_ble_client/ble_client_base.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/esp32_ble_client/ble_client_base.cpp b/esphome/components/esp32_ble_client/ble_client_base.cpp index 2793a74c5a..39bffc212d 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.cpp +++ b/esphome/components/esp32_ble_client/ble_client_base.cpp @@ -158,6 +158,11 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ this->mtu_ = param->cfg_mtu.mtu; break; } + case ESP_GATTC_CONNECT_EVT: { + ESP_LOGV(TAG, "[%d] [%s] ESP_GATTC_CONNECT_EVT", this->connection_index_, this->address_str_.c_str()); + esp_ble_set_encryption(param->connect.remote_bda, ESP_BLE_SEC_ENCRYPT); + break; + } case ESP_GATTC_DISCONNECT_EVT: { if (memcmp(param->disconnect.remote_bda, this->remote_bda_, 6) != 0) return false;