diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-04-08 01:18:30 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-04-08 01:18:30 -0700 |
commit | f9796b5c3538217ff093126aa0fdf1a2160a9d6d (patch) | |
tree | 1d1c710dbd2e54677d91cc8a2adf48e62113bf50 /emulator/btdev.c | |
parent | 3b7ad511ea4a18360b7ea30f74008f83b5e625c5 (diff) | |
download | bluez-f9796b5c3538217ff093126aa0fdf1a2160a9d6d.tar.gz |
emulator: Add support for LE remote features command
Diffstat (limited to 'emulator/btdev.c')
-rw-r--r-- | emulator/btdev.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c index 9642e8668..ad65cf899 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -533,6 +533,8 @@ static void set_le_features(struct btdev *btdev) btdev->features[4] |= 0x40; /* LE Supported */ btdev->max_page = 1; + + btdev->le_features[0] |= 0x01; /* LE Encryption */ } static void set_amp_features(struct btdev *btdev) @@ -1764,6 +1766,30 @@ static void le_set_scan_enable_complete(struct btdev *btdev) } } +static void le_read_remote_features_complete(struct btdev *btdev) +{ + char buf[1 + sizeof(struct bt_hci_evt_le_remote_features_complete)]; + struct bt_hci_evt_le_remote_features_complete *ev = (void *) &buf[1]; + struct btdev *remote = btdev->conn; + + if (!remote) { + cmd_status(btdev, BT_HCI_ERR_UNKNOWN_CONN_ID, + BT_HCI_CMD_LE_READ_REMOTE_FEATURES); + return; + } + + cmd_status(btdev, BT_HCI_ERR_SUCCESS, + BT_HCI_CMD_LE_READ_REMOTE_FEATURES); + + memset(buf, 0, sizeof(buf)); + buf[0] = BT_HCI_EVT_LE_REMOTE_FEATURES_COMPLETE; + ev->status = BT_HCI_ERR_SUCCESS; + ev->handle = cpu_to_le16(42); + memcpy(ev->features, remote->le_features, 8); + + send_event(btdev, BT_HCI_EVT_LE_META_EVENT, buf, sizeof(buf)); +} + static void le_start_encrypt_complete(struct btdev *btdev) { char buf[1 + sizeof(struct bt_hci_evt_le_long_term_key_request)]; @@ -2870,6 +2896,12 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode, cmd_complete(btdev, opcode, &lr, sizeof(lr)); break; + case BT_HCI_CMD_LE_READ_REMOTE_FEATURES: + if (btdev->type == BTDEV_TYPE_BREDR) + goto unsupported; + le_read_remote_features_complete(btdev); + break; + case BT_HCI_CMD_LE_START_ENCRYPT: if (btdev->type == BTDEV_TYPE_BREDR) goto unsupported; |