Skip to contentSkip to conversation

monitor/att: Add initial decoding for HIDS attributes

PATCH Applied Luiz Augusto von Dentz 3 participants 4 messages Jan 30 – Feb 2 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 monitor/att: Add initial decoding for HIDS attributes

From: Luiz Augusto von Dentz <[email protected]>

This adds decoders to HID Information and HID Control Point characteristics.

---
 monitor/att.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
monitor/att.c +82 -0
index 24aaa264c2bd..b77ffb66e89d 100644
@@ -4506,6 +4506,87 @@ static void ras_data_overwritten_notify(const struct l2cap_frame *frame)
 	GATT_HANDLER(0x2c19, ras_data_overwritten_read, NULL, \
 					ras_data_overwritten_notify)
 
+static const struct bitfield_data hog_info_flags[] = {
+	{  0, "RemoteWake (0x01)"		},
+	{  1, "NormallyConnectable (0x02)"	},
+	{ }
+};
+
+static void hog_info_read(const struct l2cap_frame *frame)
+{
+	uint16_t bcdhid;
+	uint8_t bcc, flags, mask;
+
+	if (!l2cap_frame_get_le16((void *)frame, &bcdhid)) {
+		print_text(COLOR_ERROR, "    bcdHID: invalid size");
+		goto done;
+	}
+
+	print_field("    bcdHID: 0x%4.4x", bcdhid);
+
+	if (!l2cap_frame_get_u8((void *)frame, &bcc)) {
+		print_text(COLOR_ERROR, "    bCountryCode: invalid size");
+		goto done;
+	}
+
+	print_field("    bCountryCode: 0x%2.2x", bcc);
+
+	if (!l2cap_frame_get_u8((void *)frame, &flags)) {
+		print_text(COLOR_ERROR, "    Flags: invalid size");
+		goto done;
+	}
+
+	print_field("    Flags: 0x%2.2x", flags);
+
+	mask = print_bitfield(4, flags, hog_info_flags);
+	if (mask)
+		print_text(COLOR_WHITE_BG, "    Unknown fields (0x%2.2x)",
+								mask);
+
+done:
+	if (frame->size)
+		print_hex_field("  Data", frame->data, frame->size);
+}
+
+static const char *hog_cmd_str(uint8_t opcode)
+{
+	switch (opcode) {
+	case 0x00:
+		return "Suspend";
+	case 0x01:
+		return "Exit Suspend";
+	default:
+		return NULL;
+	}
+}
+
+static void hog_cp_write(const struct l2cap_frame *frame)
+{
+	uint8_t opcode;
+	const char *str;
+
+	if (!l2cap_frame_get_u8((void *)frame, &opcode)) {
+		print_text(COLOR_ERROR, "    Opcode: invalid size");
+		goto done;
+	}
+
+	str = hog_cmd_str(opcode);
+	if (!str) {
+		print_field("    Opcode: Reserved (0x%2.2x)", opcode);
+		goto done;
+	}
+
+	print_field("    Opcode: %s (0x%2.2x)", str, opcode);
+
+done:
+	if (frame->size)
+		print_hex_field("  Data", frame->data, frame->size);
+}
+
+#define HIDS \
+	GATT_HANDLER(0x2a4a, hog_info_read, NULL, NULL), \
+	GATT_HANDLER(0x2a4c, NULL, hog_cp_write, NULL)
+
 #define GATT_HANDLER(_uuid, _read, _write, _notify) \
 { \
 	.uuid = { \
@@ -4588,6 +4669,7 @@ static const struct gatt_handler {
 	GATT_HANDLER(0x2bc1, incoming_call_read, NULL, incoming_call_notify),
 	GATT_HANDLER(0x2bc2, call_friendly_name_read, NULL,
 					call_friendly_name_notify),
+	HIDS,
 	GMAS,
 	RAS
 };
Signature · 1 line
2.52.0
author maintainer
#1 lore raw

PATCH 2/2 monitor/att: Fix printing data twice

From: Luiz Augusto von Dentz <[email protected]>

This fixes ATT Read Response printing the data read twice by checking if there is a dedicated decoder then skip printing the value since it is latter printed by att_read_func:

== Before ==

Quoted 1 line

ACL Data RX: Handle 2048 flags 0x02 dlen 7

      ATT: Read Response (0x0b) len 2
        Value[2]:
        11 01
        Handle: 0x0030 Type: Report Reference (0x2908)
        Value Handle: 0x002e Type: Report (0x2a4d)
        Value[2]:
        11 01

== After ==

Quoted 1 line

ACL Data RX: Handle 2048 flags 0x02 dlen 7

      ATT: Read Response (0x0b) len 2
        Handle: 0x0030 Type: Report Reference (0x2908)
        Value Handle: 0x002e Type: Report (0x2a4d)
        Value[2]:
        11 01
---
 monitor/att.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
monitor/att.c +3 -3
index b77ffb66e89d..e76cb44d28f5 100644
@@ -4989,11 +4989,11 @@ static void att_read_rsp(const struct l2cap_frame *frame)
 {
 	struct att_read *read;
 
-	print_hex_field("Value", frame->data, frame->size);
-
 	read = att_get_read(frame);
-	if (!read)
+	if (!read) {
+		print_hex_field("Value", frame->data, frame->size);
 		return;
+	}
 
 	/* Check if the data size is equal to the MTU then read long procedure
 	 * maybe used.
Signature · 1 line
2.52.0
#2 lore raw
In reply to Luiz Augusto von Dentz

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=1049069

---Test result---

Test Summary:

CheckPatch                    PENDING   0.36 seconds
GitLint                       PENDING   0.33 seconds
BuildEll                      PASS      19.86 seconds
BluezMake                     PASS      640.73 seconds
MakeCheck                     PASS      18.18 seconds
MakeDistcheck                 PASS      237.68 seconds
CheckValgrind                 PASS      289.67 seconds
CheckSmatch                   PASS      346.94 seconds
bluezmakeextell               PASS      180.44 seconds
IncrementalBuild              PENDING   0.30 seconds
ScanBuild                     PASS      993.59 seconds

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

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

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Fri, 30 Jan 2026 10:56:36 -0500 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This adds decoders to HID Information and HID Control Point characteristics.

---
 monitor/att.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

Here is the summary with links:
- [BlueZ,v1,1/2] monitor/att: Add initial decoding for HIDS attributes

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ba27f7a12246
  - [BlueZ,v1,2/2] monitor/att: Fix printing data twice
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4c963f21e56a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html