[PATCH] android/gatt: Add support for send indication

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

 



With this patch Android app can send indication to remote device
---
 android/gatt.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 3e291cf..74d36bb 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3666,10 +3666,38 @@ failed:
 
 static void handle_server_send_indication(const void *buf, uint16_t len)
 {
+	const struct hal_cmd_gatt_server_send_indication *cmd = buf;
+	uint8_t pdu[ATT_DEFAULT_LE_MTU];
+	struct app_connection *conn;
+	uint8_t status;
+	uint16_t length;
+
 	DBG("");
 
+	conn = find_connection_by_id(cmd->conn_id);
+	if (!conn) {
+		error("gatt: Could not find connection");
+		status = HAL_STATUS_FAILED;
+		goto reply;
+	}
+
+	if (cmd->confirm)
+		/* TODO: Add data to track confirmation for this request */
+		length = enc_indication(cmd->attribute_handle,
+					(uint8_t *)cmd->value, cmd->len,
+					pdu, sizeof(pdu));
+	else
+		length = enc_notification(cmd->attribute_handle,
+						(uint8_t *)cmd->value, cmd->len,
+						pdu, sizeof(pdu));
+
+	g_attrib_send(conn->device->attrib , 0, pdu, length, NULL, NULL , NULL);
+
+	status = HAL_STATUS_SUCCESS;
+
+reply:
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
-			HAL_OP_GATT_SERVER_SEND_INDICATION, HAL_STATUS_FAILED);
+				HAL_OP_GATT_SERVER_SEND_INDICATION, status);
 }
 
 static void handle_server_send_response(const void *buf, uint16_t len)
-- 
1.8.4

--
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