public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 01/12] android/hog: Add bt_hog_send
@ 2014-06-30 14:17 Luiz Augusto von Dentz
  2014-06-30 14:17 ` [PATCH BlueZ v2 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 14:17 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This function can be used to send data using Output Report if one is
available.
---
v2: Fix patch 02/12 to check if a hog instance exists.

 android/hog.c | 37 +++++++++++++++++++++++++++++++++++++
 android/hog.h |  1 +
 2 files changed, 38 insertions(+)

diff --git a/android/hog.c b/android/hog.c
index 7e61790..5d33c63 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -1009,3 +1009,40 @@ 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)
+{
+	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);
+	if (!l)
+		return -ENOTSUP;
+
+	report = l->data;
+
+	DBG("Sending data to 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)
+		gatt_write_cmd(hog->attrib, report->decl->value_handle,
+						data, size, NULL, NULL);
+
+	for (l = hog->instances; l; l = l->next) {
+		struct bt_hog *instance = l->data;
+
+		bt_hog_send(instance, data, size);
+	}
+
+	return 0;
+}
diff --git a/android/hog.h b/android/hog.h
index 7cf446b..4ebc83e 100644
--- a/android/hog.h
+++ b/android/hog.h
@@ -33,3 +33,4 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt);
 void bt_hog_detach(struct bt_hog *hog);
 
 int bt_hog_set_control_point(struct bt_hog *hog, bool suspend);
+int bt_hog_send(struct bt_hog *hog, void *data, size_t size);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-06-30 16:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 14:17 [PATCH BlueZ v2 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 03/12] android/hog: Read initial value of Report characteristic Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 04/12] android/hog: Read CCC initial value for Input Report Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 05/12] android/hog: Fix not resetting properly on detach Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 06/12] android/hog: Fix not detaching on free Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 07/12] android/hog: Remove unused code Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 08/12] android/scpp: Fix not unregistering on detach Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 09/12] android/scpp: Fix not detaching on free Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 10/12] android/bas: Enable notification for Battery Level characteristic Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 11/12] android/bas: Read CCC initial value for Battery Level Luiz Augusto von Dentz
2014-06-30 14:17 ` [PATCH BlueZ v2 12/12] android/dis: Detach on free Luiz Augusto von Dentz
2014-06-30 16:56 ` [PATCH BlueZ v2 01/12] android/hog: Add bt_hog_send Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox