diff mbox series

[BlueZ,v2] bthost: Set advertising intervals to valid value

Message ID 20250215201329.173999-1-arkadiusz.bokowy@gmail.com (mailing list archive)
State Accepted
Commit 3c62df13abbce6551166a25c481a1cd4d2d32ce7
Headers show
Series [BlueZ,v2] bthost: Set advertising intervals to valid value | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch warning CheckSparse WARNING emulator/btdev.c:450:29: warning: Variable length array is used.emulator/bthost.c:613:28: warning: Variable length array is used.emulator/bthost.c:787:28: warning: Variable length array is used.
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Arkadiusz Bokowy Feb. 15, 2025, 8:13 p.m. UTC
The range for LE advertising intervals shall be in range between 20 ms
and 10,485,759.375 ms. Requesting other value should result in the
unsupported feature or parameter value error code (0x11).

After the modification in fa4d477, the btdev emulator no longer accepts
uninitialized LE advertising intervals. To fix that, set the default LE
advertising interval to the lowest possible value - 20 ms - in order to
minimize tests delay cause by device discovery.

Also, this commit fixes the detection of the high duty cycle directed
connectable advertising and sets the advertising interval to 3 ms for
such cases in order to be complaint with the spec.
---
 emulator/btdev.c  | 11 ++++++-----
 emulator/bthost.c |  3 +++
 2 files changed, 9 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com Feb. 15, 2025, 9:28 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=934345

---Test result---

Test Summary:
CheckPatch                    PENDING   0.18 seconds
GitLint                       PENDING   0.18 seconds
BuildEll                      PASS      20.32 seconds
BluezMake                     PASS      1435.46 seconds
MakeCheck                     PASS      12.95 seconds
MakeDistcheck                 PASS      157.43 seconds
CheckValgrind                 PASS      212.69 seconds
CheckSmatch                   WARNING   282.54 seconds
bluezmakeextell               PASS      97.87 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      860.16 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
emulator/btdev.c:450:29: warning: Variable length array is used.emulator/bthost.c:613:28: warning: Variable length array is used.emulator/bthost.c:787:28: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Feb. 18, 2025, 5:10 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Sat, 15 Feb 2025 21:13:29 +0100 you wrote:
> The range for LE advertising intervals shall be in range between 20 ms
> and 10,485,759.375 ms. Requesting other value should result in the
> unsupported feature or parameter value error code (0x11).
> 
> After the modification in fa4d477, the btdev emulator no longer accepts
> uninitialized LE advertising intervals. To fix that, set the default LE
> advertising interval to the lowest possible value - 20 ms - in order to
> minimize tests delay cause by device discovery.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] bthost: Set advertising intervals to valid value
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3c62df13abbc

You are awesome, thank you!
diff mbox series

Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index d7f61deb0..d04c5b023 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -4870,14 +4870,15 @@  static int cmd_set_ext_adv_params(struct btdev *dev, const void *data,
 
 	ext_adv->type = le16_to_cpu(cmd->evt_properties);
 
-	/* In case of direct advertising (type == 0x01) the advertising
-	 * intervals shall be ignored and high duty cycle shall be used.
+	/* In case of high duty cycle directed connectable advertising
+	 * intervals shall be ignored and high duty cycle shall be used
+	 * (advertising interval <= 3.75 ms).
 	 */
-	if (ext_adv->type == 0x01)
-		ext_adv->interval = 10;
+	if ((ext_adv->type & 0x0D) == 0x0D /* 0b1101 */)
+		ext_adv->interval = 3;
 	else {
 		unsigned int min_interval = get_le24(cmd->min_interval);
-		if (min_interval < 0x0020 || min_interval > 0x4000) {
+		if (min_interval < 0x0020 || min_interval > 0xFFFFFF) {
 			rsp.status = BT_HCI_ERR_UNSUPPORTED_FEATURE;
 			cmd_complete(dev, BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
 						&rsp, sizeof(rsp));
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 95160506d..a76b02ecc 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -3249,11 +3249,14 @@  void bthost_set_scan_enable(struct bthost *bthost, uint8_t enable)
 
 void bthost_set_ext_adv_params(struct bthost *bthost)
 {
+	const uint8_t interval_20ms[] = { 0x20, 0x00, 0x00 };
 	struct bt_hci_cmd_le_set_ext_adv_params cp;
 
 	memset(&cp, 0, sizeof(cp));
 	cp.handle = 0x01;
 	cp.evt_properties = cpu_to_le16(0x0013);
+	memcpy(cp.min_interval, interval_20ms, sizeof(cp.min_interval));
+	memcpy(cp.max_interval, interval_20ms, sizeof(cp.max_interval));
 	send_command(bthost, BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
 							&cp, sizeof(cp));
 }