Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCHv2 1/2] android/client: Fix incorrect data parsing
@ 2014-08-25 13:50 Marcin Kraglak
  2014-08-25 13:50 ` [PATCHv2 2/2] android/pts: Update PTS GATT test results Marcin Kraglak
  2014-08-26  9:27 ` [PATCHv2 1/2] android/client: Fix incorrect data parsing Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Marcin Kraglak @ 2014-08-25 13:50 UTC (permalink / raw)
  To: linux-bluetooth

Use fill_buffer function in processing write_characteristic
and send_indication functions.
---
 android/client/if-gatt.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index 8154bfd..a4c6bc9 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -1191,11 +1191,12 @@ static void write_characteristic_p(int argc, const char **argv)
 		return;
 	}
 
-	/* len in chars */
-	len = strlen(argv[6]);
-	scan_field(argv[6], len, value, sizeof(value));
-	/* len in bytes converted from ascii chars */
-	len = (len + 1) / 2;
+	if (strncmp(argv[6], "0X", 2) && strncmp(argv[6], "0x", 2)) {
+		haltest_error("Value must be hex string");
+		return;
+	}
+
+	len = fill_buffer(argv[6] + 2, value, sizeof(value));
 
 	/* auth_req */
 	if (argc > 7)
@@ -1775,7 +1776,7 @@ static void gatts_send_indication_p(int argc, const char *argv[])
 	int attr_handle;
 	int conn_id;
 	int confirm;
-	char data[200];
+	uint8_t data[200];
 	int len = 0;
 
 	RETURN_IF_NULL(if_gatt);
@@ -1791,12 +1792,16 @@ static void gatts_send_indication_p(int argc, const char *argv[])
 	confirm = atoi(argv[5]);
 
 	if (argc > 6) {
-		len = strlen(argv[6]);
-		scan_field(argv[6], len, (uint8_t *) data, sizeof(data));
+		if (strncmp(argv[6], "0X", 2) && strncmp(argv[6], "0x", 2)) {
+			haltest_error("Value must be hex string");
+			return;
+		}
+
+		len = fill_buffer(argv[6] + 2, data, sizeof(data));
 	}
 
 	EXEC(if_gatt->server->send_indication, server_if, attr_handle, conn_id,
-							len, confirm, data);
+						len, confirm, (char *) data);
 }
 
 /* send_response */
-- 
1.9.3


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

end of thread, other threads:[~2014-08-26  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-25 13:50 [PATCHv2 1/2] android/client: Fix incorrect data parsing Marcin Kraglak
2014-08-25 13:50 ` [PATCHv2 2/2] android/pts: Update PTS GATT test results Marcin Kraglak
2014-08-26  9:27 ` [PATCHv2 1/2] android/client: Fix incorrect data parsing Szymon Janc

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