Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 0/2] ranging: mode validation and
@ 2026-08-20 17:49 Naga Bhavani Akella
  2026-08-20 17:49 ` [PATCH BlueZ v1 1/2] src: Modify MaxTxPower option documentation for ChannelSounding Naga Bhavani Akella
  2026-08-20 17:49 ` [PATCH BlueZ v1 2/2] client: Enforce Valid Main Mode and Sub Mode Combinations Naga Bhavani Akella
  0 siblings, 2 replies; 4+ messages in thread
From: Naga Bhavani Akella @ 2026-08-20 17:49 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, quic_mohamull, quic_hbandi, quic_anubhavg,
	Naga Bhavani Akella

This patch series introduces validation for Main Mode and Sub Mode
combinations in Channel Sounding configuration and updates the
MaxTxPower option documentation to reflect the supported value range.

Patch 1 adds validation to ensure that only specification compliant
main_mode_type and sub_mode_type combinations are accepted. Invalid
combinations are rejected, and the user is informed of the supported
mode pairings.

Patch 2 updates the MaxTxPower configuration option documentation to
clarify that decimal values are supported within the range of
-127 dBm to 20 dBm. The documentation also notes that the default
value is 20 dBm, corresponding to the maximum transmit power.


Naga Bhavani Akella (2):
  src: Modify MaxTxPower option documentation for ChannelSounding
  client: Enforce Valid Main Mode and Sub Mode Combinations

 client/cs.c   | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/main.conf |  6 ++--
 2 files changed, 78 insertions(+), 4 deletions(-)

-- 


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

* [PATCH BlueZ v1 1/2] src: Modify MaxTxPower option documentation for ChannelSounding
  2026-08-20 17:49 [PATCH BlueZ v1 0/2] ranging: mode validation and Naga Bhavani Akella
@ 2026-08-20 17:49 ` Naga Bhavani Akella
  2026-08-20 18:57   ` ranging: mode validation and bluez.test.bot
  2026-08-20 17:49 ` [PATCH BlueZ v1 2/2] client: Enforce Valid Main Mode and Sub Mode Combinations Naga Bhavani Akella
  1 sibling, 1 reply; 4+ messages in thread
From: Naga Bhavani Akella @ 2026-08-20 17:49 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, quic_mohamull, quic_hbandi, quic_anubhavg,
	Naga Bhavani Akella

Modify MaxTxPower configuration option to take decimal values
within the range of -127dBm to 20dBm
Defaults to 20 (max power).
---
 src/main.conf | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main.conf b/src/main.conf
index 5846ef92d..80f4a3a0c 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -319,9 +319,9 @@
 #CsSyncAntennaSel = 0xFF
 
 # Maximum Transmit power
-# Possible values: 0x81-0x14 (-127dBm to 20dBm)
-# Default: 0x14 (Max Power possible)
-#MaxTxPower = 0x14
+# Possible values: -127dBm to 20dBm
+# Default: 20 (Max Power possible)
+#MaxTxPower = 20
 
 [CSIS]
 # SIRK - Set Identification Resolution Key which is common for all the
-- 


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

* [PATCH BlueZ v1 2/2] client: Enforce Valid Main Mode and Sub Mode Combinations
  2026-08-20 17:49 [PATCH BlueZ v1 0/2] ranging: mode validation and Naga Bhavani Akella
  2026-08-20 17:49 ` [PATCH BlueZ v1 1/2] src: Modify MaxTxPower option documentation for ChannelSounding Naga Bhavani Akella
