* Re: [PATCH_v2 02/11] android/hid: Add a ascii2hex utility
From: Johan Hedberg @ 2013-11-08 8:10 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383862220-29968-3-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> +++ b/android/utils.c
> @@ -0,0 +1,41 @@
> +/*
> + *
> + * BlueZ - Bluetooth protocol stack for Linux
> + *
> + * Copyright (C) 2013 Intel Corporation. All rights reserved.
> + *
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include "utils.h"
> +
> +void ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex)
> +{
> + int i;
> +
> + if (!ascii || !hex)
> + return;
> +
> + for (i = 0; i < ascii_len / 2; i++)
> + sscanf((char *) &ascii[i * 2], "%02x",
> + (unsigned int *) &hex[i]);
> +
> +}
I'd just keep this static inside the HID HAL since that seems to be the
only user for it. Actually I'm not even convinced that it's worth to
have this as a separate function since you only have two users and
essentially the function is just two lines (the if-statement is
redundant). Also, the function name isn't quite right. You're converting
from hex to binary. Not from ascii to hex (hex notation is already using
the ascii character set). Also, do consider the point from Jerzy about
the format specifier.
Johan
^ permalink raw reply
* Re: [PATCH_v2 10/11] android/hid: Add virtual unplug implemention in daemon
From: Johan Hedberg @ 2013-11-08 8:37 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383862220-29968-11-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> + fd = g_io_channel_unix_get_fd(dev->ctrl_io);
> +
> + if (write(fd, &hdr, sizeof(hdr)) < 0) {
> + error("error while virtual unplug command");
> + return HAL_STATUS_FAILED;
> + }
> +
> + /* Wait either channels to HUP */
> + if (dev->intr_io)
> + g_io_channel_shutdown(dev->intr_io, TRUE, NULL);
> +
> + if (dev->ctrl_io)
> + g_io_channel_shutdown(dev->ctrl_io, TRUE, NULL);
This looks a bit suspicious. First you try to get the fd from ctrl_io
without checking if it's NULL and then later you have an explicit check
for whether it is NULL or not. Is there some check missing earlier in
the function?
Johan
^ permalink raw reply
* Re: [PATCH_v2 09/11] android/hid: Handle virtual unplug notification in hid hal
From: Johan Hedberg @ 2013-11-08 8:39 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383862220-29968-10-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> ---
> android/hal-hidhost.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
Patches 1, 4, 5, 8 and 9 have been applied, so no need to resend those
in your next revision.
Johan
^ permalink raw reply
* Re: [PATCH_Bluez] gitignore: Add tools/smp-tester to .gitignore
From: Johan Hedberg @ 2013-11-08 8:41 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383863141-30400-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> ---
> .gitignore | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/.gitignore b/.gitignore
> index 4994958..339d37b 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -85,6 +85,7 @@ monitor/btmon
> emulator/btvirt
> emulator/b1ee
> client/bluetoothctl
> +tools/smp-tester
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH_v2 02/11] android/hid: Add a ascii2hex utility
From: Johan Hedberg @ 2013-11-08 8:48 UTC (permalink / raw)
To: Ravi Kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <527CA596.6070602@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi Kumar Veeramally wrote:
>>> +void ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex)
>>> +{
>>> + int i;
>>> +
>>> + if (!ascii || !hex)
>>> + return;
>>> +
>>> + for (i = 0; i < ascii_len / 2; i++)
>>> + sscanf((char *) &ascii[i * 2], "%02x",
>>> + (unsigned int *) &hex[i]);
>>> +
>>> +}
>
>> I'd just keep this static inside the HID HAL since that seems to be
>> the only user for it. Actually I'm not even convinced that it's worth
>> to have this as a separate function since you only have two users and
>> essentially the function is just two lines (the if-statement is
>> redundant).
>
> Ok, I will keep it as static. Do you want me to keep in HID HAL or HID
> daemon?
The daemon is where you were doing the conversion now as well, so no
need to change that (sorry about being unclear when I said "HID HAL").
>> Also, the function name isn't quite right. You're converting from hex
>> to binary
>
> We are converting to hex right? correct me If I am wrong.
No, we're converting from hex to binary.
>>. Not from ascii to hex (hex notation is already using
>>the ascii character set). Also, do consider the point from Jerzy about
>>the format specifier.
>>
> Ok, I will fix Jerzy's suggestion also.
>
> Apart from this patch, do you have any comments on rest of the
> patches?
Only the ones I already sent.
Johan
^ permalink raw reply
* Re: [PATCH v2 1/2] Bluetooth: Remove unneeded check in hci_disconn_complete_evt()
From: Johan Hedberg @ 2013-11-08 8:55 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1383856570-30480-1-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
On Thu, Nov 07, 2013, Andre Guedes wrote:
> According to b644ba336 (patch that introduced HCI_CONN_MGMT_CONNECTED
> flag), the HCI_CONN_MGMT_CONNECTED flag tracks when mgmt has been
> notified about the connection.
>
> That being said, there is no point in calling mgmt_disconnect_failed()
> conditionally based on this flag. mgmt_disconnect_failed() removes
> pending MGMT_OP_DISCONNECT commands, it doesn't matter if that
> connection was notified or not.
>
> Moreover, if the Disconnection Complete event has status then we have
> nothing else to do but call mgmt_disconnect_failed() and return.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> net/bluetooth/hci_event.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
Both patches have now been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] android/ipc: Fix crash when sending file descriptor
From: Johan Hedberg @ 2013-11-08 9:04 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383837935-31110-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thu, Nov 07, 2013, Andrei Emeltchenko wrote:
> Since CMSG_FIRSTHDR is defined as shown below:
>
> ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
> ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
>
> it return NULL if msg_controllen is not defined. Accessing
> that pointer result in daemon crash.
> ---
> android/ipc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH_v2 02/11] android/hid: Add a ascii2hex utility
From: Ravi Kumar Veeramally @ 2013-11-08 9:05 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131108084831.GA19729@x220.p-661hnu-f1>
On 11/08/2013 10:48 AM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Fri, Nov 08, 2013, Ravi Kumar Veeramally wrote:
>>>> +void ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex)
>>>> +{
>>>> + int i;
>>>> +
>>>> + if (!ascii || !hex)
>>>> + return;
>>>> +
>>>> + for (i = 0; i < ascii_len / 2; i++)
>>>> + sscanf((char *) &ascii[i * 2], "%02x",
>>>> + (unsigned int *) &hex[i]);
>>>> +
>>>> +}
>>> I'd just keep this static inside the HID HAL since that seems to be
>>> the only user for it. Actually I'm not even convinced that it's worth
>>> to have this as a separate function since you only have two users and
>>> essentially the function is just two lines (the if-statement is
>>> redundant).
>> Ok, I will keep it as static. Do you want me to keep in HID HAL or HID
>> daemon?
> The daemon is where you were doing the conversion now as well, so no
> need to change that (sorry about being unclear when I said "HID HAL").
>
>>> Also, the function name isn't quite right. You're converting from hex
>>> to binary
>> We are converting to hex right? correct me If I am wrong.
> No, we're converting from hex to binary.
>
>>> . Not from ascii to hex (hex notation is already using
>>> the ascii character set). Also, do consider the point from Jerzy about
>>> the format specifier.
>>>
>> Ok, I will fix Jerzy's suggestion also.
>>
>> Apart from this patch, do you have any comments on rest of the
>> patches?
> Only the ones I already sent.
>
> Johan
>
Ok, Patch_v2 6 & 7 are independent of ascii stuff, can be it possible to
apply if there are no comments? (just a request!!).
Thanks a lot,
Ravi.
^ permalink raw reply
* Re: [PATCH_v2 06/11] android/hid: Fill send data structure variables in hal-hidhost
From: Johan Hedberg @ 2013-11-08 9:17 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383862220-29968-7-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> ---
> android/hal-hidhost.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
This doesn't compile:
CC android/android_libhal_internal_la-hal-hidhost.lo
android/hal-hidhost.c: In function 'send_data':
android/hal-hidhost.c:356:2: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
free(cmd);
^
android/hal-hidhost.c:356:2: error: incompatible implicit declaration of built-in function 'free' [-Werror]
cc1: all warnings being treated as errors
make[1]: *** [android/android_libhal_internal_la-hal-hidhost.lo] Error 1
Johan
^ permalink raw reply
* Re: [PATCH_v2 07/11] android/hid: Rename virtual unplug define and struct
From: Johan Hedberg @ 2013-11-08 9:18 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383862220-29968-8-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> Renaming virtual unplug define and strcut name from VP to more
> meaning full.
> ---
> android/hal-hidhost.c | 5 +++--
> android/hal-msg.h | 4 ++--
> android/hidhost.c | 4 ++--
> 3 files changed, 7 insertions(+), 6 deletions(-)
This patch has also been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH_v2 06/11] android/hid: Fill send data structure variables in hal-hidhost
From: Ravi Kumar Veeramally @ 2013-11-08 9:30 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131108091715.GA24795@x220.p-661hnu-f1>
Hi Johan,
On 11/08/2013 11:17 AM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
>> ---
>> android/hal-hidhost.c | 18 ++++++++++++++----
>> 1 file changed, 14 insertions(+), 4 deletions(-)
> This doesn't compile:
>
> CC android/android_libhal_internal_la-hal-hidhost.lo
> android/hal-hidhost.c: In function 'send_data':
> android/hal-hidhost.c:356:2: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
> free(cmd);
> ^
> android/hal-hidhost.c:356:2: error: incompatible implicit declaration of built-in function 'free' [-Werror]
> cc1: all warnings being treated as errors
> make[1]: *** [android/android_libhal_internal_la-hal-hidhost.lo] Error 1
>
Ok, I will send _v3 of this and rest.
Thanks,
Ravi.
^ permalink raw reply
* [PATCHv4 0/3] Reuse debug helpers for HAL client and HAL
From: Andrei Emeltchenko @ 2013-11-08 9:35 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The patch uses hal-utils.[ch] to keep debug functions for decoding
HAL messages. They will be used in haltest and HALs.
Changes:
* v4: changed bt_uuid_t -> uint8_t * since they are both used.
Andrei Emeltchenko (3):
android: Create debug hal-utils helpers
android/debug: Convert uuid helper to use uint8_t buffer
android/hal: Add UUID debug print in socket HAL
android/Android.mk | 2 ++
android/Makefile.am | 3 ++-
android/client/if-gatt.c | 1 +
android/client/textconv.c | 50 +++++++--------------------------------
android/client/textconv.h | 2 --
android/hal-sock.c | 19 +++++++++------
android/hal-utils.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
android/hal-utils.h | 26 +++++++++++++++++++++
8 files changed, 108 insertions(+), 52 deletions(-)
create mode 100644 android/hal-utils.c
create mode 100644 android/hal-utils.h
--
1.7.10.4
^ permalink raw reply
* [PATCHv4 1/3] android: Create debug hal-utils helpers
From: Andrei Emeltchenko @ 2013-11-08 9:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1383903349-17487-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Create hal-utils helpers which helps to decode packets Android
sends through HAL interface.
---
android/Android.mk | 2 ++
android/Makefile.am | 3 ++-
android/client/if-gatt.c | 1 +
android/client/textconv.c | 42 ++------------------------------
android/client/textconv.h | 2 --
android/hal-utils.c | 58 +++++++++++++++++++++++++++++++++++++++++++++
android/hal-utils.h | 26 ++++++++++++++++++++
7 files changed, 91 insertions(+), 43 deletions(-)
create mode 100644 android/hal-utils.c
create mode 100644 android/hal-utils.h
diff --git a/android/Android.mk b/android/Android.mk
index 51037a7..0bc0e82 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -88,6 +88,7 @@ LOCAL_SRC_FILES := \
hal-pan.c \
hal-a2dp.c \
client/textconv.c \
+ hal-utils.c \
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
@@ -125,6 +126,7 @@ LOCAL_SRC_FILES := \
client/if-hh.c \
client/if-pan.c \
client/if-sock.c \
+ hal-utils.c \
ANDROID_4_3_OR_ABOVE := $(shell echo 0 | awk -v v=$(PLATFORM_SDK_VERSION) 'END {print (v > 17) ? 1 : 0}')
diff --git a/android/Makefile.am b/android/Makefile.am
index 073edc8..debe7c1 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -68,7 +68,8 @@ android_haltest_SOURCES = android/client/haltest.c \
android/client/if-hh.c \
android/client/if-pan.c \
android/client/if-sock.c \
- android/client/hwmodule.c
+ android/client/hwmodule.c \
+ android/hal-utils.h android/hal-utils.c
android_haltest_LDADD = android/libhal-internal.la
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index b2b20cb..bb53952 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -17,6 +17,7 @@
#include <hardware/bluetooth.h>
+#include "../hal-utils.h"
#include "if-main.h"
const btgatt_interface_t *if_gatt = NULL;
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 4def3da..469b2c3 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -19,6 +19,8 @@
#include <stdio.h>
#include <hardware/bluetooth.h>
+#include "../hal-utils.h"
+
#include "textconv.h"
/*
@@ -154,39 +156,6 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr)
&p[0], &p[1], &p[2], &p[3], &p[4], &p[5]);
}
-static const char BT_BASE_UUID[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
-};
-
-/*
- * converts uuid to string
- * buf should be at least 39 bytes
- *
- * returns string representation of uuid
- */
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
-{
- int shift = 0;
- int i;
- int is_bt;
-
- is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
-
- for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
- if (i == 4 && is_bt)
- break;
-
- if (i == 4 || i == 6 || i == 8 || i == 10) {
- buf[i * 2 + shift] = '-';
- shift++;
- }
- sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
- }
-
- return buf;
-}
-
/* converts string to uuid */
void str2bt_uuid_t(const char *str, bt_uuid_t *uuid)
{
@@ -234,13 +203,6 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
return bt_bdaddr_t2str(bd_addr, buf);
}
-static char *btuuid2str(const bt_uuid_t *uuid)
-{
- static char buf[MAX_UUID_STR_LEN];
-
- return bt_uuid_t2str(uuid, buf);
-}
-
char *btproperty2str(const bt_property_t *property)
{
static char buf[4096];
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..837eb4e 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -103,8 +103,6 @@ static struct int2str __##type##2str[] = {
char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf);
void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
-#define MAX_UUID_STR_LEN 37
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
char *btproperty2str(const bt_property_t *property);
diff --git a/android/hal-utils.c b/android/hal-utils.c
new file mode 100644
index 0000000..84cfad1
--- /dev/null
+++ b/android/hal-utils.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+
+#include "hal-utils.h"
+
+/*
+ * converts uuid to string
+ * buf should be at least 39 bytes
+ *
+ * returns string representation of uuid
+ */
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+{
+ int shift = 0;
+ int i;
+ int is_bt;
+
+ is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+
+ for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+ if (i == 4 && is_bt)
+ break;
+
+ if (i == 4 || i == 6 || i == 8 || i == 10) {
+ buf[i * 2 + shift] = '-';
+ shift++;
+ }
+ sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+ }
+
+ return buf;
+}
+
+char *btuuid2str(const bt_uuid_t *uuid)
+{
+ static char buf[MAX_UUID_STR_LEN];
+
+ return bt_uuid_t2str(uuid, buf);
+}
diff --git a/android/hal-utils.h b/android/hal-utils.h
new file mode 100644
index 0000000..d40b430
--- /dev/null
+++ b/android/hal-utils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define MAX_UUID_STR_LEN 37
+
+static const char BT_BASE_UUID[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
+};
+
+char *btuuid2str(const bt_uuid_t *uuid);
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 2/3] android/debug: Convert uuid helper to use uint8_t buffer
From: Andrei Emeltchenko @ 2013-11-08 9:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1383903349-17487-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
At this moment Android uses uint8_t * and bt_uuid_t for representing
UUID for different HALs. Convert debug helper to use uint8_t * string.
---
android/client/textconv.c | 8 ++++++--
android/hal-utils.c | 17 ++++++++---------
android/hal-utils.h | 4 ++--
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 469b2c3..a1ce7dd 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -272,7 +272,9 @@ char *btproperty2str(const bt_property_t *property)
strcat(p, "{");
while (count--) {
- strcat(p, btuuid2str((bt_uuid_t *) ptr));
+ bt_uuid_t *uuid = (bt_uuid_t *) ptr;
+ strcat(p, btuuid2str(uuid->uu,
+ sizeof(uuid->uu)));
if (count)
strcat(p, ", ");
ptr += sizeof(bt_uuid_t);
@@ -286,8 +288,10 @@ char *btproperty2str(const bt_property_t *property)
case BT_PROPERTY_SERVICE_RECORD:
{
bt_service_record_t *rec = property->val;
+ bt_uuid_t *uuid = &rec->uuid;
- sprintf(p, "{%s, %d, %s}", btuuid2str(&rec->uuid),
+ sprintf(p, "{%s, %d, %s}", btuuid2str(uuid->uu,
+ sizeof(uuid->uu)),
rec->channel, rec->name);
}
break;
diff --git a/android/hal-utils.c b/android/hal-utils.c
index 84cfad1..3dc70c3 100644
--- a/android/hal-utils.c
+++ b/android/hal-utils.c
@@ -17,8 +17,7 @@
#include <stdio.h>
#include <string.h>
-
-#include <hardware/bluetooth.h>
+#include <stdint.h>
#include "hal-utils.h"
@@ -28,15 +27,15 @@
*
* returns string representation of uuid
*/
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+char *bt_uuid_t2str(const uint8_t *uuid, size_t len, char *buf)
{
int shift = 0;
- int i;
+ unsigned int i;
int is_bt;
- is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+ is_bt = !memcmp(&uuid[4], &BT_BASE_UUID[4], len - 4);
- for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+ for (i = 0; i < len; i++) {
if (i == 4 && is_bt)
break;
@@ -44,15 +43,15 @@ char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
buf[i * 2 + shift] = '-';
shift++;
}
- sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+ sprintf(buf + i * 2 + shift, "%02x", uuid[i]);
}
return buf;
}
-char *btuuid2str(const bt_uuid_t *uuid)
+char *btuuid2str(const uint8_t *uuid, size_t len)
{
static char buf[MAX_UUID_STR_LEN];
- return bt_uuid_t2str(uuid, buf);
+ return bt_uuid_t2str(uuid, len, buf);
}
diff --git a/android/hal-utils.h b/android/hal-utils.h
index d40b430..3b00e98 100644
--- a/android/hal-utils.h
+++ b/android/hal-utils.h
@@ -22,5 +22,5 @@ static const char BT_BASE_UUID[] = {
0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
};
-char *btuuid2str(const bt_uuid_t *uuid);
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
+char *bt_uuid_t2str(const uint8_t *uuid, size_t len, char *buf);
+char *btuuid2str(const uint8_t *uuid, size_t len);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 3/3] android/hal: Add UUID debug print in socket HAL
From: Andrei Emeltchenko @ 2013-11-08 9:35 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1383903349-17487-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Socket HAL uses uint8_t * strings which are of size bt_uuid_t.
---
android/hal-sock.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index 32c7939..74cadc1 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
#include "hal-msg.h"
#include "hal.h"
+#include "hal-utils.h"
+
static bt_status_t sock_listen_rfcomm(const char *service_name,
const uint8_t *uuid, int chan,
int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
int *sock, int flags)
{
if ((!uuid && chan <= 0) || !sock) {
- error("%s: invalid params: uuid %p, chan %d, sock %p",
- __func__, uuid, chan, sock);
+ error("Invalid params: uuid %s, chan %d, sock %p",
+ btuuid2str(uuid, sizeof(bt_uuid_t)), chan, sock);
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %p chan %d sock %p type %d service_name %s",
- uuid, chan, sock, type, service_name);
+ DBG("uuid %s chan %d sock %p type %d service_name %s",
+ btuuid2str(uuid, sizeof(bt_uuid_t)), chan,
+ sock, type, service_name);
switch (type) {
case BTSOCK_RFCOMM:
@@ -76,12 +79,14 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
struct hal_cmd_sock_connect cmd;
if ((!uuid && chan <= 0) || !bdaddr || !sock) {
- error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
- bdaddr, uuid, chan, sock);
+ error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+ bdaddr, btuuid2str(uuid, sizeof(bt_uuid_t)),
+ chan, sock);
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+ DBG("uuid %s chan %d sock %p type %d",
+ btuuid2str(uuid, sizeof(bt_uuid_t)), chan, sock, type);
if (type != BTSOCK_RFCOMM) {
error("Socket type %u not supported", type);
--
1.7.10.4
^ permalink raw reply related
* [PATCH] android: Fix pan service registration
From: Szymon Janc @ 2013-11-08 9:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
From: Marcin Kraglak <marcin.kraglak@tieto.com>
A2dp service was registered instead of pan.
---
android/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/main.c b/android/main.c
index 057c2f7..93870d0 100644
--- a/android/main.c
+++ b/android/main.c
@@ -107,7 +107,7 @@ static void service_register(void *buf, uint16_t len)
break;
case HAL_SERVICE_ID_PAN:
- if (!bt_a2dp_register(sk, adapter_bdaddr))
+ if (!bt_pan_register(sk, adapter_bdaddr))
goto failed;
break;
--
1.8.4.2
^ permalink raw reply related
* [PATCH_v3 0/5] Fixed and implemented set report and send data ifaces
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
v3: Fixed issues as per Johan's and Jerzy' comments and suggestions
Implemented hex2bin as a static funtion and split the patches.
v2: Fixed issues as per Johan's comments and suggestions.
This patch adds missing hid ipc documentation, hal headers,
renaming and virtual unplug notification in hid HAL.
Set report and send data interfaces are receiving data in ascii format
but it should be in hex format. Provided utility for this and fixed
set report data preparation. Implemented virtual unplug and send data
methods in daemon.
v1: This patch adds missing hid ipc documentation, hal headers,
renaming and virtual unplug notification in hid HAL.
send RFC for ascii2hex utility.
Unsupported methods are virtual unplug and send data in daemon.
Ravi kumar Veeramally (5):
android/hid: Fix set seport ipc cmd preparation
android/hid: Fix set report data format in daemon
android/hid: Fill send data command struct in hal-hidhost
android/hid: Add send data implemention in daemon
android/hid: Add virtual unplug implemention in daemon
android/hal-hidhost.c | 47 +++++++++++++++++-------
android/hal-msg.h | 2 +-
android/hidhost.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 127 insertions(+), 21 deletions(-)
--
1.8.3.2
^ permalink raw reply
* [PATCH_v3 1/5] android/hid: Fix set seport ipc cmd preparation
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383906271-23554-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Now report data is not fixed array. Allocate proper memory
and send ipc cmd.
---
android/hal-hidhost.c | 29 ++++++++++++++++++++---------
android/hal-msg.h | 2 +-
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 34f9f77..ce3dcd7 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -18,6 +18,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
+#include <stdlib.h>
#include "hal-log.h"
#include "hal.h"
@@ -297,7 +298,8 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
bthh_report_type_t report_type,
char *report)
{
- struct hal_cmd_hidhost_set_report cmd;
+ struct hal_cmd_hidhost_set_report *cmd;
+ int cmd_len, status;
DBG("");
@@ -307,26 +309,35 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
if (!bd_addr || !report)
return BT_STATUS_PARM_INVALID;
- memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- cmd.len = strlen(report);
- memcpy(cmd.data, report, cmd.len);
+ cmd_len = sizeof(*cmd) + sizeof(struct hal_cmd_hidhost_set_report)
+ + 1 + strlen(report);
+
+ cmd = malloc(cmd_len);
+ memset(cmd, 0, cmd_len);
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+ cmd->len = strlen(report);
+ memcpy(cmd->data, report, cmd->len);
switch (report_type) {
case BTHH_INPUT_REPORT:
- cmd.type = HAL_HIDHOST_INPUT_REPORT;
+ cmd->type = HAL_HIDHOST_INPUT_REPORT;
break;
case BTHH_OUTPUT_REPORT:
- cmd.type = HAL_HIDHOST_OUTPUT_REPORT;
+ cmd->type = HAL_HIDHOST_OUTPUT_REPORT;
break;
case BTHH_FEATURE_REPORT:
- cmd.type = HAL_HIDHOST_FEATURE_REPORT;
+ cmd->type = HAL_HIDHOST_FEATURE_REPORT;
break;
default:
+ free(cmd);
return BT_STATUS_PARM_INVALID;
}
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ status = hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
+ cmd_len, cmd, 0, NULL, NULL);
+ free(cmd);
+
+ return status;
}
static bt_status_t send_data(bt_bdaddr_t *bd_addr, char *data)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 851875e..7ba2e00 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -293,7 +293,7 @@ struct hal_cmd_hidhost_set_report {
uint8_t bdaddr[6];
uint8_t type;
uint16_t len;
- uint8_t data[670];
+ uint8_t data[0];
} __attribute__((packed));
#define HAL_OP_HIDHOST_SEND_DATA 0x09
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v3 2/5] android/hid: Fix set report data format in daemon
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383906271-23554-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Report data coming to HAL is in ascii format, HAL sends
data in hex to daemon, so convert to binary.
---
android/hidhost.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index c7b4114..9b4bb15 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -98,6 +98,14 @@ struct hid_device {
uint8_t last_hid_msg;
};
+static void hex2bin(const uint8_t *ascii, int ascii_len, uint8_t *hex)
+{
+ int i;
+
+ for (i = 0; i < ascii_len / 2; i++)
+ sscanf((char *) &ascii[i * 2], "%hhx", &hex[i]);
+}
+
static int device_cmp(gconstpointer s, gconstpointer user_data)
{
const struct hid_device *dev = s;
@@ -900,18 +908,20 @@ static uint8_t bt_hid_set_report(struct hal_cmd_hidhost_set_report *cmd,
return HAL_STATUS_FAILED;
dev = l->data;
- req_size = 1 + cmd->len;
+ /* Report data coming to HAL is in ascii format, HAL sends
+ * data in hex to daemon, so convert to binary. */
+ req_size = 1 + (cmd->len / 2);
req = g_try_malloc0(req_size);
if (!req)
return HAL_STATUS_NOMEM;
req[0] = HID_MSG_SET_REPORT | cmd->type;
- memcpy(req + 1, cmd->data, req_size - 1);
+ hex2bin(cmd->data, cmd->len, (req + 1));
fd = g_io_channel_unix_get_fd(dev->ctrl_io);
if (write(fd, req, req_size) < 0) {
- error("error while querying device protocol");
+ error("error while sending report");
g_free(req);
return HAL_STATUS_FAILED;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v3 3/5] android/hid: Fill send data command struct in hal-hidhost
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383906271-23554-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hal-hidhost.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index ce3dcd7..ec120ed 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -342,7 +342,8 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
static bt_status_t send_data(bt_bdaddr_t *bd_addr, char *data)
{
- struct hal_cmd_hidhost_send_data cmd;
+ struct hal_cmd_hidhost_send_data *cmd;
+ int cmd_len, status;
DBG("");
@@ -352,10 +353,19 @@ static bt_status_t send_data(bt_bdaddr_t *bd_addr, char *data)
if (!bd_addr || !data)
return BT_STATUS_PARM_INVALID;
- memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd_len = sizeof(*cmd) + sizeof(struct hal_cmd_hidhost_send_data)
+ + 1 + strlen(data);
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SEND_DATA,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ cmd = malloc(cmd_len);
+ memset(cmd, 0, cmd_len);
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+ cmd->len = strlen(data);
+ memcpy(cmd->data, data, cmd->len);
+
+ status = hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SEND_DATA,
+ cmd_len, cmd, 0, NULL, NULL);
+ free(cmd);
+ return status;
}
static bt_status_t init(bthh_callbacks_t *callbacks)
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v3 4/5] android/hid: Add send data implemention in daemon
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383906271-23554-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Send data on interrupt channel on request from hid host.
---
android/hidhost.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 9b4bb15..612dff4 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -934,9 +934,43 @@ static uint8_t bt_hid_set_report(struct hal_cmd_hidhost_set_report *cmd,
static uint8_t bt_hid_send_data(struct hal_cmd_hidhost_send_data *cmd,
uint16_t len)
{
- DBG("Not Implemented");
+ struct hid_device *dev;
+ GSList *l;
+ bdaddr_t dst;
+ int fd;
+ uint8_t *req;
+ uint8_t req_size;
- return HAL_STATUS_FAILED;
+ DBG("");
+
+ if (len < sizeof(*cmd))
+ return HAL_STATUS_INVALID;
+
+ android2bdaddr(&cmd->bdaddr, &dst);
+
+ l = g_slist_find_custom(devices, &dst, device_cmp);
+ if (!l)
+ return HAL_STATUS_FAILED;
+
+ dev = l->data;
+ req_size = 1 + (cmd->len / 2);
+ req = g_try_malloc0(req_size);
+ if (!req)
+ return HAL_STATUS_NOMEM;
+
+ req[0] = HID_MSG_DATA | HID_DATA_TYPE_OUTPUT;
+ hex2bin(cmd->data, cmd->len, (req + 1));
+
+ fd = g_io_channel_unix_get_fd(dev->intr_io);
+
+ if (write(fd, req, req_size) < 0) {
+ error("error while sending data to device");
+ g_free(req);
+ return HAL_STATUS_FAILED;
+ }
+
+ g_free(req);
+ return HAL_STATUS_SUCCESS;
}
void bt_hid_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v3 5/5] android/hid: Add virtual unplug implemention in daemon
From: Ravi kumar Veeramally @ 2013-11-08 10:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383906271-23554-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Send virtual unplug command to hid device and disconnect and remove
hid device details.
---
android/hidhost.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 612dff4..ac6a3b9 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -55,6 +55,7 @@
#define UHID_DEVICE_FILE "/dev/uhid"
/* HID message types */
+#define HID_MSG_CONTROL 0x10
#define HID_MSG_GET_REPORT 0x40
#define HID_MSG_SET_REPORT 0x50
#define HID_MSG_GET_PROTOCOL 0x60
@@ -73,6 +74,9 @@
/* HID GET REPORT Size Field */
#define HID_GET_REPORT_SIZE_FIELD 0x08
+/* HID Virtual Cable Unplug */
+#define HID_VIRTUAL_CABLE_UNPLUG 0x05
+
static int notification_sk = -1;
static GIOChannel *ctrl_io = NULL;
static GIOChannel *intr_io = NULL;
@@ -752,9 +756,46 @@ static uint8_t bt_hid_disconnect(struct hal_cmd_hidhost_disconnect *cmd,
static uint8_t bt_hid_virtual_unplug(struct hal_cmd_hidhost_vp *cmd,
uint16_t len)
{
- DBG("Not Implemented");
+ struct hid_device *dev;
+ GSList *l;
+ bdaddr_t dst;
+ uint8_t hdr;
+ int fd;
- return HAL_STATUS_FAILED;
+ DBG("");
+
+ if (len < sizeof(*cmd))
+ return HAL_STATUS_INVALID;
+
+ android2bdaddr(&cmd->bdaddr, &dst);
+
+ l = g_slist_find_custom(devices, &dst, device_cmp);
+ if (!l)
+ return HAL_STATUS_FAILED;
+
+ dev = l->data;
+ hdr = HID_MSG_CONTROL | HID_VIRTUAL_CABLE_UNPLUG;
+
+ if (!(dev->ctrl_io))
+ return HAL_STATUS_FAILED;
+
+ fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+ if (write(fd, &hdr, sizeof(hdr)) < 0) {
+ error("error while virtual unplug command");
+ return HAL_STATUS_FAILED;
+ }
+
+ /* Wait either channels to HUP */
+ if (dev->intr_io)
+ g_io_channel_shutdown(dev->intr_io, TRUE, NULL);
+
+ if (dev->ctrl_io)
+ g_io_channel_shutdown(dev->ctrl_io, TRUE, NULL);
+
+ bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTING);
+
+ return HAL_STATUS_SUCCESS;
}
static uint8_t bt_hid_info(struct hal_cmd_hidhost_set_info *cmd, uint16_t len)
--
1.8.3.2
^ permalink raw reply related
* Re: [PATCH] android: Fix pan service registration
From: Johan Hedberg @ 2013-11-08 10:46 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, Marcin Kraglak
In-Reply-To: <1383904308-15141-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon/Marcin,
On Fri, Nov 08, 2013, Szymon Janc wrote:
> From: Marcin Kraglak <marcin.kraglak@tieto.com>
>
> A2dp service was registered instead of pan.
> ---
> android/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCHv4 2/3] android/debug: Convert uuid helper to use uint8_t buffer
From: Johan Hedberg @ 2013-11-08 10:49 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383903349-17487-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Nov 08, 2013, Andrei Emeltchenko wrote:
> -char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
> +char *bt_uuid_t2str(const uint8_t *uuid, size_t len, char *buf)
I don't understand what you need the len parameter for. Won't you always
be passing 16 bytes to this function?
Johan
^ permalink raw reply
* Re: [PATCH_v3 2/5] android/hid: Fix set report data format in daemon
From: Johan Hedberg @ 2013-11-08 11:05 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383906271-23554-3-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> Report data coming to HAL is in ascii format, HAL sends
> data in hex to daemon, so convert to binary.
> ---
> android/hidhost.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/android/hidhost.c b/android/hidhost.c
> index c7b4114..9b4bb15 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -98,6 +98,14 @@ struct hid_device {
> uint8_t last_hid_msg;
> };
>
> +static void hex2bin(const uint8_t *ascii, int ascii_len, uint8_t *hex)
> +{
> + int i;
> +
> + for (i = 0; i < ascii_len / 2; i++)
> + sscanf((char *) &ascii[i * 2], "%hhx", &hex[i]);
> +}
You're still calling the input parameter ascii and the output parameter
hex. Also, I'm still fine if you just drop this function altogether and
do the conversion inline in the two places that you need it.
> if (write(fd, req, req_size) < 0) {
> - error("error while querying device protocol");
> + error("error while sending report");
If you're fixing this error, how about fixing it to properly print the
exact error in the same go, i.e. using strerror?
Johan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox