monitor/att: Add decoding support for CSIP
authorSathish Narasimman <sathish.narasimman@intel.com>
Tue, 22 Nov 2022 10:12:31 +0000 (15:42 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 10:11:34 +0000 (15:41 +0530)
This adds decoding support for CSIS attributes:

> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0017 Type: Set Identity Resolving Key (0x2b84)
< ACL Data TX: Handle 3585 flags 0x00 dlen 22
      ATT: Read Response (0x0b) len 17
        Value: 01761fae703ed681f0c50b34155b6434fb
        Handle: 0x0017 Type: Set Identity Resolving Key (0x2b84)
          SIRK: 01761fae703ed681f0c50b34155b6434fb
> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x001b Type: Set Member Lock (0x2b86)
< ACL Data TX: Handle 3585 flags 0x00 dlen 6
      ATT: Read Response (0x0b) len 1
        Value: 01
        Handle: 0x001b Type: Set Member Lock (0x2b86)
            Locked (0x01)
> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x001e Type: Set Member Rank (0x2b87)
< ACL Data TX: Handle 3585 flags 0x00 dlen 6
      ATT: Read Response (0x0b) len 1
        Value: 01
        Handle: 0x001e Type: Set Member Rank (0x2b87)
            Rank: 0x01

monitor/att.c

index db68187..20162e6 100644 (file)
@@ -1732,6 +1732,85 @@ static void pac_context_notify(const struct l2cap_frame *frame)
        print_pac_context(frame);
 }
 
+static void csip_rank_read(const struct l2cap_frame *frame)
+{
+       uint8_t rank;
+
+       if (!l2cap_frame_get_u8((void *)frame, &rank)) {
+               print_text(COLOR_ERROR, "Rank: invalid size");
+               goto done;
+       }
+
+       print_field("    Rank: 0x%02x", rank);
+
+done:
+       if (frame->size)
+               print_hex_field("  Data", frame->data, frame->size);
+}
+
+static void csip_lock_read(const struct l2cap_frame *frame)
+{
+       uint8_t lock;
+
+       if (!l2cap_frame_get_u8((void *)frame, &lock)) {
+               print_text(COLOR_ERROR, "Lock: invalid size");
+               goto done;
+       }
+
+       switch (lock) {
+       case 0x01:
+               print_field("    Locked (0x%02x)", lock);
+               break;
+       case 0x02:
+               print_field("    Unlocked (0x%02x)", lock);
+               break;
+       default:
+               print_field("    RFU (0x%02x)", lock);
+               break;
+       }
+
+done:
+       if (frame->size)
+               print_hex_field("  Data", frame->data, frame->size);
+}
+
+static void print_csip_size(const struct l2cap_frame *frame)
+{
+       uint8_t size;
+
+       if (!l2cap_frame_get_u8((void *)frame, &size)) {
+               print_text(COLOR_ERROR, "Size: invalid size");
+               goto done;
+       }
+       print_field("    Size: 0x%02x", size);
+
+done:
+       if (frame->size)
+               print_hex_field("  Data", frame->data, frame->size);
+}
+
+static void csip_size_read(const struct l2cap_frame *frame)
+{
+       print_csip_size(frame);
+}
+
+static void csip_size_notify(const struct l2cap_frame *frame)
+{
+       print_csip_size(frame);
+}
+
+static void csip_sirk_read(const struct l2cap_frame *frame)
+{
+       if (frame->size)
+               print_hex_field("  SIRK", frame->data, frame->size);
+}
+
+static void csip_sirk_notify(const struct l2cap_frame *frame)
+{
+       if (frame->size)
+               print_hex_field("  SIRK", frame->data, frame->size);
+}
+
 static void print_vcs_state(const struct l2cap_frame *frame)
 {
        uint8_t vol_set, mute, chng_ctr;
@@ -2412,6 +2491,12 @@ struct gatt_handler {
        GATT_HANDLER(0x2b7d, vol_state_read, NULL, vol_state_notify),
        GATT_HANDLER(0x2b7e, NULL, vol_cp_write, NULL),
        GATT_HANDLER(0x2b7f, vol_flag_read, NULL, vol_flag_notify),
+
+       GATT_HANDLER(0x2b84, csip_sirk_read, NULL, csip_sirk_notify),
+       GATT_HANDLER(0x2b85, csip_size_read, NULL, csip_size_notify),
+       GATT_HANDLER(0x2b86, csip_lock_read, NULL, NULL),
+       GATT_HANDLER(0x2b87, csip_rank_read, NULL, NULL),
+
        GATT_HANDLER(0x2b93, mp_name_read, NULL, mp_name_notify),
        GATT_HANDLER(0x2b96, NULL, NULL, track_changed_notify),
        GATT_HANDLER(0x2b97, track_title_read, NULL, track_title_notify),