Diff between 095ecf52fa9dd378ca718ff86529cae1e7b7a4da and 6477bcc8152f393b0ffa502ef44c2225c8e5089e

Changed Files

File Additions Deletions Status
android/gatt.c +41 -0 modified

Full Patch

diff --git a/android/gatt.c b/android/gatt.c
index 1d9971c..37bdeb6 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -6414,6 +6414,38 @@ done:
 	entry->state = REQUEST_DONE;
 }
 
+static void device_info_read_system_id_cb(uint16_t handle, uint16_t offset,
+					uint8_t att_opcode, bdaddr_t *bdaddr,
+					void *user_data)
+{
+	struct pending_request *entry;
+	struct gatt_device *dev;
+
+	dev = find_device_by_addr(bdaddr);
+	if (!dev) {
+		error("gatt: Could not find device ?!");
+		return;
+	}
+
+	entry = queue_find(dev->pending_requests, match_dev_request_by_handle,
+							UINT_TO_PTR(handle));
+	if (!entry)
+		return;
+
+	entry->value = malloc0(sizeof(uint64_t));
+	if (!entry->value) {
+		entry->error = ATT_ECODE_UNLIKELY;
+		goto done;
+	}
+
+	entry->length = sizeof(uint64_t);
+	put_le64(bt_config_get_system_id(), entry->value);
+	entry->offset = offset;
+
+done:
+	entry->state = REQUEST_DONE;
+}
+
 static void register_device_info_service(void)
 {
 	bt_uuid_t uuid;
@@ -6447,6 +6479,15 @@ static void register_device_info_service(void)
 						(void *) data);
 	}
 
+	if (bt_config_get_system_id()) {
+		bt_uuid16_create(&uuid, GATT_CHARAC_SYSTEM_ID);
+		gatt_db_add_characteristic(gatt_db, srvc_handle, &uuid,
+						GATT_PERM_READ,
+						GATT_CHR_PROP_READ,
+						device_info_read_system_id_cb,
+						NULL, NULL);
+	}
+
 	/* TODO */
 	data = NULL;
 	if (data) {