[PATCH 1/3] android/hog: Write all report characteristics for bt_hog_send

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows to write all hog report characeteristics (input, output,
feature). This is only test command designed for test purposes
e.g. PTS Write Report Characteristics.
---
 android/hog.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/android/hog.c b/android/hog.c
index 319cb2a..019cd57 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -1039,31 +1039,26 @@ int bt_hog_set_control_point(struct bt_hog *hog, bool suspend)
 	return 0;
 }
 
-int bt_hog_send(struct bt_hog *hog, void *data, size_t size)
+static int write_report(struct bt_hog *hog, void *data, size_t size,
+							int report_type)
 {
 	struct report *report;
 	GSList *l;
 
-	if (!hog)
-		return -EINVAL;
-
-	if (!hog->attrib)
-		return -ENOTCONN;
-
-	l = g_slist_find_custom(hog->reports,
-				GUINT_TO_POINTER(HOG_REPORT_TYPE_OUTPUT),
-				report_type_cmp);
+	l = g_slist_find_custom(hog->reports, GUINT_TO_POINTER(report_type),
+							report_type_cmp);
 	if (!l)
 		return -ENOTSUP;
 
 	report = l->data;
 
-	DBG("Sending data to handle 0x%X", report->decl->value_handle);
+	DBG("hog: Write report, handle 0x%X", report->decl->value_handle);
 
 	if (report->decl->properties & GATT_CHR_PROP_WRITE)
 		gatt_write_char(hog->attrib, report->decl->value_handle,
 				data, size, output_written_cb, hog);
-	else if (report->decl->properties & GATT_CHR_PROP_WRITE_WITHOUT_RESP)
+
+	if (report->decl->properties & GATT_CHR_PROP_WRITE_WITHOUT_RESP)
 		gatt_write_cmd(hog->attrib, report->decl->value_handle,
 						data, size, NULL, NULL);
 
@@ -1075,3 +1070,23 @@ int bt_hog_send(struct bt_hog *hog, void *data, size_t size)
 
 	return 0;
 }
+
+int bt_hog_send(struct bt_hog *hog, void *data, size_t size)
+{
+	if (!hog)
+		return -EINVAL;
+
+	if (!hog->attrib)
+		return -ENOTCONN;
+
+	if (write_report(hog, data, size, HOG_REPORT_TYPE_OUTPUT) < 0)
+		error("hog: can't write output report: %s", strerror(ENOTSUP));
+
+	if (write_report(hog, data, size, HOG_REPORT_TYPE_INPUT) < 0)
+		error("hog: can't write input report: %s", strerror(ENOTSUP));
+
+	if (write_report(hog, data, size, HOG_REPORT_TYPE_FEATURE) < 0)
+		error("hog: can't write feature report: %s", strerror(ENOTSUP));
+
+	return 0;
+}
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux