diff mbox series

[BlueZ,2/3] client/player: Make QoS sync_factor configurable

Message ID 20241213113113.64818-3-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit bd2f851be865e8c1718e6397f390dd000f8121fd
Headers show
Series client/player: Make QoS sync_factor configurable | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success

Commit Message

Iulia Tanasescu Dec. 13, 2024, 11:31 a.m. UTC
This adds a new user input prompt when configuring a Broadcast Source
endpoint, to configure a QoS sync_factor value. This is useful for the
user to adjust how frequent PA announcements should be sent by the
Source, depending on scenario, instead of always using a hardcoded
value.

[bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0
                             /local/endpoint/ep0 16_2_1
[/local/endpoint/ep0] BIG (auto/value): 1
[/local/endpoint/ep0] Enter sync factor (value/auto): 2
[/local/endpoint/ep0] Enter channel location (value/no): 1
[/local/endpoint/ep0] Enter Metadata (value/no): no

The PA interval is chosen as the BIG SDU interval multiplied by
sync_factor:

< HCI Command: LE Set Periodic Advertising Parameters (0x08|0x003e)
        Handle: 1
        Min interval: 20.00 msec (0x0010)
        Max interval: 20.00 msec (0x0010)
        Properties: 0x0000
> HCI Event: Command Complete (0x0e)
      LE Set Periodic Advertising Parameters (0x08|0x003e)
        Status: Success (0x00)

< HCI Command: LE Create Broadcast Isochronous Group (0x08|0x0068)
        Handle: 0x01
        Advertising Handle: 0x01
        Number of BIS: 1
        SDU Interval: 10000 us (0x002710)
        Maximum SDU size: 40
        Maximum Latency: 10 ms (0x000a)
        RTN: 0x02
        PHY: LE 2M (0x02)
        Packing: Sequential (0x00)
        Framing: Unframed (0x00)
        Encryption: 0x00
        Broadcast Code[16]: 0102680553f1415aa265bbafc6ea03b8
> HCI Event: Command Status (0x0f)
      LE Create Broadcast Isochronous Group (0x08|0x0068)
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e)
      LE Broadcast Isochronous Group Complete (0x1b)
        Status: Success (0x00)
        Handle: 0x01
        BIG Synchronization Delay: 912 us (0x000390)
        Transport Latency: 912 us (0x000390)
        PHY: LE 2M (0x02)
        NSE: 3
        BN: 1
        PTO: 0
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 6

This also updates the broadcast-source.bt script, to include a new
input value for sync_factor.
---
 client/player.c                    | 30 +++++++++++++++++++++++++++---
 client/scripts/broadcast-source.bt |  1 +
 2 files changed, 28 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index eed8d2306..f93c9d908 100644
--- a/client/player.c
+++ b/client/player.c
@@ -3724,7 +3724,7 @@  add_meta:
 			endpoint_set_metadata_cfg, cfg);
 }
 
-static void config_endpoint_iso_group(const char *input, void *user_data)
+static void config_endpoint_sync_factor(const char *input, void *user_data)
 {
 	struct endpoint_config *cfg = user_data;
 	char *endptr = NULL;
@@ -3733,7 +3733,7 @@  static void config_endpoint_iso_group(const char *input, void *user_data)
 	bool found = false;
 
 	if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
-		cfg->ep->iso_group = BT_ISO_QOS_GROUP_UNSET;
+		cfg->qos.bcast.sync_factor = BT_ISO_SYNC_FACTOR;
 	} else {
 		value = strtol(input, &endptr, 0);
 
@@ -3742,7 +3742,7 @@  static void config_endpoint_iso_group(const char *input, void *user_data)
 			return bt_shell_noninteractive_quit(EXIT_FAILURE);
 		}
 
-		cfg->ep->iso_group = value;
+		cfg->qos.bcast.sync_factor = value;
 	}
 
 	/* Check if Channel Allocation is present in caps */
@@ -3763,6 +3763,30 @@  static void config_endpoint_iso_group(const char *input, void *user_data)
 	}
 }
 
+static void config_endpoint_iso_group(const char *input, void *user_data)
+{
+	struct endpoint_config *cfg = user_data;
+	char *endptr = NULL;
+	int value;
+
+	if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
+		cfg->ep->iso_group = BT_ISO_QOS_GROUP_UNSET;
+	} else {
+		value = strtol(input, &endptr, 0);
+
+		if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+			bt_shell_printf("Invalid argument: %s\n", input);
+			return bt_shell_noninteractive_quit(EXIT_FAILURE);
+		}
+
+		cfg->ep->iso_group = value;
+	}
+
+	bt_shell_prompt_input(cfg->ep->path,
+			"Enter sync factor (value/auto):",
+			config_endpoint_sync_factor, cfg);
+}
+
 static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 {
 	cfg->ep->bcode = g_new0(struct iovec, 1);
diff --git a/client/scripts/broadcast-source.bt b/client/scripts/broadcast-source.bt
index 6da9e23e2..1b918efb0 100644
--- a/client/scripts/broadcast-source.bt
+++ b/client/scripts/broadcast-source.bt
@@ -6,6 +6,7 @@  a
 4
 endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1
 1
+a
 3
 0x03 0x02 0x04 0x00
 transport.acquire /org/bluez/hci0/pac_bcast0/fd0
\ No newline at end of file