Diff between 97b4ceb85cabb22a94422fc8b993da090a2b0574 and d5f15eac21c2795a2b0163cca15524e2a013803b

Changed Files

File Additions Deletions Status
lib/mgmt.h +9 -0 modified
plugins/mgmtops.c +24 -3 modified

Full Patch

diff --git a/lib/mgmt.h b/lib/mgmt.h
index f3bc6da..c9b0f1a 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -311,6 +311,14 @@ struct mgmt_cp_unblock_device {
 	struct mgmt_addr_info addr;
 } __packed;
 
+#define MGMT_OP_SET_DEVICE_ID		0x0028
+struct mgmt_cp_set_device_id {
+	uint16_t source;
+	uint16_t vendor;
+	uint16_t product;
+	uint16_t version;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -475,6 +483,7 @@ static const char *mgmt_op[] = {
 	"Confirm Name",
 	"Block Device",
 	"Unblock Device",
+	"Set Device ID",
 };
 
 static const char *mgmt_ev[] = {
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index c24757c..c08117f 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1426,6 +1426,9 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 	case MGMT_OP_STOP_DISCOVERY:
 		DBG("stop_discovery complete");
 		break;
+	case MGMT_OP_SET_DEVICE_ID:
+		DBG("set_did complete");
+		break;
 	default:
 		error("Unknown command complete for opcode %u", opcode);
 		break;
@@ -2118,9 +2121,27 @@ static int mgmt_encrypt_link(int index, bdaddr_t *dst, bt_hci_result_t cb,
 static int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
 					uint16_t version, uint16_t source)
 {
-	DBG("index %d vendor %u product %u version %u source %u",
-				index, vendor, product, version, source);
-	return -ENOSYS;
+	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_device_id)];
+	struct mgmt_hdr *hdr = (void *) buf;
+	struct mgmt_cp_set_device_id *cp = (void *) &buf[sizeof(*hdr)];
+
+	DBG("index %d source %x vendor %x product %x version %x",
+				index, source, vendor, product, version);
+
+	memset(buf, 0, sizeof(buf));
+	hdr->opcode = htobs(MGMT_OP_SET_DEVICE_ID);
+	hdr->len = htobs(sizeof(*cp));
+	hdr->index = htobs(index);
+
+	cp->source = htobs(source);
+	cp->vendor = htobs(vendor);
+	cp->product = htobs(product);
+	cp->version = htobs(version);
+
+	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
+		return -errno;
+
+	return 0;
 }
 
 static int mgmt_disable_cod_cache(int index)