All of lore.kernel.org
 help / color / mirror / Atom feed
* [BlueZ PATCH 1/3] monitor: Decode ADV Monitor read feature command
@ 2020-10-29 10:09 Howard Chung
  2020-10-29 10:09 ` [BlueZ PATCH 2/3] monitor: Decode Add ADV monitor command Howard Chung
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Howard Chung @ 2020-10-29 10:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: alainm, luiz.dentz, mcchou, mmandlik, Howard Chung

Add support for Read Advertisement Monitor Features mgmt operation.

@ MGMT Command: Read Advertisement Monitor Features (0x0051) plen 0
@ MGMT Event: Command Complete (0x0001) plen 20
      Read Advertisement Monitor Features (0x0051) plen 17
        Status: Success (0x00)
        Supported Features: 0x00000000
        Enabled Features: 0x00000000
        Max number of handles: 32
        Max number of patterns: 16
        Number of handles: 2
          Handle: 1
          Handle: 3

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---

 monitor/packet.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index d83552f74f5b..2516cf970f9f 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -88,6 +88,7 @@
 #define COLOR_UNKNOWN_ADV_FLAG		COLOR_WHITE_BG
 #define COLOR_UNKNOWN_PHY		COLOR_WHITE_BG
 #define COLOR_UNKNOWN_ADDED_DEVICE_FLAG	COLOR_WHITE_BG
+#define COLOR_UNKNOWN_ADVMON_FEATURES	COLOR_WHITE_BG
 
 #define COLOR_PHY_PACKET		COLOR_BLUE
 
@@ -13151,6 +13152,50 @@ static void mgmt_set_device_flags_rsp(const void *data, uint16_t size)
 	mgmt_print_address(data, type);
 }
 
+static const struct bitfield_data mgmt_adv_monitor_features_table[] = {
+	{ 1, "OR Patterns"	},
+	{ }
+};
+
+static void mgmt_print_adv_monitor_features(char *label, uint32_t flags)
+{
+	uint32_t mask;
+
+	print_field("%s: 0x%8.8x", label, flags);
+	mask = print_bitfield(2, flags, mgmt_adv_monitor_features_table);
+	if (mask)
+		print_text(COLOR_UNKNOWN_ADVMON_FEATURES,
+			   "  Unknown Flags (0x%8.8x)", mask);
+}
+
+static void mgmt_print_adv_monitor_handles(const void *data, uint8_t len)
+{
+	uint8_t idx = 0;
+
+	while (idx + 2 <= len) {
+		print_field("  Handle: %d", get_le16(data + idx));
+		idx += 2;
+	}
+}
+
+static void mgmt_read_adv_monitor_features_rsp(const void *data, uint16_t size)
+{
+	uint32_t supported_features = get_le32(data);
+	uint32_t enabled_features = get_le32(data + 4);
+	uint16_t max_num_handles = get_le16(data + 8);
+	uint8_t max_num_patterns = get_u8(data + 10);
+	uint16_t num_handles = get_le16(data + 11);
+
+	mgmt_print_adv_monitor_features("Supported Features",
+							supported_features);
+	mgmt_print_adv_monitor_features("Enabled Features",
+							enabled_features);
+	print_field("Max number of handles: %d", max_num_handles);
+	print_field("Max number of patterns: %d", max_num_patterns);
+	print_field("Number of handles: %d", num_handles);
+	mgmt_print_adv_monitor_handles(data + 13, size - 13);
+}
+
 struct mgmt_data {
 	uint16_t opcode;
 	const char *str;
@@ -13382,6 +13427,9 @@ static const struct mgmt_data mgmt_command_table[] = {
 	{ 0x0050, "Set Device Flags",
 				mgmt_set_device_flags_cmd, 11, true,
 				mgmt_set_device_flags_rsp, 7, true},
+	{ 0x0051, "Read Advertisement Monitor Features",
+				mgmt_null_cmd, 0, true,
+				mgmt_read_adv_monitor_features_rsp, 13, false},
 	{ }
 };
 
-- 
2.29.1.341.ge80a0c044ae-goog


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

* [BlueZ PATCH 2/3] monitor: Decode Add ADV monitor command
  2020-10-29 10:09 [BlueZ PATCH 1/3] monitor: Decode ADV Monitor read feature command Howard Chung
@ 2020-10-29 10:09 ` Howard Chung
  2020-10-29 10:09 ` [BlueZ PATCH 3/3] monitor: Decode Remove ADV Monitor Howard Chung
  2020-10-29 10:38 ` [BlueZ,1/3] monitor: Decode ADV Monitor read feature command bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: Howard Chung @ 2020-10-29 10:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: alainm, luiz.dentz, mcchou, mmandlik, Howard Chung

Add support for Add Advertisement Monitor MGMT command and event.

