Diff between 55eeda7afd5dd0b6ea5581295bbfcbfd7a742804 and 368bf5cdf0639cb431369af9cfda37462a60e92a

Changed Files

File Additions Deletions Status
monitor/bt.h +30 -0 modified
monitor/packet.c +127 -34 modified

Full Patch

diff --git a/monitor/bt.h b/monitor/bt.h
index 1bb9048..430ebcd 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -1257,6 +1257,17 @@ struct bt_hci_evt_disconn_phy_link_complete {
 	uint8_t  reason;
 } __attribute__ ((packed));
 
+#define BT_HCI_EVT_PHY_LINK_LOSS_EARLY_WARNING	0x43
+struct bt_hci_evt_phy_link_loss_early_warning {
+	uint8_t  phy_handle;
+	uint8_t  reason;
+} __attribute__ ((packed));
+
+#define BT_HCI_EVT_PHY_LINK_RECOVERY		0x44
+struct bt_hci_evt_phy_link_recovery {
+	uint8_t  phy_handle;
+} __attribute__ ((packed));
+
 #define BT_HCI_EVT_LOGIC_LINK_COMPLETE		0x45
 struct bt_hci_evt_logic_link_complete {
 	uint8_t  status;
@@ -1272,6 +1283,12 @@ struct bt_hci_evt_disconn_logic_link_complete {
 	uint8_t  reason;
 } __attribute__ ((packed));
 
+#define BT_HCI_EVT_FLOW_SPEC_MODIFY_COMPLETE	0x47
+struct bt_hci_evt_flow_spec_modify_complete {
+	uint8_t  status;
+	uint16_t handle;
+} __attribute__ ((packed));
+
 #define BT_HCI_EVT_NUM_COMPLETED_DATA_BLOCKS	0x48
 struct bt_hci_evt_num_completed_data_blocks {
 	uint16_t total_num_blocks;
@@ -1281,6 +1298,19 @@ struct bt_hci_evt_num_completed_data_blocks {
 	uint16_t num_blocks;
 } __attribute__ ((packed));
 
+#define BT_HCI_EVT_SHORT_RANGE_MODE_CHANGE	0x4c
+struct bt_hci_evt_short_range_mode_change {
+	uint8_t  status;
+	uint8_t  phy_handle;
+	uint8_t  mode;
+} __attribute__ ((packed));
+
+#define BT_HCI_EVT_AMP_STATUS_CHANGE		0x4d
+struct bt_hci_evt_amp_status_change {
+	uint8_t  status;
+	uint8_t  amp_status;
+} __attribute__ ((packed));
+
 #define BT_HCI_EVT_LE_CONN_COMPLETE		0x01
 struct bt_hci_evt_le_conn_complete {
 	uint8_t  status;
diff --git a/monitor/packet.c b/monitor/packet.c
index 26d38e3..64037e8 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -909,6 +909,59 @@ static void print_service_type(uint8_t service_type)
 	print_field("Service type: %s (0x%2.2x)", str, service_type);
 }
 
+static void print_short_range_mode(uint8_t mode)
+{
+	const char *str;
+
+	switch (mode) {
+	case 0x00:
+		str = "Disabled";
+		break;
+	case 0x01:
+		str = "Enabled";
+		break;
+	default:
+		str = "Reserved";
+		break;
+	}
+
+	print_field("Short range mode: %s (0x%2.2x)", str, mode);
+}
+
+static void print_amp_status(uint8_t amp_status)
+{
+	const char *str;
+
+	switch (amp_status) {
+	case 0x00:
+		str = "Present";
+		break;
+	case 0x01:
+		str = "Bluetooth only";
+		break;
+	case 0x02:
+		str = "No capacity";
+		break;
+	case 0x03:
+		str = "Low capacity";
+		break;
+	case 0x04:
+		str = "Medium capacity";
+		break;
+	case 0x05:
+		str = "High capacity";
+		break;
+	case 0x06:
+		str = "Full capacity";
+		break;
+	default:
+		str = "Reserved";
+		break;
+	}
+
+	print_field("AMP status: %s (0x%2.2x)", str, amp_status);
+}
+
 static void print_num_resp(uint8_t num_resp)
 {
 	print_field("Num responses: %d", num_resp);
@@ -2512,35 +2565,7 @@ static void read_local_amp_info_rsp(const void *data, uint8_t size)
 	const char *str;
 
 	print_status(rsp->status);
-
-	switch (rsp->amp_status) {
-	case 0x00:
-		str = "Present";
-		break;
-	case 0x01:
-		str = "Bluetooth only";
-		break;
-	case 0x02:
-		str = "No capacity";
-		break;
-	case 0x03:
-		str = "Low capacity";
-		break;
-	case 0x04:
-		str = "Medium capacity";
-		break;
-	case 0x05:
-		str = "High capacity";
-		break;
-	case 0x06:
-		str = "Full capacity";
-		break;
-	default:
-		str = "Reserved";
-		break;
-	}
-
-	print_field("AMP status: %s (0x%2.2x)", str, rsp->amp_status);
+	print_amp_status(rsp->amp_status);
 
 	print_field("Total bandwidth: %d kbps", btohl(rsp->total_bw));
 	print_field("Max guaranteed bandwidth: %d kbps", btohl(rsp->max_bw));
@@ -3896,6 +3921,44 @@ static void disconn_phy_link_complete_evt(const void *data, uint8_t size)
 	print_reason(evt->reason);
 }
 
+static void phy_link_loss_early_warning_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_evt_phy_link_loss_early_warning *evt = data;
+	const char *str;
+
+	print_phy_handle(evt->phy_handle);
+
+	switch (evt->reason) {
+	case 0x00:
+		str = "Unknown";
+		break;
+	case 0x01:
+		str = "Range related";
+		break;
+	case 0x02:
+		str = "Bandwidth related";
+		break;
+	case 0x03:
+		str = "Resolving conflict";
+		break;
+	case 0x04:
+		str = "Interference";
+		break;
+	default:
+		str = "Reserved";
+		break;
+	}
+
+	print_field("Reason: %s (0x%2.2x)", str, evt->reason);
+}
+
+static void phy_link_recovery_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_evt_phy_link_recovery *evt = data;
+
+	print_phy_handle(evt->phy_handle);
+}
+
 static void logic_link_complete_evt(const void *data, uint8_t size)
 {
 	const struct bt_hci_evt_logic_link_complete *evt = data;
@@ -3915,6 +3978,14 @@ static void disconn_logic_link_complete_evt(const void *data, uint8_t size)
 	print_reason(evt->reason);
 }
 
