default to just-works encryption

This patch will turn on encryption when making active connections in order to comply with just-works BLE encryption.
This commit is contained in:
Fredrik Gustafsson 2023-02-21 18:57:07 +01:00 committed by GitHub
parent 8fb481751f
commit 05bc9e9f1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,6 +158,11 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
this->mtu_ = param->cfg_mtu.mtu; this->mtu_ = param->cfg_mtu.mtu;
break; 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: { case ESP_GATTC_DISCONNECT_EVT: {
if (memcmp(param->disconnect.remote_bda, this->remote_bda_, 6) != 0) if (memcmp(param->disconnect.remote_bda, this->remote_bda_, 6) != 0)
return false; return false;