diff options
author | Kiran K <kiran.k@intel.com> | 2021-08-17 14:19:41 +0530 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-08-17 16:49:39 -0700 |
commit | a84ae30c28370c0ca15d4d1e071b07a6780ec3e9 (patch) | |
tree | 775c7d153da7e8a95f77e96bb597a8b69a77898d /emulator/btdev.c | |
parent | 039888b697af04aabbcb621e627af175c007a9c3 (diff) | |
download | bluez-a84ae30c28370c0ca15d4d1e071b07a6780ec3e9.tar.gz |
emulator: Add support enhanced SCO connection
Add support for enhanced_setup_synchronous_connection command
in btdev
Diffstat (limited to 'emulator/btdev.c')
-rw-r--r-- | emulator/btdev.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c index f8daf4587..86c9b4750 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -2488,6 +2488,59 @@ static void set_common_commands_bredr20(struct btdev *btdev) btdev->commands[16] |= 0x04; /* Enable Device Under Test Mode */ } +static int cmd_enhanced_setup_sync_conn(struct btdev *dev, const void *data, + uint8_t len) +{ + const struct bt_hci_cmd_enhanced_setup_sync_conn *cmd = data; + uint8_t status = BT_HCI_ERR_SUCCESS; + + if (cmd->tx_coding_format[0] > 5) + status = BT_HCI_ERR_INVALID_PARAMETERS; + + cmd_status(dev, status, BT_HCI_EVT_SYNC_CONN_COMPLETE); + + return 0; +} + +static int cmd_enhanced_setup_sync_conn_complete(struct btdev *dev, + const void *data, uint8_t len) +{ + const struct bt_hci_cmd_enhanced_setup_sync_conn *cmd = data; + struct bt_hci_evt_sync_conn_complete cc; + struct btdev_conn *conn; + + memset(&cc, 0, sizeof(cc)); + + conn = queue_find(dev->conns, match_handle, + UINT_TO_PTR(le16_to_cpu(cmd->handle))); + if (!conn) { + cc.status = BT_HCI_ERR_UNKNOWN_CONN_ID; + goto done; + } + + conn = conn_add_sco(conn); + if (!conn) { + cc.status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; + goto done; + } + + cc.status = BT_HCI_ERR_SUCCESS; + memcpy(cc.bdaddr, conn->link->dev->bdaddr, 6); + + cc.handle = cpu_to_le16(conn->handle); + cc.link_type = 0x02; + cc.tx_interval = 0x000c; + cc.retrans_window = 0x06; + cc.rx_pkt_len = 60; + cc.tx_pkt_len = 60; + cc.air_mode = cmd->tx_coding_format[0]; + +done: + send_event(dev, BT_HCI_EVT_SYNC_CONN_COMPLETE, &cc, sizeof(cc)); + + return 0; +} + static int cmd_setup_sync_conn(struct btdev *dev, const void *data, uint8_t len) { cmd_status(dev, BT_HCI_ERR_SUCCESS, BT_HCI_EVT_SYNC_CONN_COMPLETE); @@ -2886,7 +2939,9 @@ static int cmd_get_mws_transport_config(struct btdev *dev, const void *data, CMD(BT_HCI_CMD_READ_DATA_BLOCK_SIZE, cmd_read_data_block_size, NULL), \ CMD(BT_HCI_CMD_READ_LOCAL_CODECS, cmd_read_local_codecs, NULL), \ CMD(BT_HCI_CMD_GET_MWS_TRANSPORT_CONFIG, cmd_get_mws_transport_config, \ - NULL) + NULL), \ + CMD(BT_HCI_CMD_ENHANCED_SETUP_SYNC_CONN, cmd_enhanced_setup_sync_conn, \ + cmd_enhanced_setup_sync_conn_complete) static const struct btdev_cmd cmd_bredr[] = { CMD_COMMON_ALL, @@ -2919,6 +2974,7 @@ static void set_bredr_commands(struct btdev *btdev) btdev->commands[20] |= 0x10; /* Read Encryption Key Size */ btdev->commands[23] |= 0x04; /* Read Data Block Size */ btdev->commands[29] |= 0x20; /* Read Local Supported Codecs */ + btdev->commands[29] |= 0x08; /* Enhanced Setup Synchronous Conn */ btdev->commands[30] |= 0x08; /* Get MWS Transport Layer Config */ btdev->cmds = cmd_bredr; } |