public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] android/client: Fix data parsing for write descriptor
@ 2014-07-02 10:34 Grzegorz Kolodziejczyk
  2014-07-02 10:34 ` [PATCH 2/2] Android/pts: Update HOGP tests results Grzegorz Kolodziejczyk
  2014-07-02 10:37 ` [PATCH 1/2] android/client: Fix data parsing for write descriptor Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-02 10:34 UTC (permalink / raw)
  To: linux-bluetooth

This fix data parsing for write descriptor by using fill buffer function.
Fill buffer helper has been moved upper to be visible for write descriptor
function.
---
 android/client/if-gatt.c | 100 ++++++++++++++++++++++++-----------------------
 1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index 4b1c549..8154bfd 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -782,6 +782,51 @@ static const btgatt_callbacks_t gatt_cbacks = {
 	.server = &btgatt_server_callbacks
 };
 
+/*
+ * convert hex string to uint8_t array
+ */
+static int fill_buffer(const char *str, uint8_t *out, int out_size)
+{
+	int str_len;
+	int i, j;
+	char c;
+	uint8_t b;
+
+	str_len = strlen(str);
+
+	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
+		c = str[j];
+
+		if (c >= 'a' && c <= 'f')
+			c += 'A' - 'a';
+
+		if (c >= '0' && c <= '9')
+			b = c - '0';
+		else if (c >= 'A' && c <= 'F')
+			b = 10 + c - 'A';
+		else
+			return 0;
+
+		j++;
+
+		c = str[j];
+
+		if (c >= 'a' && c <= 'f')
+			c += 'A' - 'a';
+
+		if (c >= '0' && c <= '9')
+			b = b * 16 + c - '0';
+		else if (c >= 'A' && c <= 'F')
+			b = b * 16 + 10 + c - 'A';
+		else
+			return 0;
+
+		out[i] = b;
+	}
+
+	return i;
+}
+
 /* gatt client methods */
 
 /* init */
@@ -1238,10 +1283,12 @@ static void write_descriptor_p(int argc, const char **argv)
 	}
 
 	/* len in chars */
-	len = strlen(argv[7]);
-	scan_field(argv[7], len, value, sizeof(value));
-	/* len in bytes converted from ascii chars */
-	len = (len + 1) / 2;
+	if (strncmp(argv[7], "0X", 2) && strncmp(argv[7], "0x", 2)) {
+		haltest_error("Value must be hex string");
+		return;
+	}
+
+	len = fill_buffer(argv[7] + 2, value, sizeof(value));
 
 	/* auth_req */
 	if (argc > 8)
@@ -1752,51 +1799,6 @@ static void gatts_send_indication_p(int argc, const char *argv[])
 							len, confirm, data);
 }
 
-/*
- * convert hex string to uint8_t array
- */
-static int fill_buffer(const char *str, uint8_t *out, int out_size)
-{
-	int str_len;
-	int i, j;
-	char c;
-	uint8_t b;
-
-	str_len = strlen(str);
-
-	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
-		c = str[j];
-
-		if (c >= 'a' && c <= 'f')
-			c += 'A' - 'a';
-
-		if (c >= '0' && c <= '9')
-			b = c - '0';
-		else if (c >= 'A' && c <= 'F')
-			b = 10 + c - 'A';
-		else
-			return 0;
-
-		j++;
-
-		c = str[j];
-
-		if (c >= 'a' && c <= 'f')
-			c += 'A' - 'a';
-
-		if (c >= '0' && c <= '9')
-			b = b * 16 + c - '0';
-		else if (c >= 'A' && c <= 'F')
-			b = b * 16 + 10 + c - 'A';
-		else
-			return 0;
-
-		out[i] = b;
-	}
-
-	return i;
-}
-
 /* send_response */
 
 static void gatts_send_response_p(int argc, const char *argv[])
-- 
1.9.3


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

* [PATCH 2/2] Android/pts: Update HOGP tests results
  2014-07-02 10:34 [PATCH 1/2] android/client: Fix data parsing for write descriptor Grzegorz Kolodziejczyk
@ 2014-07-02 10:34 ` Grzegorz Kolodziejczyk
  2014-07-02 10:37 ` [PATCH 1/2] android/client: Fix data parsing for write descriptor Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-02 10:34 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/pts-hogp.txt | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/android/pts-hogp.txt b/android/pts-hogp.txt
index 965ed33..9ab7872 100644
--- a/android/pts-hogp.txt
+++ b/android/pts-hogp.txt
@@ -78,7 +78,17 @@ TC_HGWF_BH_BV_09_I	N/A
 TC_HGWF_BH_BV_10_I	N/A
 TC_HGWF_BH_BV_11_I	N/A
 TC_HGCF_RH_BV_01_I	PASS
-TC_HGCF_RH_BV_02_I	INC
+TC_HGCF_RH_BV_02_I	PASS	haltest: hidhost connect <addr>
+				gattc search_service 1
+				gattc get_characteristic 1 {1812,2,1}
+				gattc get_descriptor 1 {1812,2,1} {2a4d,5}
+				gattc write_descriptor 1 {1812,2,1} {2a4d,5}
+					{2902,0} 2 0x0000 0
+				gattc get_characteristic 1 {1812,5,1}
+				gattc get_descriptor 1 {1812,5,1} {2a4d,4}
+				gattc write_descriptor 1 {1812,5,1}
+					{2a4d,4} {2902,0} 2 0x0000 0
+				hidhost disconnect <addr>
 TC_HGCF_BH_BV_03_I	N/A
 TC_HGCF_BH_BV_04_I	N/A
 TC_HGCF_BH_BV_05_I	N/A
