Diff between 0356d2a4c690bbd50c307cf795ccc047accd3d65 and 0f849abb1b090257370225a0d6bfa4b2d4871ca5

Changed Files

File Additions Deletions Status
emulator/btdev.c +13 -0 modified

Full Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 7f4386e..c9ec22e 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -2998,8 +2998,21 @@ static int cmd_set_random_address(struct btdev *dev, const void *data,
 	const struct bt_hci_cmd_le_set_random_address *cmd = data;
 	uint8_t status;
 
+	/* If the Host issues this command when any of advertising
+	 * (created using legacy advertising commands), scanning, or initiating
+	 * are enabled, the Controller shall return the error code
+	 * Command Disallowed (0x0C).
+	 */
+	if (dev->le_scan_enable || (dev->le_adv_enable &&
+					queue_isempty(dev->le_ext_adv))) {
+		status = BT_HCI_ERR_COMMAND_DISALLOWED;
+		goto done;
+	}
+
 	memcpy(dev->random_addr, cmd->addr, 6);
 	status = BT_HCI_ERR_SUCCESS;
+
+done:
 	cmd_complete(dev, BT_HCI_CMD_LE_SET_RANDOM_ADDRESS, &status,
 						sizeof(status));