+static void flow_spec_modify_complete_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_evt_flow_spec_modify_complete *evt = data;
+
+	print_status(evt->status);
+	print_handle(evt->handle);
+}
+
 static void num_completed_data_blocks_evt(const void *data, uint8_t size)
 {
 	const struct bt_hci_evt_num_completed_data_blocks *evt = data;
@@ -3929,6 +4000,23 @@ static void num_completed_data_blocks_evt(const void *data, uint8_t size)
 		packet_hexdump(data + sizeof(*evt), size - sizeof(*evt));
 }
 
+static void short_range_mode_change_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_evt_short_range_mode_change *evt = data;
+
+	print_status(evt->status);
+	print_phy_handle(evt->phy_handle);
+	print_short_range_mode(evt->mode);
+}
+
+static void amp_status_change_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_evt_amp_status_change *evt = data;
+
+	print_status(evt->status);
+	print_amp_status(evt->amp_status);
+}
+
 static void le_conn_complete_evt(const void *data, uint8_t size)
 {
 	const struct bt_hci_evt_le_conn_complete *evt = data;
@@ -4216,20 +4304,25 @@ static const struct event_data event_table[] = {
 				channel_selected_evt, 1, true },
 	{ 0x42, "Disconnect Physical Link Complete",
 				disconn_phy_link_complete_evt, 3, true },
-	{ 0x43, "Physical Link Loss Early Warning"	},
-	{ 0x44, "Physical Link Recovery"		},
+	{ 0x43, "Physical Link Loss Early Warning",
+				phy_link_loss_early_warning_evt, 2, true },
+	{ 0x44, "Physical Link Recovery",
+				phy_link_recovery_evt, 1, true },
 	{ 0x45, "Logical Link Complete",
 				logic_link_complete_evt, 5, true },
 	{ 0x46, "Disconnect Logical Link Complete",
 				disconn_logic_link_complete_evt, 4, true },
-	{ 0x47, "Flow Spec Modify Complete"		},
+	{ 0x47, "Flow Spec Modify Complete",
+				flow_spec_modify_complete_evt, 3, true },
 	{ 0x48, "Number Of Completed Data Blocks",
 				num_completed_data_blocks_evt, 3, false },
 	{ 0x49, "AMP Start Test"			},
 	{ 0x4a, "AMP Test End"				},
 	{ 0x4b, "AMP Receiver Report"			},
-	{ 0x4c, "Short Range Mode Change Complete"	},
-	{ 0x4d, "AMP Status Change"			},
+	{ 0x4c, "Short Range Mode Change Complete",
+				short_range_mode_change_evt, 3, true },
+	{ 0x4d, "AMP Status Change",
+				amp_status_change_evt, 2, true },
 	{ 0xfe, "Testing"				},
 	{ 0xff, "Vendor"				},
 	{ }