@ 2026-08-20 17:49 ` Naga Bhavani Akella
  1 sibling, 0 replies; 4+ messages in thread
From: Naga Bhavani Akella @ 2026-08-20 17:49 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, quic_mohamull, quic_hbandi, quic_anubhavg,
	Naga Bhavani Akella

Introduce validation for main_mode_type and sub_mode_type combinations as
specified in the protocol requirements.
Reject invalid combinations and guide the user by displaying
the acceptable mode pairings.
---
 client/cs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/client/cs.c b/client/cs.c
index 9f069589d..64eeb212b 100644
--- a/client/cs.c
+++ b/client/cs.c
@@ -644,22 +644,96 @@ static void cs_print_role_hint(uint8_t role)
 				" procedure.\n");
 }
 
+/* Core CS mode combinations: sub_mode_type == 0xFF means "None". */
+static const struct {
+	uint8_t main_mode_type;
+	uint8_t sub_mode_type;
+} cs_valid_mode_combos[] = {
+	{ 0x01, 0xFF },
+	{ 0x02, 0xFF },
+	{ 0x03, 0xFF },
+	{ 0x02, 0x01 },
+	{ 0x02, 0x03 },
+	{ 0x03, 0x02 },
+};
+
+static bool cs_mode_combo_is_valid(uint8_t main_mode_type,
+					uint8_t sub_mode_type)
+{
+	unsigned int i;
+
+	for (i = 0; i < G_N_ELEMENTS(cs_valid_mode_combos); i++) {
+		if (cs_valid_mode_combos[i].main_mode_type == main_mode_type &&
+				cs_valid_mode_combos[i].sub_mode_type ==
+							sub_mode_type)
+			return true;
+	}
+
+	return false;
+}
+
+static void cs_print_valid_mode_combos(void)
+{
+	bt_shell_printf("Valid combinations:\n"
+			"  main_mode_type - sub_mode_type\n"
+			"  Main(0x01) - Sub(0xff)\n"
+			"  Main(0x02) - Sub(0xff)\n"
+			"  Main(0x03) - Sub(0xff)\n"
+			"  Main(0x02) - Sub(0x01)\n"
+			"  Main(0x02) - Sub(0x03)\n"
+			"  Main(0x03) - Sub(0x02)\n");
+}
+
+/* Rejects the just-applied main_mode_type/sub_mode_type change by
+ * restoring the previous values if the resulting combination is not
+ * one of cs_valid_mode_combos.
+ */
+static void cs_enforce_mode_combo(uint8_t old_main_mode_type,
+					uint8_t old_sub_mode_type)
+{
+	if (cs_mode_combo_is_valid(cs_cfg.main_mode_type, cs_cfg.sub_mode_type))
+		return;
+
+	bt_shell_printf("Error: main_mode_type=0x%02x sub_mode_type=0x%02x is "
+			"not a valid combination. Rejecting change.\n",
+			cs_cfg.main_mode_type, cs_cfg.sub_mode_type);
+	cs_print_valid_mode_combos();
+
+	cs_cfg.main_mode_type = old_main_mode_type;
+	cs_cfg.sub_mode_type = old_sub_mode_type;
+
+	bt_shell_printf("Keeping main_mode_type=0x%02x sub_mode_type=0x%02x\n",
+			cs_cfg.main_mode_type, cs_cfg.sub_mode_type);
+}
+
 /* Generic handler for the per-parameter set commands (cs.role,
  * cs.main_mode_type, ...); argv[0] is the parameter name (the command
  * itself), argv[1] is the value.
  */
 static void cmd_cs_set(int argc, char *argv[])
 {
+	uint8_t old_main_mode_type = cs_cfg.main_mode_type;
+	uint8_t old_sub_mode_type = cs_cfg.sub_mode_type;
+	bool is_mode_param;
+
 	if (argc < 2) {
 		bt_shell_printf("Usage: %s <value>\n", argv[0]);
 		return;
 	}
 
+	is_mode_param = !strcmp(argv[0], "main_mode_type") ||
+				!strcmp(argv[0], "sub_mode_type");
+
 	if (!cs_set_param(argv[0], argv[1]))
 		return;
 
-	if (!strcmp(argv[0], "role"))
+	if (!strcmp(argv[0], "role")) {
 		cs_print_role_hint(cs_role);
+		return;
+	}
+
+	if (is_mode_param)
+		cs_enforce_mode_combo(old_main_mode_type, old_sub_mode_type);
 }
 
 /* Tab completion for params whose only legal values are a small fixed
-- 


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

* RE: ranging: mode validation and
  2026-08-20 17:49 ` [PATCH BlueZ v1 1/2] src: Modify MaxTxPower option documentation for ChannelSounding Naga Bhavani Akella
@ 2026-08-20 18:57   ` bluez.test.bot
  0 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-08-20 18:57 UTC (permalink / raw)
  To: linux-bluetooth, naga.akella

[-- Attachment #1: Type: text/plain, Size: 824 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=1149256

---Test result---

Test Summary:
CheckPatch                    PASS      0.77 seconds
GitLint                       PASS      0.55 seconds
BuildEll                      PASS      20.52 seconds
BluezMake                     PASS      564.82 seconds
CheckSmatch                   PASS      299.95 seconds
bluezmakeextell               PASS      96.83 seconds
IncrementalBuild              PASS      552.85 seconds
ScanBuild                     PASS      891.92 seconds



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

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-08-20 18:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 17:49 [PATCH BlueZ v1 0/2] ranging: mode validation and Naga Bhavani Akella
2026-08-20 17:49 ` [PATCH BlueZ v1 1/2] src: Modify MaxTxPower option documentation for ChannelSounding Naga Bhavani Akella
2026-08-20 18:57   ` ranging: mode validation and bluez.test.bot
2026-08-20 17:49 ` [PATCH BlueZ v1 2/2] client: Enforce Valid Main Mode and Sub Mode Combinations Naga Bhavani Akella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox