public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] android/gatt: Fix sending incorrect frames
@ 2014-07-09  8:53 Marcin Kraglak
  2014-07-09  8:53 ` [PATCH 2/2] android/gatt: Set need_resp flag in when received PREP_WRITE_REQ Marcin Kraglak
  2014-07-09  9:31 ` [PATCH 1/2] android/gatt: Fix sending incorrect frames Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Marcin Kraglak @ 2014-07-09  8:53 UTC (permalink / raw)
  To: linux-bluetooth

Don't send pdu if encoding failed. It cause errors when trying
send notification larger than MTU - encoding pdu failed, and
length passed to g_attrib_send was 0. I caused errors.
---
 android/gatt.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 2ee2d05..cccf23e 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4884,9 +4884,14 @@ static void handle_server_send_indication(const void *buf, uint16_t len)
 						(uint8_t *)cmd->value, cmd->len,
 						pdu, mtu);
 
-	g_attrib_send(conn->device->attrib, 0, pdu, length, NULL, NULL, NULL);
-
-	status = HAL_STATUS_SUCCESS;
+	if (length == 0) {
+		error("gatt: Failed to encode indication");
+		status = HAL_STATUS_FAILED;
+	} else {
+		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,
-- 
1.9.3


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

* [PATCH 2/2] android/gatt: Set need_resp flag in when received PREP_WRITE_REQ
  2014-07-09  8:53 [PATCH 1/2] android/gatt: Fix sending incorrect frames Marcin Kraglak
@ 2014-07-09  8:53 ` Marcin Kraglak
  2014-07-09  9:31 ` [PATCH 1/2] android/gatt: Fix sending incorrect frames Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Marcin Kraglak @ 2014-07-09  8:53 UTC (permalink / raw)
  To: linux-bluetooth

Set need_resp flag if pepare write request have been received.
This is needed because application should send response to stack.
---
 android/gatt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index cccf23e..ef831ad 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4580,7 +4580,10 @@ static void write_cb(uint16_t handle, uint16_t offset,
 	ev->trans_id = transaction->id;
 
 	ev->is_prep = att_opcode == ATT_OP_PREP_WRITE_REQ;
-	ev->need_rsp = att_opcode == ATT_OP_WRITE_REQ;
+
+	if (att_opcode == ATT_OP_WRITE_REQ ||
+					att_opcode == ATT_OP_PREP_WRITE_REQ)
+		ev->need_rsp = true;
 
 	ev->length = len;
 	memcpy(ev->value, value, len);
-- 
1.9.3


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

* Re: [PATCH 1/2] android/gatt: Fix sending incorrect frames
  2014-07-09  8:53 [PATCH 1/2] android/gatt: Fix sending incorrect frames Marcin Kraglak
  2014-07-09  8:53 ` [PATCH 2/2] android/gatt: Set need_resp flag in when received PREP_WRITE_REQ Marcin Kraglak
@ 2014-07-09  9:31 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-07-09  9:31 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth

Hi Marcin,

On Wednesday 09 of July 2014 10:53:52 Marcin Kraglak wrote:
> Don't send pdu if encoding failed. It cause errors when trying
> send notification larger than MTU - encoding pdu failed, and
> length passed to g_attrib_send was 0. I caused errors.
> ---
>  android/gatt.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index 2ee2d05..cccf23e 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -4884,9 +4884,14 @@ static void handle_server_send_indication(const void *buf, uint16_t len)
>  						(uint8_t *)cmd->value, cmd->len,
>  						pdu, mtu);
>  
> -	g_attrib_send(conn->device->attrib, 0, pdu, length, NULL, NULL, NULL);
> -
> -	status = HAL_STATUS_SUCCESS;
> +	if (length == 0) {
> +		error("gatt: Failed to encode indication");
> +		status = HAL_STATUS_FAILED;
> +	} else {
> +		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,
> 

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-07-09  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-09  8:53 [PATCH 1/2] android/gatt: Fix sending incorrect frames Marcin Kraglak
2014-07-09  8:53 ` [PATCH 2/2] android/gatt: Set need_resp flag in when received PREP_WRITE_REQ Marcin Kraglak
2014-07-09  9:31 ` [PATCH 1/2] android/gatt: Fix sending incorrect frames Szymon Janc

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