btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 5 Mar 2022 01:22:21 +0000 (17:22 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:53 +0000 (14:55 +0530)
This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
emulator/btdev.c

index 09101a5..1568913 100755 (executable)
@@ -5425,8 +5425,21 @@ static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data,
 static int cmd_per_adv_term_sync(struct btdev *dev, const void *data,
                                                        uint8_t len)
 {
-       /* TODO */
-       return -ENOTSUP;
+       uint8_t status = BT_HCI_ERR_SUCCESS;
+
+       /* If the periodic advertising train corresponding to the Sync_Handle
+        * parameter does not exist, then the Controller shall return the error
+        * code Unknown Advertising Identifier (0x42).
+        */
+       if (dev->le_periodic_sync_handle != SYC_HANDLE)
+               status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
+       else
+               dev->le_periodic_sync_handle = 0x0000;
+
+       cmd_complete(dev, BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC,
+                                       &status, sizeof(status));
+
+       return 0;
 }
 
 static int cmd_per_adv_add(struct btdev *dev, const void *data, uint8_t len)