Diff between 36d58cdd1b1f4efd465f527549365a786904ff02 and 8240f36f3b3e749c2fba9a5f638fda51c71abca1

Changed Files

File Additions Deletions Status
monitor/control.c +46 -0 modified

Full Patch

diff --git a/monitor/control.c b/monitor/control.c
index c808a84..083f65d 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -540,6 +540,46 @@ static void mgmt_new_csrk(uint16_t len, const void *buf)
 	packet_hexdump(buf, len);
 }
 
+static void mgmt_device_added(uint16_t len, const void *buf)
+{
+	const struct mgmt_ev_device_added *ev = buf;
+	char str[18];
+
+	if (len < sizeof(*ev)) {
+		printf("* Malformed Device Added control\n");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, str);
+
+	printf("@ Device Added: %s (%d) %d\n", str, ev->addr.type, ev->action);
+
+	buf += sizeof(*ev);
+	len -= sizeof(*ev);
+
+	packet_hexdump(buf, len);
+}
+
+static void mgmt_device_removed(uint16_t len, const void *buf)
+{
+	const struct mgmt_ev_device_removed *ev = buf;
+	char str[18];
+
+	if (len < sizeof(*ev)) {
+		printf("* Malformed Device Removed control\n");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, str);
+
+	printf("@ Device Removed: %s (%d)\n", str, ev->addr.type);
+
+	buf += sizeof(*ev);
+	len -= sizeof(*ev);
+
+	packet_hexdump(buf, len);
+}
+
 void control_message(uint16_t opcode, const void *data, uint16_t size)
 {
 	switch (opcode) {
@@ -612,6 +652,12 @@ void control_message(uint16_t opcode, const void *data, uint16_t size)
 	case MGMT_EV_NEW_CSRK:
 		mgmt_new_csrk(size, data);
 		break;
+	case MGMT_EV_DEVICE_ADDED:
+		mgmt_device_added(size, data);
+		break;
+	case MGMT_EV_DEVICE_REMOVED:
+		mgmt_device_removed(size, data);
+		break;
 	default:
 		printf("* Unknown control (code %d len %d)\n", opcode, size);
 		packet_hexdump(data, size);