OSDN Git Service

monitor: Add support for decoding keypress notification command
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 22 Oct 2013 22:27:38 +0000 (15:27 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 22 Oct 2013 22:27:38 +0000 (15:27 -0700)
monitor/bt.h
monitor/packet.c

index 5914041..2aec950 100644 (file)
@@ -946,6 +946,16 @@ struct bt_hci_cmd_enhanced_flush {
        uint8_t  type;
 } __attribute__ ((packed));
 
+#define BT_HCI_CMD_SEND_KEYPRESS_NOTIFY                0x0c60
+struct bt_hci_cmd_send_keypress_notify {
+       uint8_t  bdaddr[6];
+       uint8_t  type;
+} __attribute__ ((packed));
+struct bt_hci_rsp_send_keypress_notify {
+       uint8_t  status;
+       uint8_t  bdaddr[6];
+} __attribute__ ((packed));
+
 #define BT_HCI_CMD_SET_EVENT_MASK_PAGE2                0x0c63
 struct bt_hci_cmd_set_event_mask_page2 {
        uint8_t  mask[8];
index 07028e7..5721988 100644 (file)
@@ -4071,6 +4071,45 @@ static void enhanced_flush_cmd(const void *data, uint8_t size)
        print_field("Type: %s (0x%2.2x)", str, cmd->type);
 }
 
+static void send_keypress_notify_cmd(const void *data, uint8_t size)
+{
+       const struct bt_hci_cmd_send_keypress_notify *cmd = data;
+       const char *str;
+
+       print_bdaddr(cmd->bdaddr);
+
+       switch (cmd->type) {
+       case 0x00:
+               str = "Passkey entry started";
+               break;
+       case 0x01:
+               str = "Passkey digit entered";
+               break;
+       case 0x02:
+               str = "Passkey digit erased";
+               break;
+       case 0x03:
+               str = "Passkey cleared";
+               break;
+       case 0x04:
+               str = "Passkey entry completed";
+               break;
+       default:
+               str = "Reserved";
+               break;
+       }
+
+       print_field("Type: %s (0x%2.2x)", str, cmd->type);
+}
+
+static void send_keypress_notify_rsp(const void *data, uint8_t size)
+{
+       const struct bt_hci_rsp_send_keypress_notify *rsp = data;
+
+       print_status(rsp->status);
+       print_bdaddr(rsp->bdaddr);
+}
+
 static void set_event_mask_page2_cmd(const void *data, uint8_t size)
 {
        const struct bt_hci_cmd_set_event_mask_page2 *cmd = data;
@@ -5262,7 +5301,9 @@ static const struct opcode_data opcode_table[] = {
        { 0x0c5b, 147, "Write Default Erroneous Reporting" },
        { 0x0c5f, 158, "Enhanced Flush",
                                enhanced_flush_cmd, 3, true },
-       { 0x0c60, 162, "Send Keypress Notification" },
+       { 0x0c60, 162, "Send Keypress Notification",
+                               send_keypress_notify_cmd, 7, true,
+                               send_keypress_notify_rsp, 7, true },
        { 0x0c61, 176, "Read Logical Link Accept Timeout" },
        { 0x0c62, 177, "Write Logical Link Accept Timeout" },
        { 0x0c63, 178, "Set Event Mask Page 2",