From f61edaad86cdaddbce3ed24b746aa86b8ef1a20b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 29 Nov 2013 14:07:06 +0200 Subject: [PATCH] emulator/bthost: Add API for requesting LE encryption --- emulator/bthost.c | 14 ++++++++++++++ emulator/bthost.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/emulator/bthost.c b/emulator/bthost.c index 0c5836f67..03d5d7599 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -1159,6 +1159,20 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable) send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1); } +void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle, + const uint8_t ltk[16]) +{ + struct bt_hci_cmd_le_start_encrypt cmd; + + printf("bthost_le_start_encrypt(handle %u)\n", handle); + + memset(&cmd, 0, sizeof(cmd)); + cmd.handle = htobs(handle); + memcpy(cmd.ltk, ltk, 16); + + send_command(bthost, BT_HCI_CMD_LE_START_ENCRYPT, &cmd, sizeof(cmd)); +} + void bthost_set_server_psm(struct bthost *bthost, uint16_t psm) { bthost->server_psm = psm; diff --git a/emulator/bthost.h b/emulator/bthost.h index 32b10f9cb..474ada919 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -72,6 +72,9 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan); void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable); +void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle, + const uint8_t ltk[16]); + void bthost_set_server_psm(struct bthost *bthost, uint16_t psm); void bthost_start(struct bthost *bthost); -- 2.47.3