summaryrefslogtreecommitdiff
path: root/emulator
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-03-10 15:20:49 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-04-14 17:05:21 -0700
commitdc1b309901e5a1af4fdb5dc36c4af87ea9f7fae3 (patch)
tree3a9b779faa2cd05e0cd832b6c28bbc790d3095bc /emulator
parent1967b5311525846d94fca3a2a73f9efc743b0572 (diff)
downloadbluez-dc1b309901e5a1af4fdb5dc36c4af87ea9f7fae3.tar.gz
bthost: Add support for Create CIS
This introduces bthost_set_cig_params and bthost_create_cis.
Diffstat (limited to 'emulator')
-rw-r--r--emulator/btdev.c2
-rw-r--r--emulator/bthost.c42
-rw-r--r--emulator/bthost.h6
3 files changed, 49 insertions, 1 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c
index ccfaed36b..ae27ce613 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5860,7 +5860,7 @@ static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
memset(&evt, 0, sizeof(evt));
evt.status = status;
- evt.conn_handle = cpu_to_le16(conn->handle);
+ evt.conn_handle = conn ? cpu_to_le16(conn->handle) : 0x0000;
if (!evt.status) {
struct btdev *remote = conn->link->dev;
diff --git a/emulator/bthost.c b/emulator/bthost.c
index f629f2e6e..a7a0b8428 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -3127,6 +3127,48 @@ bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr)
return false;
}
+void bthost_set_cig_params(struct bthost *bthost, uint8_t cig_id,
+ uint8_t cis_id)
+{
+ struct bt_hci_cmd_le_set_cig_params *cp;
+
+ cp = malloc(sizeof(*cp) + sizeof(*cp->cis));
+ memset(cp, 0, sizeof(*cp) + sizeof(*cp->cis));
+ cp->cig_id = cig_id;
+ put_le24(10000, cp->c_interval);
+ put_le24(10000, cp->p_interval);
+ cp->c_latency = cpu_to_le16(10);
+ cp->p_latency = cpu_to_le16(10);
+ cp->num_cis = 0x01;
+ cp->cis[0].cis_id = cis_id;
+ cp->cis[0].c_sdu = 40;
+ cp->cis[0].p_sdu = 40;
+ cp->cis[0].c_phy = 0x02;
+ cp->cis[0].p_phy = 0x02;
+ cp->cis[0].c_rtn = 2;
+ cp->cis[0].p_rtn = 2;
+
+ send_command(bthost, BT_HCI_CMD_LE_SET_CIG_PARAMS, cp,
+ sizeof(*cp) + sizeof(*cp->cis));
+ free(cp);
+}
+
+void bthost_create_cis(struct bthost *bthost, uint16_t cis_handle,
+ uint16_t acl_handle)
+{
+ struct bt_hci_cmd_le_create_cis *cp;
+
+ cp = malloc(sizeof(*cp) + sizeof(*cp->cis));
+ memset(cp, 0, sizeof(*cp) + sizeof(*cp->cis));
+ cp->num_cis = 0x01;
+ cp->cis[0].cis_handle = cpu_to_le16(cis_handle);
+ cp->cis[0].acl_handle = cpu_to_le16(acl_handle);
+
+ send_command(bthost, BT_HCI_CMD_LE_CREATE_CIS, cp,
+ sizeof(*cp) + sizeof(*cp->cis));
+ free(cp);
+}
+
void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode)
{
send_command(bthost, BT_HCI_CMD_WRITE_SIMPLE_PAIRING_MODE, &mode, 1);
diff --git a/emulator/bthost.h b/emulator/bthost.h
index ae5678009..fd177ac29 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -100,6 +100,12 @@ void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable);
void bthost_create_big(struct bthost *bthost, uint8_t num_bis);
bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr);
+void bthost_set_cig_params(struct bthost *bthost, uint8_t cig_id,
+ uint8_t cis_id);
+void bthost_create_cis(struct bthost *bthost, uint16_t cis_handle,
+ uint16_t acl_handle);
+
+
void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type,
uint8_t addr_type, uint8_t filter_policy);
void bthost_set_scan_enable(struct bthost *bthost, uint8_t enable);