linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] emulator: Periodic Advertising and Create BIG Command
@ 2021-02-04 21:02 Chris White
  2021-02-04 21:29 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Chris White @ 2021-02-04 21:02 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cwhit, Keyur Parekh

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(-)

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), \
-- 
2.21.0 (Apple Git-122.2)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: emulator: Periodic Advertising and Create BIG Command
  2021-02-04 21:02 [PATCH] emulator: Periodic Advertising and Create BIG Command Chris White
@ 2021-02-04 21:29 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2021-02-04 21:29 UTC (permalink / raw)
  To: linux-bluetooth, cdwhite13

[-- Attachment #1: Type: text/plain, Size: 3192 bytes --]

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-04 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 21:02 [PATCH] emulator: Periodic Advertising and Create BIG Command Chris White
2021-02-04 21:29 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).