From 7bf51153378dfa5ae7c614ba0f72ba22e701b034 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 6 Apr 2022 13:01:03 -0700 Subject: [PATCH] btdev: Fix BIG Create Sync This fixes status return to BIG Create Sync command. Signed-off-by: Manika Shrivastava Signed-off-by: Ayush Garg --- emulator/btdev.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index d191c82..f70fa91 100755 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -6070,15 +6070,19 @@ static int cmd_big_create_sync(struct btdev *dev, const void *data, uint8_t len) /* If the Sync_Handle does not exist, the Controller shall return the * error code Unknown Advertising Identifier (0x42). */ - if (dev->le_pa_sync_handle != le16_to_cpu(cmd->sync_handle)) + if (dev->le_pa_sync_handle != le16_to_cpu(cmd->sync_handle)) { status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID; + goto done; + } /* If the Host sends this command with a BIG_Handle that is already * allocated, the Controller shall return the error code Command * Disallowed (0x0C). */ - if (dev->big_handle == cmd->handle) + if (dev->big_handle == cmd->handle) { status = BT_HCI_ERR_COMMAND_DISALLOWED; + goto done; + } /* If the Num_BIS parameter is greater than the total number of BISes * in the BIG, the Controller shall return the error code Unsupported @@ -6087,12 +6091,10 @@ static int cmd_big_create_sync(struct btdev *dev, const void *data, uint8_t len) if (cmd->num_bis != len - sizeof(*cmd)) status = BT_HCI_ERR_UNSUPPORTED_FEATURE; - if (status) - return status; - +done: cmd_status(dev, status, BT_HCI_CMD_LE_BIG_CREATE_SYNC); - return status; + return 0; } static int cmd_big_create_sync_complete(struct btdev *dev, const void *data, @@ -6140,7 +6142,7 @@ static int cmd_big_create_sync_complete(struct btdev *dev, const void *data, pdu.ev.pto = 0x00; pdu.ev.irc = 0x01; pdu.ev.max_pdu = bis->sdu; - pdu.ev.interval = bis->latency; + pdu.ev.interval = bis->latency / 1.25; pdu.ev.num_bis = cmd->num_bis; le_meta_event(dev, BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED, &pdu, @@ -6873,6 +6875,7 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id) btdev->iso_mtu = 251; btdev->iso_max_pkt = 1; btdev->le_cig.params.cig_id = 0xff; + btdev->big_handle = 0xff; btdev->country_code = 0x00; -- 2.7.4