-- 
1.9.3


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

* Re: [PATCH 1/2] android/client: Fix data parsing for write descriptor
  2014-07-02 10:34 [PATCH 1/2] android/client: Fix data parsing for write descriptor Grzegorz Kolodziejczyk
  2014-07-02 10:34 ` [PATCH 2/2] Android/pts: Update HOGP tests results Grzegorz Kolodziejczyk
@ 2014-07-02 10:37 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-07-02 10:37 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Wednesday 02 of July 2014 12:34:57 Grzegorz Kolodziejczyk wrote:
> This fix data parsing for write descriptor by using fill buffer function.
> Fill buffer helper has been moved upper to be visible for write descriptor
> function.
> ---
>  android/client/if-gatt.c | 100 ++++++++++++++++++++++++-----------------------
>  1 file changed, 51 insertions(+), 49 deletions(-)
> 
> diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
> index 4b1c549..8154bfd 100644
> --- a/android/client/if-gatt.c
> +++ b/android/client/if-gatt.c
> @@ -782,6 +782,51 @@ static const btgatt_callbacks_t gatt_cbacks = {
>  	.server = &btgatt_server_callbacks
>  };
>  
> +/*
> + * convert hex string to uint8_t array
> + */
> +static int fill_buffer(const char *str, uint8_t *out, int out_size)
> +{
> +	int str_len;
> +	int i, j;
> +	char c;
> +	uint8_t b;
> +
> +	str_len = strlen(str);
> +
> +	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
> +		c = str[j];
> +
> +		if (c >= 'a' && c <= 'f')
> +			c += 'A' - 'a';
> +
> +		if (c >= '0' && c <= '9')
> +			b = c - '0';
> +		else if (c >= 'A' && c <= 'F')
> +			b = 10 + c - 'A';
> +		else
> +			return 0;
> +
> +		j++;
> +
> +		c = str[j];
> +
> +		if (c >= 'a' && c <= 'f')
> +			c += 'A' - 'a';
> +
> +		if (c >= '0' && c <= '9')
> +			b = b * 16 + c - '0';
> +		else if (c >= 'A' && c <= 'F')
> +			b = b * 16 + 10 + c - 'A';
> +		else
> +			return 0;
> +
> +		out[i] = b;
> +	}
> +
> +	return i;
> +}
> +
>  /* gatt client methods */
>  
>  /* init */
> @@ -1238,10 +1283,12 @@ static void write_descriptor_p(int argc, const char **argv)
>  	}
>  
>  	/* len in chars */
> -	len = strlen(argv[7]);
> -	scan_field(argv[7], len, value, sizeof(value));
> -	/* len in bytes converted from ascii chars */
> -	len = (len + 1) / 2;
> +	if (strncmp(argv[7], "0X", 2) && strncmp(argv[7], "0x", 2)) {
> +		haltest_error("Value must be hex string");
> +		return;
> +	}
> +
> +	len = fill_buffer(argv[7] + 2, value, sizeof(value));
>  
>  	/* auth_req */
>  	if (argc > 8)
> @@ -1752,51 +1799,6 @@ static void gatts_send_indication_p(int argc, const char *argv[])
>  							len, confirm, data);
>  }
>  
> -/*
> - * convert hex string to uint8_t array
> - */
> -static int fill_buffer(const char *str, uint8_t *out, int out_size)
> -{
> -	int str_len;
> -	int i, j;
> -	char c;
> -	uint8_t b;
> -
> -	str_len = strlen(str);
> -
> -	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
> -		c = str[j];
> -
> -		if (c >= 'a' && c <= 'f')
> -			c += 'A' - 'a';
> -
> -		if (c >= '0' && c <= '9')
> -			b = c - '0';
> -		else if (c >= 'A' && c <= 'F')
> -			b = 10 + c - 'A';
> -		else
> -			return 0;
> -
> -		j++;
> -
> -		c = str[j];
> -
> -		if (c >= 'a' && c <= 'f')
> -			c += 'A' - 'a';
> -
> -		if (c >= '0' && c <= '9')
> -			b = b * 16 + c - '0';
> -		else if (c >= 'A' && c <= 'F')
> -			b = b * 16 + 10 + c - 'A';
> -		else
> -			return 0;
> -
> -		out[i] = b;
> -	}
> -
> -	return i;
> -}
> -
>  /* send_response */
>  
>  static void gatts_send_response_p(int argc, const char *argv[])
> 

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-07-02 10:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-02 10:34 [PATCH 1/2] android/client: Fix data parsing for write descriptor Grzegorz Kolodziejczyk
2014-07-02 10:34 ` [PATCH 2/2] Android/pts: Update HOGP tests results Grzegorz Kolodziejczyk
2014-07-02 10:37 ` [PATCH 1/2] android/client: Fix data parsing for write descriptor Szymon Janc

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