Diff between 179652b272027cff67e33bd1ff89b3eebb894724 and e637d4e32b81f20f9574c4aed8c970cf7323b952

Changed Files

File Additions Deletions Status
mgmt/main.c +22 -0 modified

Full Patch

diff --git a/mgmt/main.c b/mgmt/main.c
index 27da639..3379812 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
@@ -339,6 +339,26 @@ static int mgmt_connected(int mgmt_sk, uint16_t index, bool connected,
 
 	return 0;
 }
+
+static int mgmt_conn_failed(int mgmt_sk, uint16_t index,
+				struct mgmt_ev_connect_failed *ev,
+				uint16_t len)
+{
+	char addr[18];
+
+	if (len != sizeof(*ev)) {
+		fprintf(stderr,
+			"Invalid connect_failed event length (%u bytes)\n", len);
+		return -EINVAL;
+	}
+
+	ba2str(&ev->bdaddr, addr);
+	printf("hci%u %s connect failed with status 0x%02x\n", index, addr,
+								ev->status);
+
+	return 0;
+}
+
 static int mgmt_handle_event(int mgmt_sk, uint16_t ev, uint16_t index,
 						void *data, uint16_t len)
 {
@@ -367,6 +387,8 @@ static int mgmt_handle_event(int mgmt_sk, uint16_t ev, uint16_t index,
 		return mgmt_connected(mgmt_sk, index, true, data, len);
 	case MGMT_EV_DEVICE_DISCONNECTED:
 		return mgmt_connected(mgmt_sk, index, false, data, len);
+	case MGMT_EV_CONNECT_FAILED:
+		return mgmt_conn_failed(mgmt_sk, index, data, len);
 	default:
 		if (monitor)
 			printf("Unhandled event 0x%04x (%s)\n", ev, mgmt_evstr(ev));