diff mbox series

emulator: Periodic Advertising and Create BIG Command

Message ID 20210204210222.69767-1-cdwhite13@gmail.com (mailing list archive)
State New, archived
Headers show
Series emulator: Periodic Advertising and Create BIG Command | expand

Commit Message

Chris White Feb. 4, 2021, 9:02 p.m. UTC
From: Keyur Parekh <kpare@dolby.com>

This adds support for Periodic Advertising and the Create BIG HCI
command in the emulator. These changes are the first step in making
the emulator useful for testing the LE Audio broadcast feature.
---
 emulator/btdev.c | 82 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 73 insertions(+), 9 deletions(-)

Comments

bluez.test.bot@gmail.com Feb. 4, 2021, 9:29 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=428267

---Test result---

##############################
Test: CheckPatch - FAIL
Output:
emulator: Periodic Advertising and Create BIG Command
ERROR:CODE_INDENT: code indent should use tabs where possible
#18: FILE: emulator/btdev.c:144:
+        uint8_t  le_periodic_adv_enable;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#18: FILE: emulator/btdev.c:144:
+        uint8_t  le_periodic_adv_enable;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#19: FILE: emulator/btdev.c:145:
+        uint16_t le_periodic_adv_properties;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#19: FILE: emulator/btdev.c:145:
+        uint16_t le_periodic_adv_properties;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#20: FILE: emulator/btdev.c:146:
+        uint16_t le_periodic_min_interval;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#20: FILE: emulator/btdev.c:146:
+        uint16_t le_periodic_min_interval;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#21: FILE: emulator/btdev.c:147:
+        uint16_t le_periodic_max_interval;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#21: FILE: emulator/btdev.c:147:
+        uint16_t le_periodic_max_interval;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#22: FILE: emulator/btdev.c:148:
+        uint8_t  le_periodic_data_len;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#22: FILE: emulator/btdev.c:148:
+        uint8_t  le_periodic_data_len;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#23: FILE: emulator/btdev.c:149:
+        uint8_t  le_periodic_data[31];$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#23: FILE: emulator/btdev.c:149:
+        uint8_t  le_periodic_data[31];$