@ MGMT Command: Add Advertisement Monitor (0x0052) plen 69
        Number of patterns: 2
          Pattern 1:
            AD type: 0
            Offset: 1
            Length: 2
            Value : ...
          Pattern 2:
            AD type: 1
            Offset: 10
            Length: 4
            Value : ...
@ MGMT Event: Advertisement Monitor Added (0x002b) plen 2
        Handle: 1
@ MGMT Event: Command Complete (0x0001) plen 5
      Add Advertisement Monitor (0x0052) plen 2
        Status: Success (0x00)
        Handle: 1

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---

 monitor/packet.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index 2516cf970f9f..b3a6ed24d5fc 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -13196,6 +13196,42 @@ static void mgmt_read_adv_monitor_features_rsp(const void *data, uint16_t size)
 	mgmt_print_adv_monitor_handles(data + 13, size - 13);
 }
 
+static void mgmt_print_adv_monitor_patterns(const void *data, uint8_t len)
+{
+	uint8_t data_idx = 0, pattern_idx = 1;
+
+	/* Reference: struct mgmt_adv_pattern in lib/mgmt.h. */
+	while (data_idx + 34 <= len) {
+		uint8_t ad_type = get_u8(data + data_idx);
+		uint8_t offset = get_u8(data + data_idx + 1);
+		uint8_t length = get_u8(data + data_idx + 2);
+
+		print_field("  Pattern %d:", pattern_idx);
+		print_field("    AD type: %d", ad_type);
+		print_field("    Offset: %d", offset);
+		print_field("    Length: %d", length);
+		print_hex_field("    Value ", data + data_idx + 3, 31);
+
+		pattern_idx += 1;
+		data_idx += 34;
+	}
+}
+
+static void mgmt_add_adv_monitor_patterns_cmd(const void *data, uint16_t size)
+{
+	uint8_t pattern_count = get_u8(data);
+
+	print_field("Number of patterns: %d", pattern_count);
+	mgmt_print_adv_monitor_patterns(data + 1, size - 1);
+}
+
+static void mgmt_add_adv_monitor_patterns_rsp(const void *data, uint16_t size)
+{
+	uint16_t handle = get_le16(data);
+
+	print_field("Handle: %d", handle);
+}
+
 struct mgmt_data {
 	uint16_t opcode;
 	const char *str;
@@ -13430,6 +13466,9 @@ static const struct mgmt_data mgmt_command_table[] = {
 	{ 0x0051, "Read Advertisement Monitor Features",
 				mgmt_null_cmd, 0, true,
 				mgmt_read_adv_monitor_features_rsp, 13, false},
+	{ 0x0052, "Add Advertisement Monitor",
+				mgmt_add_adv_monitor_patterns_cmd, 1, false,
+				mgmt_add_adv_monitor_patterns_rsp, 2, true},
 	{ }
 };
 
@@ -13834,6 +13873,13 @@ static void mgmt_device_flags_changed_evt(const void *data, uint16_t size)
 	mgmt_print_added_device_flags("Current Flags", current_flags);
 }
 
