From 2c4724736723b2e1cd3d30b3a0557217010e2da3 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 8 Dec 2014 16:26:52 +0200 Subject: [PATCH] emulator: Fix encryption mode for BR/EDR SC --- emulator/btdev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 675a638ed..b50df0f62 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -3026,10 +3026,18 @@ static void default_cmd_completion(struct btdev *btdev, uint16_t opcode, return; sce = data; if (btdev->conn) { - encrypt_change(btdev, sce->encr_mode, - BT_HCI_ERR_SUCCESS); - encrypt_change(btdev->conn, sce->encr_mode, - BT_HCI_ERR_SUCCESS); + uint8_t mode; + + if (!sce->encr_mode) + mode = 0x00; + else if (btdev->secure_conn_support && + btdev->conn->secure_conn_support) + mode = 0x02; + else + mode = 0x01; + + encrypt_change(btdev, mode, BT_HCI_ERR_SUCCESS); + encrypt_change(btdev->conn, mode, BT_HCI_ERR_SUCCESS); } break; -- 2.47.3