* [PATCH 3/8] android/client: Initialize all interfaces at start
From: Jerzy Kasenberg @ 2013-11-08 12:48 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1383914910-2304-1-git-send-email-jerzy.kasenberg@tieto.com>
Patch adds function that initializes all HAL interfaces.
---
android/client/haltest.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index f511025..107dfec 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -318,11 +318,47 @@ static void stdin_handler(struct pollfd *pollfd)
}
}
+static void init(void)
+{
+ static const char * const inames[] = {
+ BT_PROFILE_HANDSFREE_ID,
+ BT_PROFILE_ADVANCED_AUDIO_ID,
+ BT_PROFILE_HEALTH_ID,
+ BT_PROFILE_HIDHOST_ID,
+ BT_PROFILE_PAN_ID,
+#if PLATFORM_SDK_VERSION > 17
+ BT_PROFILE_GATT_ID,
+#endif
+ BT_PROFILE_SOCKETS_ID
+ };
+ const struct method *m;
+ const char *argv[4];
+ char init_line[] = "bluetooth init";
+ uint32_t i;
+
+ process_line(init_line);
+ m = get_interface_method("bluetooth", "get_profile_interface");
+
+ for (i = 0; i < NELEM(inames); ++i) {
+ argv[2] = inames[i];
+ m->func(3, argv);
+ }
+
+ /* Init what is available to init */
+ for (i = 1; i < NELEM(interfaces) - 1; ++i) {
+ m = get_interface_method(interfaces[i]->name, "init");
+ if (m != NULL)
+ m->func(2, argv);
+ }
+}
+
int main(int argc, char **argv)
{
struct stat rcstat;
terminal_setup();
+ init();
+
history_restore(".haltest_history");
fd_stack[fd_stack_pointer++] = 0;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/8] android/client: Add NELEM macro for count elements
From: Jerzy Kasenberg @ 2013-11-08 12:48 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1383914910-2304-1-git-send-email-jerzy.kasenberg@tieto.com>
NELEM macro will be used in several places.
---
android/client/if-main.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 647162c..dea7237 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -144,6 +144,8 @@ struct method *get_command(const char *name);
const struct method *get_interface_method(const char *iname,
const char *mname);
+#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
+
/* Helper macro for executing function on interface and printing BT_STATUS */
#define EXEC(f, ...) \
{ \
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/8] android/client: Export get_interface_method
From: Jerzy Kasenberg @ 2013-11-08 12:48 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1383914910-2304-1-git-send-email-jerzy.kasenberg@tieto.com>
This method will be used outside tab completion.c.
---
android/client/if-main.h | 2 ++
android/client/tabcompletion.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/android/client/if-main.h b/android/client/if-main.h
index f638b91..647162c 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -141,6 +141,8 @@ void add_remote_device(const bt_bdaddr_t *addr);
const struct interface *get_interface(const char *name);
struct method *get_method(struct method *methods, const char *name);
struct method *get_command(const char *name);
+const struct method *get_interface_method(const char *iname,
+ const char *mname);
/* Helper macro for executing function on interface and printing BT_STATUS */
#define EXEC(f, ...) \
diff --git a/android/client/tabcompletion.c b/android/client/tabcompletion.c
index 4a6329f..f965620 100644
--- a/android/client/tabcompletion.c
+++ b/android/client/tabcompletion.c
@@ -30,7 +30,7 @@ typedef struct split_arg {
} split_arg_t;
/* function returns method of given name or NULL if not found */
-static const struct method *get_interface_method(const char *iname,
+const struct method *get_interface_method(const char *iname,
const char *mname)
{
const struct interface *iface = get_interface(iname);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/8] Improve user experience
From: Jerzy Kasenberg @ 2013-11-08 12:48 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
This patchset works towards improving user interface.
- Command line parsing (--help, --version, --no-init)
- All interfaces are now initialized at start by default
- --no-init allows to disable this initialization
- pin_request_cb will now present prompt and send reply
- ssp_request_cb will now present prompt and sent reply
As part of adding those features terminal.c was restructured.
Big switch inside terminal_process_char was distributed between
number of small functions. This work was necessary due to input
handling of prompted data.
Version print may need to be changed according to bluez culture.
Jerzy Kasenberg (8):
android/client: Export get_interface_method
android/client: Add NELEM macro for count elements
android/client: Initialize all interfaces at start
android/client: Add command line arguments
android/client: Split terminal_process_char
android/client: Add prompting for answer
android/client: Add pin handling for bind
android/client: Add ssp key confirmation helper
android/client/haltest.c | 102 ++++++-
android/client/if-bt.c | 46 +++
android/client/if-main.h | 4 +
android/client/tabcompletion.c | 2 +-
android/client/terminal.c | 605 +++++++++++++++++++++++++++-------------
android/client/terminal.h | 5 +-
6 files changed, 567 insertions(+), 197 deletions(-)
--
1.7.9.5
^ permalink raw reply
* [PATCH_v5 3/5] android/hid: Fill send data command struct in hal-hidhost
From: Ravi kumar Veeramally @ 2013-11-08 12:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
---
android/hal-hidhost.c | 9 +++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index a0df7ce..e4a15c0 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -335,7 +335,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;
+ uint8_t buf[BLUEZ_HAL_MTU];
+ struct hal_cmd_hidhost_send_data *cmd = (void *) buf;
DBG("");
@@ -345,10 +346,13 @@ 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));
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+ cmd->len = strlen(data);
+ memcpy(cmd->data, data, cmd->len);
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SEND_DATA,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ sizeof(*cmd) + cmd->len, buf, 0, NULL, NULL);
}
static bt_status_t init(bthh_callbacks_t *callbacks)
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v5 1/5] android/hid: Fix set seport ipc cmd preparation
From: Ravi kumar Veeramally @ 2013-11-08 12:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
---
v5: Fix issues as per Johan's comemnts.
---
android/hal-hidhost.c | 18 +++++++++++--------
android/hal-msg.h | 2 +-
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 94f7e01..a0df7ce 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"
@@ -298,7 +299,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;
+ uint8_t buf[BLUEZ_HAL_MTU];
+ struct hal_cmd_hidhost_set_report *cmd = (void *) buf;
DBG("");
@@ -308,26 +310,27 @@ 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);
+ 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:
return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ sizeof(*cmd) + cmd->len, buf, 0, NULL, NULL);
}
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 4af86de..4c7d344 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
* Re: [PATCH_v4 1/5] android/hid: Fix set seport ipc cmd preparation
From: Ravi Kumar Veeramally @ 2013-11-08 12:27 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131108121531.GA1371@x220.p-661hnu-f1>
Hi Johan,
On 11/08/2013 02:15 PM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
>> - memcpy(cmd.data, report, cmd.len);
>> + memset(cmd, 0, sizeof(buf));
> How about memset(buf, 0, sizeof(buf)) to make this perfectly clear.
Ok.
> Btw,
> why is the memset needed? I don't think the original code had it. Seems
> like this is an independent bug fix?
Not in original, but in between versions (v1~v4) :(.
>
>> + 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:
>> return BT_STATUS_PARM_INVALID;
>> }
>>
>> return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
>> - sizeof(cmd), &cmd, 0, NULL, NULL);
>> + sizeof(buf), buf, 0, NULL, NULL);
> This last call looks broken to me. Shouldn't you instead of sizeof(buf)
> be sending sizeof(*cmd) + cmd->len?
yes, should be "sizeof(*cmd) + cmd->len".
>
> Johan
>
Thanks,
Ravi.
^ permalink raw reply
* [PATCH 4/4] android: Register DeviceID record when adapter is initialized
From: Szymon Janc @ 2013-11-08 12:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383913284-4032-1-git-send-email-szymon.janc@tieto.com>
Register DeviceID SDP record and update local UUIDs after DeviceID
information is passed to kernel.
---
android/adapter.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 8c4fe76..37ba988 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,10 @@
#include "utils.h"
#include "adapter.h"
+#define DEVICE_ID_SOURCE 0x0002 /* USB */
+#define DEVICE_ID_VENDOR 0x1d6b /* Linux Foundation */
+#define DEVICE_ID_PRODUCT 0x0247 /* BlueZ for Android */
+
/* Default to DisplayYesNo */
#define DEFAULT_IO_CAPABILITY 0x01
/* Default discoverable timeout 120sec as in Android */
@@ -1184,20 +1188,28 @@ static void set_device_id(void)
{
struct mgmt_cp_set_device_id cp;
uint8_t major, minor;
+ uint16_t version;
if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2)
return;
+ version = major << 8 | minor;
+
memset(&cp, 0, sizeof(cp));
- cp.source = htobs(0x0002); /* USB */
- cp.vendor = htobs(0x1d6b); /* Linux Foundation */
- cp.product = htobs(0x0247); /* BlueZ for Android */
- cp.version = htobs(major << 8 | minor);
+ cp.source = htobs(DEVICE_ID_SOURCE);
+ cp.vendor = htobs(DEVICE_ID_VENDOR);
+ cp.product = htobs(DEVICE_ID_PRODUCT);
+ cp.version = htobs(version);
if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DEVICE_ID,
adapter->index, sizeof(cp), &cp,
NULL, NULL, NULL) == 0)
error("Failed to set device id");
+
+ register_device_id(DEVICE_ID_SOURCE, DEVICE_ID_VENDOR,
+ DEVICE_ID_PRODUCT, version);
+
+ bt_adapter_add_record(PNPID_UUID, sdp_record_find(0x10000), 0x00);
}
static void set_adapter_name_complete(uint8_t status, uint16_t length,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/4] android: Add support for getting UUIDs property
From: Szymon Janc @ 2013-11-08 12:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383913284-4032-1-git-send-email-szymon.janc@tieto.com>
From: Marcin Kraglak <marcin.kraglak@tieto.com>
This method will call adapter_properties_cb with uuids of
adapter. Method is called also when uuid is added or removed.
---
android/adapter.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 8ea104b..8c4fe76 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -988,6 +988,44 @@ static void load_link_keys(GSList *keys)
}
}
+static bool get_uuids(void)
+{
+ struct hal_ev_adapter_props_changed *ev;
+ GSList *list = adapter->uuids;
+ unsigned int uuid_count = g_slist_length(list);
+ int len = uuid_count * sizeof(uint128_t);
+ uint8_t buf[BASELEN_PROP_CHANGED + len];
+ bt_uuid_t *uuid;
+ uint8_t *p;
+ int i;
+
+ memset(buf, 0, sizeof(buf));
+ ev = (void *) buf;
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_UUIDS;
+ ev->props[0].len = len;
+ p = ev->props->val;
+
+ for (; list; list = g_slist_next(list)) {
+ uuid = list->data;
+
+ /* uuids on list are in mgmt interface format and need to
+ * be swapped before sending to HAL */
+ for (i = 0; i < 16; i++)
+ p[15 - i] = uuid->value.u128.data[i];
+
+ p += sizeof(uint128_t);
+ }
+
+ ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+
+ return true;
+}
+
static void remove_uuid_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -998,6 +1036,10 @@ static void remove_uuid_complete(uint8_t status, uint16_t length,
}
mgmt_dev_class_changed_event(adapter->index, length, param, NULL);
+
+ /* send notification only if bluetooth service is registered */
+ if (notification_sk >= 0)
+ get_uuids();
}
static void remove_uuid(const uint8_t *uuid)
@@ -1006,7 +1048,6 @@ static void remove_uuid(const uint8_t *uuid)
memcpy(cp.uuid, uuid, sizeof(uint128_t));
-
mgmt_send(adapter->mgmt, MGMT_OP_REMOVE_UUID,
adapter->index, sizeof(cp), &cp,
remove_uuid_complete, NULL, NULL);
@@ -1022,6 +1063,10 @@ static void add_uuid_complete(uint8_t status, uint16_t length,
}
mgmt_dev_class_changed_event(adapter->index, length, param, NULL);
+
+ /* send notification only if bluetooth service is registered */
+ if (notification_sk >= 0)
+ get_uuids();
}
static void add_uuid(uint8_t svc_hint, const uint8_t *uuid)
@@ -1335,14 +1380,6 @@ static bool get_name(void)
return true;
}
-static bool get_uuids(void)
-{
- DBG("Not implemented");
-
- /* TODO: Add implementation */
-
- return false;
-}
static bool get_class(void)
{
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/4] android: Clear adapter uuids during initialization
From: Szymon Janc @ 2013-11-08 12:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383913284-4032-1-git-send-email-szymon.janc@tieto.com>
From: Marcin Kraglak <marcin.kraglak@tieto.com>
Clear adapter uuids during init. We have to do it before
other profiles will be able to register sdp records and add
their uuids.
---
android/adapter.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 60b2635..8ea104b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1197,6 +1197,17 @@ static uint8_t set_discoverable_timeout(uint8_t *timeout)
return HAL_STATUS_SUCCESS;
}
+
+static void clear_uuids(void)
+{
+ struct mgmt_cp_remove_uuid cp;
+
+ memset(&cp, 0, sizeof(cp));
+
+ mgmt_send(adapter->mgmt, MGMT_OP_REMOVE_UUID, adapter->index,
+ sizeof(cp), &cp, NULL, NULL, NULL);
+}
+
static void read_info_complete(uint8_t status, uint16_t length, const void *param,
void *user_data)
{
@@ -1237,6 +1248,8 @@ static void read_info_complete(uint8_t status, uint16_t length, const void *para
/* TODO: Register all event notification handlers */
register_mgmt_handlers();
+ clear_uuids();
+
load_link_keys(NULL);
set_io_capability();
--
1.8.4.2
^ permalink raw reply related
* [PATCH 1/4] android: Add and remove sdp records and uuids
From: Szymon Janc @ 2013-11-08 12:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383913284-4032-1-git-send-email-szymon.janc@tieto.com>
From: Marcin Kraglak <marcin.kraglak@tieto.com>
This is api for adding and removing sdp records and uuids
via mgmt interface. Local profiles have to store handle to
own records to remove them in cleanup. Additionally list of
uuids is created in bt_adapter struct.
---
android/Android.mk | 1 +
android/adapter.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++
android/adapter.h | 4 +++
3 files changed, 106 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index 51037a7..9f89dfd 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -39,6 +39,7 @@ LOCAL_SRC_FILES := \
../lib/sdp.c \
../lib/bluetooth.c \
../lib/hci.c \
+ ../lib/uuid.c \
../btio/btio.c \
../src/sdp-client.c \
diff --git a/android/adapter.c b/android/adapter.c
index 65b3170..60b2635 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -39,6 +39,7 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "lib/uuid.h"
+#include "src/sdpd.h"
#include "src/sdp-client.h"
#include "log.h"
#include "hal-msg.h"
@@ -74,6 +75,7 @@ struct bt_adapter {
bool discovering;
uint32_t discoverable_timeout;
+ GSList *uuids;
};
struct browse_req {
@@ -986,6 +988,105 @@ static void load_link_keys(GSList *keys)
}
}
+static void remove_uuid_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Failed to remove UUID: %s (0x%02x)",
+ mgmt_errstr(status), status);
+ return;
+ }
+
+ mgmt_dev_class_changed_event(adapter->index, length, param, NULL);
+}
+
+static void remove_uuid(const uint8_t *uuid)
+{
+ struct mgmt_cp_remove_uuid cp;
+
+ memcpy(cp.uuid, uuid, sizeof(uint128_t));
+
+
+ mgmt_send(adapter->mgmt, MGMT_OP_REMOVE_UUID,
+ adapter->index, sizeof(cp), &cp,
+ remove_uuid_complete, NULL, NULL);
+}
+
+static void add_uuid_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Failed to add UUID: %s (0x%02x)",
+ mgmt_errstr(status), status);
+ return;
+ }
+
+ mgmt_dev_class_changed_event(adapter->index, length, param, NULL);
+}
+
+static void add_uuid(uint8_t svc_hint, const uint8_t *uuid)
+{
+ struct mgmt_cp_add_uuid cp;
+
+ memcpy(cp.uuid, uuid, sizeof(uint128_t));
+ cp.svc_hint = svc_hint;
+
+ mgmt_send(adapter->mgmt, MGMT_OP_ADD_UUID,
+ adapter->index, sizeof(cp), &cp,
+ add_uuid_complete, NULL, NULL);
+}
+
+static int uuid_cmp(gconstpointer a, gconstpointer b)
+{
+ const bt_uuid_t *uuid_a = a;
+ const bt_uuid_t *uuid_b = b;
+
+ return bt_uuid_cmp(uuid_a, uuid_b);
+}
+
+int bt_adapter_add_record(const char *uuid, sdp_record_t *rec,
+ uint8_t svc_hint)
+{
+ bt_uuid_t *new_uuid;
+
+ new_uuid = g_new0(bt_uuid_t, 1);
+ bt_string_to_uuid(new_uuid, uuid);
+ if (new_uuid->type != BT_UUID128) {
+ g_free(new_uuid);
+ return -1;
+ }
+
+ if (g_slist_find_custom(adapter->uuids, new_uuid, uuid_cmp)) {
+ DBG("UUID %s already added", uuid);
+ g_free(new_uuid);
+ return -1;
+ }
+
+ adapter->uuids = g_slist_prepend(adapter->uuids, new_uuid);
+ add_uuid(svc_hint, new_uuid->value.u128.data);
+
+ return add_record_to_server(&adapter->bdaddr, rec);
+}
+
+void bt_adapter_remove_record(const char *uuid, int handle)
+{
+ bt_uuid_t bt_uuid;
+ GSList *uuid_found;
+
+ bt_string_to_uuid(&bt_uuid, uuid);
+
+ uuid_found = g_slist_find_custom(adapter->uuids, &bt_uuid, uuid_cmp);
+
+ if (uuid_found) {
+ remove_uuid(bt_uuid.value.u128.data);
+ g_free(uuid_found->data);
+ adapter->uuids = g_slist_remove(adapter->uuids,
+ uuid_found->data);
+ }
+
+ remove_record_from_server(handle);
+}
+
static void set_mode_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
diff --git a/android/adapter.h b/android/adapter.h
index c62b859..0d93917 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -32,3 +32,7 @@ const bdaddr_t *bt_adapter_get_address(void);
bool bt_adapter_register(int sk);
void bt_adapter_unregister(void);
+
+int bt_adapter_add_record(const char *uuid, sdp_record_t *rec,
+ uint8_t svc_hint);
+void bt_adapter_remove_record(const char *uuid, int handle);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 0/4] Add support for registering local SDP records
From: Szymon Janc @ 2013-11-08 12:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This adds support for manipulating local SDP database with
bt_adapter_add_record and bt_adapter_remove_record functions. Those should
be called when HAL service is registered or unregistered.
This also adds DeviceID record as at least 1 local UUID is needed by Android to
properly handle remote device profiles.
Last but not least: With this serie it is possible to connect HID device from
Android UI (Settings application). \O/
Comments are welcome.
BR
Szymon Janc
Marcin Kraglak (3):
android: Add and remove sdp records and uuids
android: Clear adapter uuids during initialization
android: Add support for getting UUIDs property
Szymon Janc (1):
android: Register DeviceID record when adapter is initialized
android/Android.mk | 1 +
android/adapter.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++++----
android/adapter.h | 4 ++
3 files changed, 180 insertions(+), 12 deletions(-)
--
1.8.4.2
^ permalink raw reply
* Re: [PATCH_v4 1/5] android/hid: Fix set seport ipc cmd preparation
From: Johan Hedberg @ 2013-11-08 12:15 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383912531-1306-2-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> - memcpy(cmd.data, report, cmd.len);
> + memset(cmd, 0, sizeof(buf));
How about memset(buf, 0, sizeof(buf)) to make this perfectly clear. Btw,
why is the memset needed? I don't think the original code had it. Seems
like this is an independent bug fix?
> + 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:
> return BT_STATUS_PARM_INVALID;
> }
>
> return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
> - sizeof(cmd), &cmd, 0, NULL, NULL);
> + sizeof(buf), buf, 0, NULL, NULL);
This last call looks broken to me. Shouldn't you instead of sizeof(buf)
be sending sizeof(*cmd) + cmd->len?
Johan
^ permalink raw reply
* [PATCH_v4 5/5] android/hid: Add virtual unplug implemention in daemon
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383912531-1306-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 | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 250288c..46f992e 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;
@@ -744,9 +748,47 @@ static uint8_t bt_hid_disconnect(struct hal_cmd_hidhost_disconnect *cmd,
static uint8_t bt_hid_virtual_unplug(struct hal_cmd_hidhost_virtual_unplug *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;
+
+ if (!(dev->ctrl_io))
+ return HAL_STATUS_FAILED;
+
+ hdr = HID_MSG_CONTROL | HID_VIRTUAL_CABLE_UNPLUG;
+
+ 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
* [PATCH_v4 4/5] android/hid: Add send data implemention in daemon
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383912531-1306-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Send data on interrupt channel on request from hid host.
---
android/hidhost.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 0e6bae0..250288c 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -931,9 +931,50 @@ 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 i, 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;
+
+ if (!(dev->intr_io))
+ return HAL_STATUS_FAILED;
+
+ 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;
+ /* Report data coming to HAL is in ascii format, HAL sends
+ * data in hex to daemon, so convert to binary. */
+ for (i = 0; i < (req_size - 1); i++)
+ sscanf((char *) &(cmd->data)[i * 2], "%hhx", &(req + 1)[i]);
+
+ 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_v4 3/5] android/hid: Fill send data command struct in hal-hidhost
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383912531-1306-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hal-hidhost.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index a0df7ce..e4a15c0 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -335,7 +335,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;
+ uint8_t buf[BLUEZ_HAL_MTU];
+ struct hal_cmd_hidhost_send_data *cmd = (void *) buf;
DBG("");
@@ -345,10 +346,13 @@ 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));
+ memset(cmd, 0, sizeof(buf));
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+ cmd->len = strlen(data);
+ memcpy(cmd->data, data, cmd->len);
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SEND_DATA,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ sizeof(buf), buf, 0, NULL, NULL);
}
static bt_status_t init(bthh_callbacks_t *callbacks)
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v4 2/5] android/hid: Fix set report data format in daemon
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383912531-1306-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 | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 242fcbc..0e6bae0 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -884,7 +884,7 @@ static uint8_t bt_hid_set_report(struct hal_cmd_hidhost_set_report *cmd,
struct hid_device *dev;
GSList *l;
bdaddr_t dst;
- int fd;
+ int i, fd;
uint8_t *req;
uint8_t req_size;
@@ -900,13 +900,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;
+
+ if (!(dev->ctrl_io))
+ return HAL_STATUS_FAILED;
+
+ 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);
+ /* Report data coming to HAL is in ascii format, HAL sends
+ * data in hex to daemon, so convert to binary. */
+ for (i = 0; i < (req_size - 1); i++)
+ sscanf((char *) &(cmd->data)[i * 2], "%hhx", &(req + 1)[i]);
fd = g_io_channel_unix_get_fd(dev->ctrl_io);
--
1.8.3.2
^ permalink raw reply related
* [PATCH_v4 1/5] android/hid: Fix set seport ipc cmd preparation
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383912531-1306-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hal-hidhost.c | 19 +++++++++++--------
android/hal-msg.h | 2 +-
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 94f7e01..a0df7ce 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"
@@ -298,7 +299,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;
+ uint8_t buf[BLUEZ_HAL_MTU];
+ struct hal_cmd_hidhost_set_report *cmd = (void *) buf;
DBG("");
@@ -308,26 +310,27 @@ 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);
+ memset(cmd, 0, sizeof(buf));
+ 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:
return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
- sizeof(cmd), &cmd, 0, NULL, NULL);
+ sizeof(buf), buf, 0, NULL, NULL);
}
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 4af86de..4c7d344 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_v4 0/5] Fixed and implemented set report and send data ifaces
From: Ravi kumar Veeramally @ 2013-11-08 12:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
v4: Fixed changes as per Johan's comments. Conversion done inside
functions now. Removed unnecessary allocation in hal-hidhost
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 | 29 ++++++++------
android/hal-msg.h | 2 +-
android/hidhost.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 116 insertions(+), 19 deletions(-)
--
1.8.3.2
^ permalink raw reply
* Re: [PATCH_v3 1/5] android/hid: Fix set seport ipc cmd preparation
From: Ravi Kumar Veeramally @ 2013-11-08 11:28 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131108110757.GD28608@x220.p-661hnu-f1>
Hi Johan,
On 11/08/2013 01:07 PM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
>> 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;
> The return type of this function is bt_status_t, not int (even though
> the two are in practice compatible).
>
> Are you sure you don't want to keep using a stack variable? You could
> potentially just define a buffer with the max mtu size and use that.
>
> Johan
Ahh , I noticed your commit 49f051b6b62 removing
unnecessary allocations. I will fix that.
Thanks,
Ravi.
^ permalink raw reply
* Re: [PATCH_v3 2/5] android/hid: Fix set report data format in daemon
From: Ravi Kumar Veeramally @ 2013-11-08 11:26 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131108110528.GC28608@x220.p-661hnu-f1>
Hi Johan,
On 11/08/2013 01:05 PM, Johan Hedberg wrote:
> 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.
Ok.
>> 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?
>
Ok, I will send this in another patch, have to fix other debugs also.
Thanks,
Ravi.
^ permalink raw reply
* Re: [PATCHv4 2/3] android/debug: Convert uuid helper to use uint8_t buffer
From: Andrei Emeltchenko @ 2013-11-08 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20131108104953.GB28608@x220.p-661hnu-f1>
Hi Johan,
On Fri, Nov 08, 2013 at 12:49:53PM +0200, Johan Hedberg wrote:
> 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?
OK I'll remove len.
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Michal Labedzki @ 2013-11-08 11:17 UTC (permalink / raw)
To: Hui Wang
Cc: Stevie Trujillo, Marcel Holtmann, tedd.an,
linux-bluetooth@vger.kernel.org development
In-Reply-To: <527C41C5.8070209@canonical.com>
Hello,
Could you create a bug for Wireshark? (capture log are welcome)
https://bugs.wireshark.org/bugzilla/buglist.cgi?resolution=3D---&query_form=
at=3Dadvanced&list_id=3D11313
I check and that is right. There are two commands shares the same
code. "Setup Synchronous Connection" and "Accept Synchronous
Connection Request". But second one should be different. I can fix
that.
Also I recommend to try latest development Wireshark - it is generally stab=
le.
On 8 November 2013 02:43, Hui Wang <hui.wang@canonical.com> wrote:
> On 11/07/2013 06:07 PM, Stevie Trujillo wrote:
>>
>> On Thu, 07 Nov 2013 11:45:53 +0800
>> Hui Wang <hui.wang@canonical.com> wrote:
>>
>>> Do you know any tools can decode the log generated by usbmon?
>>
>> Hmm, I never actually used the usbmon program. I did "modprobe usbmon",
>> then Wireshark shows usbmon{1..4} (one for each bus) as an interface
>> like eth0 for ethernet. http://wiki.wireshark.org/CaptureSetup/USB
>>
>> If it's difficult to compare two captures in Wireshark (I don't know any
>> other method than visual inspection), tshark (Wireshark's "command-line
>> counter-part") is able to decode to stdout. Maybe one can run the diff
>> program on that. The output seems a bit terse however.
>>
>> Please be aware: in my Wireshark (1.10.2) one of the of the SCO setup
>> packets are decoded slightly wrong. It looks like Wireshark is missing
>> a BDADDR in the beginning, so all the other fields get shifted.
>>
>>
> Thanks for sharing this knowledge, i will have a try according to your
> instructions.
>
> Regards,
> Hui.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--=20
Pozdrawiam / Best regards
---------------------------------------------------------------------------=
----------------------------------
Micha=C5=82 =C5=81ab=C4=99dzki, Software Engineer
Tieto Corporation
Product Development Services
http://www.tieto.com / http://www.tieto.pl
---
ASCII: Michal Labedzki
location: Swobodna 1 Street, 50-088 Wroc=C5=82aw, Poland
room: 5.01 (desk next to 5.08)
---
Please note: The information contained in this message may be legally
privileged and confidential and protected from disclosure. If the
reader of this message is not the intended recipient, you are hereby
notified that any unauthorised use, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the message and deleting it from your computer. Thank You.
---
Please consider the environment before printing this e-mail.
---
Tieto Poland sp=C3=B3=C5=82ka z ograniczon=C4=85 odpowiedzialno=C5=9Bci=C4=
=85 z siedzib=C4=85 w
Szczecinie, ul. Malczewskiego 26. Zarejestrowana w S=C4=85dzie Rejonowym
Szczecin-Centrum w Szczecinie, XIII Wydzia=C5=82 Gospodarczy Krajowego
Rejestru S=C4=85dowego pod numerem 0000124858. NIP: 8542085557. REGON:
812023656. Kapita=C5=82 zak=C5=82adowy: 4 271500 PLN
^ permalink raw reply
* Re: [PATCH_v3 1/5] android/hid: Fix set seport ipc cmd preparation
From: Johan Hedberg @ 2013-11-08 11:07 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383906271-23554-2-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Fri, Nov 08, 2013, Ravi kumar Veeramally wrote:
> 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;
The return type of this function is bt_status_t, not int (even though
the two are in practice compatible).
Are you sure you don't want to keep using a stack variable? You could
potentially just define a buffer with the max mtu size and use that.
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