mirror of
https://github.com/esphome/esphome.git
synced 2025-09-07 05:42:20 +01:00
Add support for BLE passkey authentication (#4258)
Co-authored-by: Branden Cash <203336+ammmze@users.noreply.github.com>
This commit is contained in:
@@ -134,8 +134,7 @@ bool ESP32BLE::ble_setup_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_ble_io_cap_t iocap = ESP_IO_CAP_NONE;
|
||||
err = esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t));
|
||||
err = esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &(this->io_cap_), sizeof(uint8_t));
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_ble_gap_set_security_param failed: %d", err);
|
||||
return false;
|
||||
@@ -215,9 +214,31 @@ float ESP32BLE::get_setup_priority() const { return setup_priority::BLUETOOTH; }
|
||||
void ESP32BLE::dump_config() {
|
||||
const uint8_t *mac_address = esp_bt_dev_get_address();
|
||||
if (mac_address) {
|
||||
const char *io_capability_s;
|
||||
switch (this->io_cap_) {
|
||||
case ESP_IO_CAP_OUT:
|
||||
io_capability_s = "display_only";
|
||||
break;
|
||||
case ESP_IO_CAP_IO:
|
||||
io_capability_s = "display_yes_no";
|
||||
break;
|
||||
case ESP_IO_CAP_IN:
|
||||
io_capability_s = "keyboard_only";
|
||||
break;
|
||||
case ESP_IO_CAP_NONE:
|
||||
io_capability_s = "none";
|
||||
break;
|
||||
case ESP_IO_CAP_KBDISP:
|
||||
io_capability_s = "keyboard_display";
|
||||
break;
|
||||
default:
|
||||
io_capability_s = "invalid";
|
||||
break;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, "ESP32 BLE:");
|
||||
ESP_LOGCONFIG(TAG, " MAC address: %02X:%02X:%02X:%02X:%02X:%02X", mac_address[0], mac_address[1], mac_address[2],
|
||||
mac_address[3], mac_address[4], mac_address[5]);
|
||||
ESP_LOGCONFIG(TAG, " IO Capability: %s", io_capability_s);
|
||||
} else {
|
||||
ESP_LOGCONFIG(TAG, "ESP32 BLE: bluetooth stack is not enabled");
|
||||
}
|
||||
|
Reference in New Issue
Block a user