+static void mgmt_adv_monitor_added_evt(const void *data, uint16_t size)
+{
+	uint16_t handle = get_le16(data);
+
+	print_field("Handle: %d", handle);
+}
+
 static void mgmt_controller_suspend_evt(const void *data, uint16_t size)
 {
 	uint8_t state = get_u8(data);
@@ -13963,6 +14009,8 @@ static const struct mgmt_data mgmt_event_table[] = {
 			mgmt_exp_feature_changed_evt, 20, true },
 	{ 0x002a, "Device Flags Changed",
 			mgmt_device_flags_changed_evt, 15, true },
+	{ 0x002b, "Advertisement Monitor Added",
+			mgmt_adv_monitor_added_evt, 2, true },
 	{ 0x002d, "Controller Suspended",
 			mgmt_controller_suspend_evt, 1, true },
 	{ 0x002e, "Controller Resumed",
-- 
2.29.1.341.ge80a0c044ae-goog


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

* [BlueZ PATCH 3/3] monitor: Decode Remove ADV Monitor
  2020-10-29 10:09 [BlueZ PATCH 1/3] monitor: Decode ADV Monitor read feature command Howard Chung
  2020-10-29 10:09 ` [BlueZ PATCH 2/3] monitor: Decode Add ADV monitor command Howard Chung
@ 2020-10-29 10:09 ` Howard Chung
  2020-10-29 10:38 ` [BlueZ,1/3] monitor: Decode ADV Monitor read feature command bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: Howard Chung @ 2020-10-29 10:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: alainm, luiz.dentz, mcchou, mmandlik, Howard Chung

Add support for Remove Advertisement Monitor MGMT command and event.

@ MGMT Command: Remove Advertisement Monitor (0x0053) plen 2
	Handle: 1
@ MGMT Event: Advertisement Monitor Added (0x002c) plen 2
        Handle: 1
@ MGMT Event: Command Complete (0x0001) plen 5
      Remove Advertisement Monitor (0x0053) plen 2
        Status: Success (0x00)
        Handle: 1

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---

 monitor/packet.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index b3a6ed24d5fc..dcbed9f0f287 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -13232,6 +13232,22 @@ static void mgmt_add_adv_monitor_patterns_rsp(const void *data, uint16_t size)
 	print_field("Handle: %d", handle);
 }
 
+static void mgmt_remove_adv_monitor_patterns_cmd(const void *data,
+								uint16_t size)
+{
+	uint16_t handle = get_le16(data);
+
+	print_field("Handle: %d", handle);
+}
+
+static void mgmt_remove_adv_monitor_patterns_rsp(const void *data,
+								uint16_t size)
+{
+	uint16_t handle = get_le16(data);
+
+	print_field("Handle: %d", handle);
+}
+
 struct mgmt_data {
 	uint16_t opcode;
 	const char *str;
@@ -13469,6 +13485,9 @@ static const struct mgmt_data mgmt_command_table[] = {
 	{ 0x0052, "Add Advertisement Monitor",
 				mgmt_add_adv_monitor_patterns_cmd, 1, false,
 				mgmt_add_adv_monitor_patterns_rsp, 2, true},
+	{ 0x0053, "Remove Advertisement Monitor",
+				mgmt_remove_adv_monitor_patterns_cmd, 2, true,
+				mgmt_remove_adv_monitor_patterns_rsp, 2, true},
 	{ }
 };
 
@@ -13880,6 +13899,13 @@ static void mgmt_adv_monitor_added_evt(const void *data, uint16_t size)
 	print_field("Handle: %d", handle);
 }
 
+static void mgmt_adv_monitor_removed_evt(const void *data, uint16_t size)
+{
+	uint16_t handle = get_le16(data);
+
+	print_field("Handle: %d", handle);
+}
+
 static void mgmt_controller_suspend_evt(const void *data, uint16_t size)
 {
 	uint8_t state = get_u8(data);
@@ -14011,6 +14037,8 @@ static const struct mgmt_data mgmt_event_table[] = {
 			mgmt_device_flags_changed_evt, 15, true },
 	{ 0x002b, "Advertisement Monitor Added",
 			mgmt_adv_monitor_added_evt, 2, true },
+	{ 0x002c, "Advertisement Monitor Added",
+			mgmt_adv_monitor_removed_evt, 2, true },
 	{ 0x002d, "Controller Suspended",
 			mgmt_controller_suspend_evt, 1, true },
 	{ 0x002e, "Controller Resumed",
-- 
2.29.1.341.ge80a0c044ae-goog


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

* RE: [BlueZ,1/3] monitor: Decode ADV Monitor read feature command
  2020-10-29 10:09 [BlueZ PATCH 1/3] monitor: Decode ADV Monitor read feature command Howard Chung
  2020-10-29 10:09 ` [BlueZ PATCH 2/3] monitor: Decode Add ADV monitor command Howard Chung
  2020-10-29 10:09 ` [BlueZ PATCH 3/3] monitor: Decode Remove ADV Monitor Howard Chung
@ 2020-10-29 10:38 ` bluez.test.bot
  2020-10-29 17:40   ` Luiz Augusto von Dentz
  2 siblings, 1 reply; 5+ messages in thread
From: bluez.test.bot @ 2020-10-29 10:38 UTC (permalink / raw)
  To: linux-bluetooth, howardchung

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

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth


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

* Re: [BlueZ,1/3] monitor: Decode ADV Monitor read feature command
  2020-10-29 10:38 ` [BlueZ,1/3] monitor: Decode ADV Monitor read feature command bluez.test.bot
@ 2020-10-29 17:40   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2020-10-29 17:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Yun-hao Chung

Hi Howard,

On Thu, Oct 29, 2020 at 3:41 AM <bluez.test.bot@gmail.com> wrote:
>
> 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=372967
>
> ---Test result---
>
> ##############################
> Test: CheckPatch - PASS
>
> ##############################
> Test: CheckGitLint - PASS
>
> ##############################
> Test: CheckBuild - PASS
>
> ##############################
> Test: MakeCheck - PASS
>
>
>
> ---
> Regards,
> Linux Bluetooth
>

Applied, thanks.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2020-10-29 17:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 10:09 [BlueZ PATCH 1/3] monitor: Decode ADV Monitor read feature command Howard Chung
2020-10-29 10:09 ` [BlueZ PATCH 2/3] monitor: Decode Add ADV monitor command Howard Chung
2020-10-29 10:09 ` [BlueZ PATCH 3/3] monitor: Decode Remove ADV Monitor Howard Chung
2020-10-29 10:38 ` [BlueZ,1/3] monitor: Decode ADV Monitor read feature command bluez.test.bot
2020-10-29 17:40   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.