Diff between bc34ec0e7d3387ba96db2b34a98473369db68520 and 2c4724736723b2e1cd3d30b3a0557217010e2da3

Changed Files

File Additions Deletions Status
emulator/btdev.c +12 -4 modified

Full Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 675a638..b50df0f 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;