ERROR:ELSE_AFTER_BRACE: else should follow close brace '}'
#47: FILE: emulator/btdev.c:3948:
+	}
+	else {

ERROR:ELSE_AFTER_BRACE: else should follow close brace '}'
#87: FILE: emulator/btdev.c:3984:
+	}
+	else {

- total: 8 errors, 6 warnings, 124 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

"[PATCH] emulator: Periodic Advertising and Create BIG Command" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 17965f9b6..3f9201ba2 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -141,6 +141,12 @@  struct btdev {
 	uint8_t  le_scan_own_addr_type;
 	uint8_t  le_filter_dup;
 	uint8_t  le_adv_enable;
+        uint8_t  le_periodic_adv_enable;
+        uint16_t le_periodic_adv_properties;
+        uint16_t le_periodic_min_interval;
+        uint16_t le_periodic_max_interval;
+        uint8_t  le_periodic_data_len;
+        uint8_t  le_periodic_data[31];
 	uint8_t  le_ltk[16];
 	struct {
 		struct bt_hci_cmd_le_set_cig_params params;
@@ -3008,7 +3014,6 @@  static void le_send_adv_report(struct btdev *btdev, const struct btdev *remote,
 	} meta_event;
 
 	meta_event.subevent = BT_HCI_EVT_LE_ADV_REPORT;
-
 	memset(&meta_event.lar, 0, sizeof(meta_event.lar));
 	meta_event.lar.num_reports = 1;
 	meta_event.lar.event_type = type;
@@ -3934,22 +3939,57 @@  static int cmd_clear_adv_sets(struct btdev *dev, const void *data,
 static int cmd_set_per_adv_params(struct btdev *dev, const void *data,
 							uint8_t len)
 {
-	/* TODO */
-	return -ENOTSUP;
+	const struct bt_hci_cmd_le_set_periodic_adv_params *cmd = data;
+	uint8_t status;
+
+	if (dev->le_periodic_adv_enable) {
+		status = BT_HCI_ERR_COMMAND_DISALLOWED;
+	}
+	else {
+		status = BT_HCI_ERR_SUCCESS;
+		dev->le_periodic_adv_properties = le16_to_cpu(cmd->properties);
+		dev->le_periodic_min_interval = cmd->min_interval;
+		dev->le_periodic_max_interval = cmd->max_interval;
+	}
+
+	cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_PARAMS, &status,
+							sizeof(status));
+
+	return 0;
 }
 
 static int cmd_set_per_adv_data(struct btdev *dev, const void *data,
 							uint8_t len)
 {
-	/* TODO */
-	return -ENOTSUP;
+	const struct bt_hci_cmd_le_set_periodic_adv_data *cmd = data;
+	uint8_t status = BT_HCI_ERR_SUCCESS;
+
+	dev->le_periodic_data_len = cmd->data_len;
+	memcpy(dev->le_periodic_data, cmd->data, 31);
+	cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_DATA, &status,
+							sizeof(status));
+
+	return 0;
 }
 
 static int cmd_set_per_adv_enable(struct btdev *dev, const void *data,
 							uint8_t len)
 {
-	/* TODO */
-	return -ENOTSUP;
+	const struct bt_hci_cmd_le_set_periodic_adv_enable *cmd = data;
+	uint8_t status;
+
+	if (dev->le_periodic_adv_enable == cmd->enable) {
+		status = BT_HCI_ERR_COMMAND_DISALLOWED;
+	}
+	else {
+		dev->le_periodic_adv_enable = cmd->enable;
+		status = BT_HCI_ERR_SUCCESS;
+	}
+
+	cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE, &status,
+							sizeof(status));
+
+	return 0;
 }
 
 static int cmd_set_ext_scan_params(struct btdev *dev, const void *data,
@@ -4470,9 +4510,32 @@  static int cmd_reject_cis(struct btdev *dev, const void *data, uint8_t len)
 static int cmd_create_big(struct btdev *dev, const void *data, uint8_t len)
 {
 	/* TODO */
-	return -ENOTSUP;
+	cmd_status(dev, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_CREATE_BIG);
+
+	return 0;
 }
 
+static int cmd_create_big_complete(struct btdev *dev, const void *data,
+							uint8_t len)
+{
+	const struct bt_hci_cmd_le_create_big *cmd = data;
+	int i;
+
+	for (i = 0; i < cmd->num_bis; i++) {
+		const struct bt_hci_bis *bis = &cmd->bis[i];
+		struct  bt_hci_evt_le_big_complete evt;
+
+		evt.big_id = cmd->big_id;
+		evt.num_bis = cmd->num_bis;
+		evt.phy = bis->phy;
+		memcpy(&evt.latency, &(bis->latency), 3);
+
+		le_meta_event(dev, BT_HCI_EVT_LE_BIG_COMPLETE, &evt,
+					sizeof(evt));
+	}
+
+	return 0;
+}
 static int cmd_create_big_test(struct btdev *dev, const void *data, uint8_t len)
 {
 	/* TODO */
@@ -4621,7 +4684,8 @@  static int cmd_set_host_feature(struct btdev *dev, const void *data,
 	CMD(BT_HCI_CMD_LE_REMOVE_CIG, cmd_remove_cig, NULL), \
 	CMD(BT_HCI_CMD_LE_ACCEPT_CIS, cmd_accept_cis, NULL), \
 	CMD(BT_HCI_CMD_LE_REJECT_CIS, cmd_reject_cis, NULL), \
-	CMD(BT_HCI_CMD_LE_CREATE_BIG, cmd_create_big, NULL), \
+	CMD(BT_HCI_CMD_LE_CREATE_BIG, cmd_create_big, \
+			cmd_create_big_complete), \
 	CMD(BT_HCI_CMD_LE_CREATE_BIG_TEST, cmd_create_big_test, NULL), \
 	CMD(BT_HCI_CMD_LE_TERM_BIG, cmd_term_big, NULL), \
 	CMD(BT_HCI_CMD_LE_BIG_CREATE_SYNC, cmd_big_create_sync, NULL), \