Skip to contentSkip to conversation

hci: add ext adv interface

PATCH In review Yang Li 2 participants 3 messages Oct 15 – Oct 30 Bluetooth drivers

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH v2 1/1 hci: add ext adv interface

Wrap extended advertising HCI command interfaces.

---

---
Changes in v2:
- Fixed coding style.
- Link to v1: https://patch.msgid.link/[email protected]

---
 lib/bluetooth/hci.c     | 194 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/bluetooth/hci.h     |  55 ++++++++++++++
 lib/bluetooth/hci_lib.h |  16 ++++
 3 files changed, 265 insertions(+)
lib/bluetooth/hci.c +194 -0
index f50a30c61..fe74ba2a5 100644
@@ -3017,6 +3017,200 @@ int hci_le_set_advertise_enable(int dd, uint8_t enable, int to)
 	return 0;
 }
 
+int hci_le_set_ext_adv_params(int dd, uint8_t handle, uint16_t evt_properties,
+			uint32_t min_interval, uint32_t max_interval,
+			uint8_t channel_map, uint8_t own_addr_type,
+			uint8_t peer_addr_type, const bdaddr_t *peer_addr,
+			uint8_t filter_policy, int8_t tx_power,
+			uint8_t primary_phy, uint8_t secondary_max_skip,
+			uint8_t secondary_phy, uint8_t sid,
+			uint8_t notif_enable, int to)
+{
+	struct hci_request rq;
+	le_set_ext_adv_params_cp cp;
+	struct {
+		uint8_t status;
+		int8_t  tx_power;
+	} rsp;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.handle = handle;
+	cp.evt_properties = evt_properties;
+	cp.min_interval[0] = min_interval & 0xff;
+	cp.min_interval[1] = (min_interval >> 8) & 0xff;
+	cp.min_interval[2] = (min_interval >> 16) & 0xff;
+	cp.max_interval[0] = max_interval & 0xff;
+	cp.max_interval[1] = (max_interval >> 8) & 0xff;
+	cp.max_interval[2] = (max_interval >> 16) & 0xff;
+	cp.channel_map = channel_map;
+	cp.own_addr_type = own_addr_type;
+	cp.peer_addr_type = peer_addr_type;
+	if (peer_addr)
+		memcpy(&cp.peer_addr, peer_addr, sizeof(cp.peer_addr));
+	cp.filter_policy = filter_policy;
+	cp.tx_power = tx_power;
+	cp.primary_phy = primary_phy;
+	cp.secondary_max_skip = secondary_max_skip;
+	cp.secondary_phy = secondary_phy;
+	cp.sid = sid;
+	cp.notif_enable = notif_enable;
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_SET_EXT_ADV_PARAMS;
+	rq.cparam = &cp;
+	rq.clen = sizeof(cp);
+	rq.rparam = &rsp;
+	rq.rlen = sizeof(rsp);
+
+	if (hci_send_req(dd, &rq, to) < 0)
+		return -1;
+
+	if (rsp.status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
+int hci_le_set_ext_adv_data(int dd, uint8_t handle, uint8_t operation,
+				uint8_t fragment_pref, const uint8_t *data,
+				uint8_t data_len, int to)
+{
+	struct hci_request rq;
+	le_set_ext_adv_data_cp *cp;
+	uint8_t status;
+	size_t plen = sizeof(*cp) + data_len;
+
+	cp = malloc(plen);
+	if (!cp) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	memset(cp, 0, plen);
+	cp->handle = handle;
+	cp->operation = operation;
+	cp->fragment_preference = fragment_pref;
+	cp->data_len = data_len;
+	if (data && data_len)
+		memcpy(cp->data, data, data_len);
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_SET_EXT_ADV_DATA;
+	rq.cparam = cp;
+	rq.clen = plen;
+	rq.rparam = &status;
+	rq.rlen = 1;
+
+	if (hci_send_req(dd, &rq, to) < 0) {
+		free(cp);
+		return -1;
+	}
+
+	free(cp);
+
+	if (status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
+int hci_le_set_ext_scan_rsp_data(int dd, uint8_t handle, uint8_t operation,
+				uint8_t fragment_pref, const uint8_t *data,
+				uint8_t data_len, int to)
+{
+	struct hci_request rq;
+	le_set_ext_adv_data_cp *cp;
+	uint8_t status;
+	size_t plen = sizeof(*cp) + data_len;
+
+	cp = malloc(plen);
+	if (!cp) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	memset(cp, 0, plen);
+	cp->handle = handle;
+	cp->operation = operation;
+	cp->fragment_preference = fragment_pref;
+	cp->data_len = data_len;
+	if (data && data_len)
+		memcpy(cp->data, data, data_len);
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_SET_EXT_SCAN_RSP_DATA;
+	rq.cparam = cp;
+	rq.clen = plen;
+	rq.rparam = &status;
+	rq.rlen = 1;
+
+	if (hci_send_req(dd, &rq, to) < 0) {
+		free(cp);
+		return -1;
+	}
+
+	free(cp);
+
+	if (status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
+int hci_le_set_ext_adv_enable(int dd, uint8_t enable, uint8_t num_of_sets,
+				const void *sets, int to)
+{
+	struct hci_request rq;
+	le_set_ext_adv_enable_cp *cp;
+	uint8_t status;
+	size_t set_entry_len = 4; /* handle(1) + duration(2) + max_events(1) */
+	size_t plen =
+		sizeof(le_set_ext_adv_enable_cp) + (num_of_sets * set_entry_len);
+
+	cp = malloc(plen);
+	if (!cp) {
+		errno = ENOMEM;
+		return -1;
+	}
+
+	memset(cp, 0, plen);
+	cp->enable = enable;
+	cp->num_of_sets = num_of_sets;
+	if (sets && num_of_sets)
+		memcpy(cp->sets, sets, num_of_sets * set_entry_len);
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_SET_EXT_ADV_ENABLE;
+	rq.cparam = cp;
+	rq.clen = plen;
+	rq.rparam = &status;
+	rq.rlen = 1;
+
+	if (hci_send_req(dd, &rq, to) < 0) {
+		free(cp);
+		return -1;
+	}
+
+	free(cp);
+
+	if (status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
 int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
 		uint8_t initiator_filter, uint8_t peer_bdaddr_type,
 		bdaddr_t peer_bdaddr, uint8_t own_bdaddr_type,
lib/bluetooth/hci.h +55 -0

61 lines not on this page · raw message

lib/bluetooth/hci_lib.h +16 -0
index eeb51411a..4a06a9383 100644
@@ -112,6 +112,22 @@ int hci_le_set_scan_enable(int dev_id, uint8_t enable, uint8_t filter_dup, int t
 int hci_le_set_scan_parameters(int dev_id, uint8_t type, uint16_t interval,
 					uint16_t window, uint8_t own_type,
 					uint8_t filter, int to);
+int hci_le_set_ext_adv_params(int dev_id, uint8_t handle, uint16_t evt_properties,
+				uint32_t min_interval, uint32_t max_interval,
+				uint8_t channel_map, uint8_t own_addr_type,
+				uint8_t peer_addr_type, const bdaddr_t *peer_addr,
+				uint8_t filter_policy, int8_t tx_power,
+				uint8_t primary_phy, uint8_t secondary_max_skip,
+				uint8_t secondary_phy, uint8_t sid,
+				uint8_t notif_enable, int to);
+int hci_le_set_ext_adv_data(int dev_id, uint8_t handle, uint8_t operation,
+				uint8_t fragment_pref, const uint8_t *data,
+				uint8_t data_len, int to);
+int hci_le_set_ext_scan_rsp_data(int dev_id, uint8_t handle, uint8_t operation,
+				uint8_t fragment_pref, const uint8_t *data,
+				uint8_t data_len, int to);
+int hci_le_set_ext_adv_enable(int dev_id, uint8_t enable, uint8_t num_of_sets,
+				const void *sets, int to);
 int hci_le_set_advertise_enable(int dev_id, uint8_t enable, int to);
 int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
 		uint8_t initiator_filter, uint8_t peer_bdaddr_type,

---
base-commit: 9dc7e40962f11d1d9a5568f8a7633a695288329c
change-id: 20261014-extend_adv_api-61bb883ac885

Best regards,

Signature · 1 line
Yang Li <[email protected]>
#1 lore raw

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/series/1186303/

---Test result---

Test Summary:

CheckPatch                    FAIL      0.45 seconds
GitLint                       PASS      0.24 seconds
BuildEll                      PASS      12.70 seconds
BluezMake                     PASS      166.45 seconds
MakeCheck                     PASS      0.53 seconds
MakeDistcheck                 PASS      92.68 seconds
CheckValgrind                 PASS      87.35 seconds
CheckSmatch                   PASS      166.30 seconds
bluezmakeextell               PASS      57.75 seconds
TestFunctional                PASS      802.36 seconds
IncrementalBuild              PASS      186.96 seconds
ScanBuild                     PASS      607.08 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,bluez,v2] hci: add ext adv interface WARNING:LONG_LINE: line length of 81 exceeds 80 columns #261: FILE: lib/bluetooth/hci.c:3177:
+ sizeof(le_set_ext_adv_enable_cp) + (num_of_sets * set_entry_len);

WARNING:NEW_TYPEDEFS: do not add new typedefs
#310: FILE: lib/bluetooth/hci.h:1739:
+typedef struct {

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #326: FILE: lib/bluetooth/hci.h:1755:
+} __attribute__ ((packed)) le_set_ext_adv_params_cp;

WARNING:NEW_TYPEDEFS: do not add new typedefs
#329: FILE: lib/bluetooth/hci.h:1758:
+typedef struct {

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #332: FILE: lib/bluetooth/hci.h:1761:
+} __attribute__ ((packed)) le_set_ext_adv_params_rp;

WARNING:NEW_TYPEDEFS: do not add new typedefs
#336: FILE: lib/bluetooth/hci.h:1765:
+typedef struct {

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #342: FILE: lib/bluetooth/hci.h:1771:
+} __attribute__ ((packed)) le_set_ext_adv_data_cp;

WARNING:NEW_TYPEDEFS: do not add new typedefs
#346: FILE: lib/bluetooth/hci.h:1775:
+typedef struct {

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #352: FILE: lib/bluetooth/hci.h:1781:
+} __attribute__((packed)) le_set_ext_scan_rsp_data_cp;

WARNING:NEW_TYPEDEFS: do not add new typedefs
#356: FILE: lib/bluetooth/hci.h:1785:
+typedef struct {

WARNING:LONG_LINE_COMMENT: line length of 84 exceeds 80 columns #359: FILE: lib/bluetooth/hci.h:1788:
+ /* followed by ext adv set entries: handle(1), duration(2), max_events(1) */

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #361: FILE: lib/bluetooth/hci.h:1790:
+} __attribute__ ((packed)) le_set_ext_adv_enable_cp;

WARNING:LONG_LINE: line length of 82 exceeds 80 columns
#375: FILE: lib/bluetooth/hci_lib.h:115:
+int hci_le_set_ext_adv_params(int dev_id, uint8_t handle, uint16_t evt_properties,

WARNING:LONG_LINE: line length of 82 exceeds 80 columns #378: FILE: lib/bluetooth/hci_lib.h:118:
+ uint8_t peer_addr_type, const bdaddr_t *peer_addr,

/home/runner/work/bluez/bluez/src/patch/14891171.patch total: 0 errors, 14 warnings, 283 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.

/home/runner/work/bluez/bluez/src/patch/14891171.patch has style problems, please review.

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

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

https://github.com/bluez/bluez/pull/2684

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Yang Li

This is an automated email and please do not reply to this email.

Dear Submitter,

This series was picked up by the CI more than 2 weeks ago and the pull request created for it is still open, which means the series was never applied to the tree.

Series: [BlueZ,bluez,v2] hci: add ext adv interface
Pull Request: https://github.com/bluez/bluez/pull/2684
Created: 2026-10-15 12:08:07+00:00

The pull request has been closed and no further action is taken on this series.

If the change should still be considered, it must be resent to the Linux Bluetooth mailing list ([email protected]) so that it is picked up again.

---
Regards,
Linux Bluetooth