Diff between 5b7dc670216b366ba0d6e8407233ac861e51b5e1 and 5784a830bf1f98c6b70da50de5364964551d45a4

Changed Files

File Additions Deletions Status
monitor/display.h +9 -6 modified
monitor/l2cap.c +11 -10 modified
monitor/packet.c +6 -9 modified

Full Patch

diff --git a/monitor/display.h b/monitor/display.h
index 28ea9fe..d7269ae 100644
--- a/monitor/display.h
+++ b/monitor/display.h
@@ -40,14 +40,17 @@ bool use_color(void);
 
 #define COLOR_ERROR	"\x1B[1;31m"
 
-#define print_indent(indent, color, fmt, args...) do { \
-	printf("%*c%s" fmt "%s\n", (indent), ' ', \
-		use_color() ? (color) : "", ## args, \
-		use_color() ? COLOR_OFF : ""); \
+#define print_indent(indent, color, prefix, title, fmt, args...) do { \
+	printf("%*c%s%s%s%s" fmt "\n", (indent), ' ', \
+		use_color() ? (color) : "", prefix, title, \
+		use_color() ? COLOR_OFF : "", ## args); \
 } while (0);
 
-#define print_text(color, fmt, args...) print_indent(8, color, fmt, ## args)
-#define print_field(fmt, args...) print_indent(8, COLOR_OFF, fmt, ## args)
+#define print_text(color, fmt, args...) \
+			print_indent(8, color, "", "", fmt, ## args)
+
+#define print_field(fmt, args...) \
+			print_indent(8, COLOR_OFF, "", "", fmt, ## args)
 
 int num_columns(void);
 
diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index dabd04a..8fbfc57 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -445,9 +445,9 @@ static void sig_packet(bool in, const void *data, uint16_t size)
 			opcode_str = "Unknown";
 		}
 
-		print_indent(6, opcode_color,
-				"L2CAP: %s (0x%2.2x) ident %d len %d",
-				opcode_str, hdr->code, hdr->ident, len);
+		print_indent(6, opcode_color, "L2CAP: ", opcode_str,
+					" (0x%2.2x) ident %d len %d",
+					hdr->code, hdr->ident, len);
 
 		if (!opcode_data || !opcode_data->func) {
 			packet_hexdump(data, len);
@@ -559,8 +559,8 @@ static void amp_packet(const void *data, uint16_t size)
 	else
 		opcode_str = "Unknown";
 
-	print_indent(8, COLOR_CYAN, "AMP: %s (0x%2.2x) ident %d len %d",
-					opcode_str, opcode, ident, len);
+	print_indent(6, COLOR_CYAN, "AMP: ", opcode_str,
+			" (0x%2.2x) ident %d len %d", opcode, ident, len);
 
 	packet_hexdump(data + 6, size - 8);
 }
@@ -630,8 +630,8 @@ static void att_packet(const void *data, uint16_t size)
 	else
 		opcode_str = "Unknown";
 
-	print_indent(8, COLOR_CYAN, "ATT: %s (0x%2.2x) len %d",
-					opcode_str, opcode, size - 1);
+	print_indent(6, COLOR_CYAN, "ATT: ", opcode_str,
+				" (0x%2.2x) len %d", opcode, size - 1);
 
 	packet_hexdump(data + 1, size - 1);
 }
@@ -684,8 +684,8 @@ static void smp_packet(const void *data, uint16_t size)
 	else
 		opcode_str = "Unknown";
 
-	print_indent(8, COLOR_CYAN, "SMP: %s (0x%2.2x) len %d",
-					opcode_str, opcode, size - 1);
+	print_indent(6, COLOR_CYAN, "SMP: ", opcode_str,
+				" (0x%2.2x) len %d", opcode, size - 1);
 
 	packet_hexdump(data + 1, size - 1);
 }
@@ -728,7 +728,8 @@ void l2cap_packet(uint16_t handle, bool in, const void *data, uint16_t size)
 		smp_packet(data, len);
 		break;
 	default:
-		print_field("Channel: %d len %d", cid, len);
+		print_indent(6, COLOR_CYAN, "Channel:", "",
+						" %d len %d", cid, len);
 		packet_hexdump(data, len);
 		break;
 	}
diff --git a/monitor/packet.c b/monitor/packet.c
index d215400..18b4c59 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -3375,9 +3375,8 @@ static void cmd_complete_evt(const void *data, uint8_t size)
 		opcode_str = "Unknown";
 	}
 
-	print_field("%s%s%s (0x%2.2x|0x%4.4x) ncmd %d",
-			use_color() ? opcode_color : "", opcode_str,
-			use_color() ? COLOR_OFF : "", ogf, ocf, evt->ncmd);
+	print_indent(6, opcode_color, "", opcode_str,
+			" (0x%2.2x|0x%4.4x) ncmd %d", ogf, ocf, evt->ncmd);
 
 	if (!opcode_data->rsp_func) {
 		packet_hexdump(data + 3, size - 3);
@@ -3426,9 +3425,8 @@ static void cmd_status_evt(const void *data, uint8_t size)
 		opcode_str = "Unknown";
 	}
 
-	print_field("%s%s%s (0x%2.2x|0x%4.4x) ncmd %d",
-			use_color() ? opcode_color : "", opcode_str,
-			use_color() ? COLOR_OFF : "", ogf, ocf, evt->ncmd);
+	print_indent(6, opcode_color, "", opcode_str,
+			" (0x%2.2x|0x%4.4x) ncmd %d", ogf, ocf, evt->ncmd);
 
 	print_status(evt->status);
 }
@@ -3980,9 +3978,8 @@ static void le_meta_event_evt(const void *data, uint8_t size)
 		subevent_str = "Unknown";
 	}
 
-	print_field("Subevent: %s%s%s (0x%2.2x)",
-			use_color() ? subevent_color : "", subevent_str,
-			use_color() ? COLOR_OFF : "", subevent);
+	print_indent(6, subevent_color, "", subevent_str,
+					" (0x%2.2x)", subevent);
 
 	if (!subevent_data || !subevent_data->func) {
 		packet_hexdump(data + 1, size - 1);