* [PATCH 2/2] android/client: Change adapter to bluetooth
From: Jerzy Kasenberg @ 2013-11-05 9:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1383645382-3372-1-git-send-email-jerzy.kasenberg@tieto.com>
This fixes all places where adapter should be changed to
bluetooth.
---
android/client/haltest.c | 6 +++---
android/client/if-main.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index bbe8693..f511025 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -141,9 +141,9 @@ static void help_p(int argc, const char **argv)
terminal_print("\nTo get help on methods for each interface type:\n");
terminal_print("\n\thelp <inerface>\n");
- terminal_print("\nBasic scenario:\n\tadapter init\n");
- terminal_print("\tadapter enable\n\tadapter start_discovery\n");
- terminal_print("\tadapter get_profile_interface handsfree\n");
+ terminal_print("\nBasic scenario:\n\tbluetooth init\n");
+ terminal_print("\tbluetooth enable\n\tbluetooth start_discovery\n");
+ terminal_print("\tbluetooth get_profile_interface handsfree\n");
terminal_print("\thandsfree init\n\n");
return;
}
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 0c59054..f638b91 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -61,7 +61,7 @@ extern const btgatt_client_interface_t *if_gatt_client;
/*
* Structure defines top level interfaces that can be used in test tool
- * this will contain values as: adapter, av, gatt, sock, pan...
+ * this will contain values as: bluetooth, av, gatt, socket, pan...
*/
struct interface {
const char *name; /* interface name */
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/2] android/client: Fix style and typos
From: Jerzy Kasenberg @ 2013-11-05 9:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1383645382-3372-1-git-send-email-jerzy.kasenberg@tieto.com>
Fixes spelling errors and white space style errors.
---
android/client/history.c | 3 +++
android/client/tabcompletion.c | 21 +++++++++++++--------
android/client/terminal.c | 26 ++++++++++++++------------
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/android/client/history.c b/android/client/history.c
index 6481174..ee285da 100644
--- a/android/client/history.c
+++ b/android/client/history.c
@@ -49,13 +49,16 @@ void history_restore(const char *filename)
for (;;) {
if (fgets(line, 1000, f) != NULL) {
int l = strlen(line);
+
while (l > 0 && isspace(line[--l]))
line[l] = 0;
+
if (l > 0)
history_add_line(line);
} else
break;
}
+
fclose(f);
}
diff --git a/android/client/tabcompletion.c b/android/client/tabcompletion.c
index cc1a5d3..4a6329f 100644
--- a/android/client/tabcompletion.c
+++ b/android/client/tabcompletion.c
@@ -58,9 +58,9 @@ static void print_matches(enum_func f, void *user, const char *prefix, int len)
/*
* This function splits command line into linked list of arguments.
- * line_buffer - pointer to input comman line
+ * line_buffer - pointer to input command line
* size - size of command line to parse
- * buf - output buffer to keep splited arguments list
+ * buf - output buffer to keep split arguments list
* buf_size_in_bytes - size of buf
*/
static int split_command(const char *line_buffer, int size, split_arg_t *buf,
@@ -134,12 +134,14 @@ static void tab_completion(struct command_completion_args *args)
/* prefix does not match */
if (strncmp(enum_name, name, len) != 0)
continue;
+
/* prefix matches first time */
if (count++ == 0) {
strcpy(prefix, enum_name);
prefix_len = strlen(prefix);
continue;
}
+
/*
* Prefix matches next time
* reduce prefix to common part
@@ -158,12 +160,13 @@ static void tab_completion(struct command_completion_args *args)
tab_hit_count = 0;
return;
}
+
/* len == prefix_len => nothing new was added */
if (len == prefix_len) {
if (count != 1) {
- if (tab_hit_count == 1)
+ if (tab_hit_count == 1) {
putchar('\a');
- else if (tab_hit_count == 2 ||
+ } else if (tab_hit_count == 2 ||
args->help == NULL) {
print_matches(args->func,
args->user, name, len);
@@ -182,6 +185,7 @@ static void tab_completion(struct command_completion_args *args)
prefix[prefix_len++] = ' ';
prefix[prefix_len] = '\0';
}
+
terminal_insert_into_command_line(prefix + len);
tab_hit_count = 0;
}
@@ -304,7 +308,7 @@ static const char *return_null(void *user, int i)
* parameter completion function
* argc - number of elements in arg list
* arg - list of arguments
- * megthod - method to get completion from (can be NULL)
+ * method - method to get completion from (can be NULL)
*/
static void param_completion(int argc, const split_arg_t *arg,
const struct method *method, int hlpix)
@@ -339,9 +343,9 @@ static void param_completion(int argc, const split_arg_t *arg,
}
/*
- * This methd gets called when user tapped tab key.
- * line - points to comman line
- * len - size of line that should be used for comletions. This should be
+ * This method gets called when user tapped tab key.
+ * line - points to command line
+ * len - size of line that should be used for completions. This should be
* cursor position during tab hit.
*/
void process_tab(const char *line, int len)
@@ -360,6 +364,7 @@ void process_tab(const char *line, int len)
command_completion(buf);
return;
}
+
method = get_command(buf[0].ntcopy);
if (method != NULL) {
param_completion(argc, buf, method, 1);
diff --git a/android/client/terminal.c b/android/client/terminal.c
index 22a1d8a..b152bf3 100644
--- a/android/client/terminal.c
+++ b/android/client/terminal.c
@@ -99,8 +99,8 @@ static const struct ansii_sequence ansii_sequnces[] = {
#define isseqence(c) ((c) == 0x1B)
/*
- * Number of characters that consist of ANSII sequence
- * Should not be less then longest string in ansii_sequnces
+ * Number of characters that consist of ANSI sequence
+ * Should not be less then longest string in ansi_sequences
*/
#define MAX_ASCII_SEQUENCE 10
@@ -139,7 +139,7 @@ static void terminal_move_cursor(int n)
void terminal_draw_command_line(void)
{
/*
- * this needs to be checked here since line_buf is not cleard
+ * this needs to be checked here since line_buf is not cleared
* before parsing event though line_len and line_buf_ix are
*/
if (line_len > 0)
@@ -240,7 +240,7 @@ static void terminal_clear_line(void)
terminal_line_replaced();
}
-static void terminal_clear_sceen(void)
+static void terminal_clear_screen(void)
{
line_buf[0] = '\0';
line_buf_ix = 0;
@@ -312,7 +312,7 @@ static void terminal_match_hitory(bool back)
if (matching_line >= 0) {
int pos = line_buf_ix;
terminal_get_line_from_history(matching_line);
- /* move back to cursor position to origianl place */
+ /* move back to cursor position to original place */
line_buf_ix = pos;
terminal_move_cursor(pos - line_len);
}
@@ -328,12 +328,13 @@ static int terminal_convert_sequence(int c)
/* Not in sequence yet? */
if (current_sequence_len == -1) {
- /* Is ansii sequence detected by 0x1B ? */
+ /* Is ansi sequence detected by 0x1B ? */
if (isseqence(c)) {
current_sequence_len++;
return KEY_SEQUNCE_NOT_FINISHED;
- }
- return c;
+ }
+
+ return c;
}
/* Inside sequence */
@@ -350,11 +351,12 @@ static int terminal_convert_sequence(int c)
current_sequence_len = -1;
return ansii_sequnces[i].code;
}
+
/* partial match (not whole sequence yet) */
return KEY_SEQUNCE_NOT_FINISHED;
}
- terminal_print("ansii char 0x%X %c\n", c);
+ terminal_print("ansi char 0x%X %c\n", c);
/*
* Sequence does not match
* mark that no in sequence any more, return char
@@ -421,7 +423,7 @@ void terminal_process_char(int c, void (*process_line)(char *line))
line_buf_ix--;
/* skip all non spaces to the left */
while (line_buf_ix > 0 &&
- !isspace(line_buf[line_buf_ix - 1]))
+ !isspace(line_buf[line_buf_ix - 1]))
line_buf_ix--;
/* move cursor to new position */
terminal_move_cursor(line_buf_ix - old_pos);
@@ -538,7 +540,7 @@ void terminal_process_char(int c, void (*process_line)(char *line))
}
break;
case KEY_C_L:
- terminal_clear_sceen();
+ terminal_clear_screen();
break;
default:
if (!isprint(c)) {
@@ -592,7 +594,7 @@ void terminal_setup(void)
/*
* Turn off echo since all editing is done by hand,
- * Ctrl-c handled internaly
+ * Ctrl-c handled internally
*/
tios.c_lflag &= ~(ICANON | ECHO | BRKINT | IGNBRK);
tcsetattr(0, TCSANOW, &tios);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/2] Style, typo and naming fixes
From: Jerzy Kasenberg @ 2013-11-05 9:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
This patchset fixes obvious spelling errors.
It also changes adapter to bluetooth in help and comments.
Few white space errors also were fixed.
Jerzy Kasenberg (2):
android/client: Fix style and typos
android/client: Change adapter to bluetooth
android/client/haltest.c | 6 +++---
android/client/history.c | 3 +++
android/client/if-main.h | 2 +-
android/client/tabcompletion.c | 21 +++++++++++++--------
android/client/terminal.c | 26 ++++++++++++++------------
5 files changed, 34 insertions(+), 24 deletions(-)
--
1.7.9.5
^ permalink raw reply
* [PATCH] android: Add Android Makefile for btmon
From: Andrei Emeltchenko @ 2013-11-05 9:46 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Build btmon for Android image. btmon requires fresh bionic to build.
---
android/Android.mk | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index 77fd5a0..86af7b6 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -145,3 +145,58 @@ LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := haltest
include $(BUILD_EXECUTABLE)
+
+#
+# btmon
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ ../monitor/main.c \
+ ../monitor/bt.h \
+ ../monitor/mainloop.h \
+ ../monitor/mainloop.c \
+ ../monitor/display.h \
+ ../monitor/display.c \
+ ../monitor/hcidump.h \
+ ../monitor/hcidump.c \
+ ../monitor/btsnoop.h \
+ ../monitor/btsnoop.c \
+ ../monitor/control.h \
+ ../monitor/control.c \
+ ../monitor/packet.h \
+ ../monitor/packet.c \
+ ../monitor/l2cap.h \
+ ../monitor/l2cap.c \
+ ../monitor/uuid.h \
+ ../monitor/uuid.c \
+ ../monitor/sdp.h \
+ ../monitor/sdp.c \
+ ../monitor/vendor.h \
+ ../monitor/vendor.c \
+ ../monitor/lmp.h \
+ ../monitor/lmp.c \
+ ../monitor/crc.h \
+ ../monitor/crc.c \
+ ../monitor/ll.h \
+ ../monitor/ll.c \
+ ../lib/hci.c \
+ ../lib/bluetooth.c \
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../src/shared \
+
+LOCAL_C_INCLUDES += \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)/glib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := btmon
+
+include $(BUILD_EXECUTABLE)
--
1.7.10.4
^ permalink raw reply related
* [PATCH] net: bluetooth: fix crash in l2cap_chan_send after l2cap_chan_del
From: Seung-Woo Kim @ 2013-11-05 9:46 UTC (permalink / raw)
To: linux-bluetooth, johan.hedberg; +Cc: marcel, gustavo, sw0312.kim, s.syam
In-Reply-To: <20131101075718.GA13221@x220.p-661hnu-f1>
Removing a bond and disconnecting from a specific remote device
can cause l2cap_chan_send() is called after l2cap_chan_del() is
called. This causes following crash.
[ 1384.972086] Unable to handle kernel NULL pointer dereference at virtual address 00000008
[ 1384.972090] pgd = c0004000
[ 1384.972125] [00000008] *pgd=00000000
[ 1384.972137] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
[ 1384.972144] Modules linked in:
[ 1384.972156] CPU: 0 PID: 841 Comm: krfcommd Not tainted 3.10.14-gdf22a71-dirty #435
[ 1384.972162] task: df29a100 ti: df178000 task.ti: df178000
[ 1384.972182] PC is at l2cap_create_basic_pdu+0x30/0x1ac
[ 1384.972191] LR is at l2cap_chan_send+0x100/0x1d4
[ 1384.972198] pc : [<c051d250>] lr : [<c0521c78>] psr: 40000113
[ 1384.972198] sp : df179d40 ip : c083a010 fp : 00000008
[ 1384.972202] r10: 00000004 r9 : 0000065a r8 : 000003f5
[ 1384.972206] r7 : 00000000 r6 : 00000000 r5 : df179e84 r4 : da557000
[ 1384.972210] r3 : 00000000 r2 : 00000004 r1 : df179e84 r0 : 00000000
[ 1384.972215] Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 1384.972220] Control: 10c53c7d Table: 5c8b004a DAC: 00000015
[ 1384.972224] Process krfcommd (pid: 841, stack limit = 0xdf178238)
[ 1384.972229] Stack: (0xdf179d40 to 0xdf17a000)
[ 1384.972238] 9d40: 00000000 da557000 00000004 df179e84 00000004 000003f5 0000065a 00000000
[ 1384.972245] 9d60: 00000008 c0521c78 df179e84 da557000 00000004 da557204 de0c6800 df179e84
[ 1384.972253] 9d80: da557000 00000004 da557204 c0526b7c 00000004 df724000 df179e84 00000004
[ 1384.972260] 9da0: df179db0 df29a100 c083bc48 c045481c 00000001 00000000 00000000 00000000
[ 1384.972267] 9dc0: 00000000 df29a100 00000000 00000000 00000000 00000000 df179e10 00000000
[ 1384.972274] 9de0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1384.972281] 9e00: 00000000 00000000 00000000 00000000 df179e4c c000ec80 c0b538c0 00000004
[ 1384.972288] 9e20: df724000 df178000 00000000 df179e84 c0b538c0 00000000 df178000 c07f4570
[ 1384.972295] 9e40: dcad9c00 df179e74 c07f4394 df179e60 df178000 00000000 df179e84 de247010
[ 1384.972303] 9e60: 00000043 c0454dec 00000001 00000004 df315c00 c0530598 00000004 df315c0c
[ 1384.972310] 9e80: ffffc32c 00000000 00000000 df179ea0 00000001 00000000 00000000 00000000
[ 1384.972317] 9ea0: df179ebc 00000004 df315c00 c05df838 00000000 c0530810 c07d08c0 d7017303
[ 1384.972325] 9ec0: 6ec245b9 00000000 df315c00 c0531b04 c07f3fe0 c07f4018 da67a300 df315c00
[ 1384.972332] 9ee0: 00000000 c05334e0 df315c00 df315b80 df315c00 de0c6800 da67a300 00000000
[ 1384.972339] 9f00: de0c684c c0533674 df204100 df315c00 df315c00 df204100 df315c00 c082b138
[ 1384.972347] 9f20: c053385c c0533754 a0000113 df178000 00000001 c083bc48 00000000 c053385c
[ 1384.972354] 9f40: 00000000 00000000 00000000 c05338c4 00000000 df9f0000 df9f5ee4 df179f6c
[ 1384.972360] 9f60: df178000 c0049db4 00000000 00000000 c07f3ff8 00000000 00000000 00000000
[ 1384.972368] 9f80: df179f80 df179f80 00000000 00000000 df179f90 df179f90 df9f5ee4 c0049cfc
[ 1384.972374] 9fa0: 00000000 00000000 00000000 c000f168 00000000 00000000 00000000 00000000
[ 1384.972381] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1384.972388] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00010000 00000600
[ 1384.972411] [<c051d250>] (l2cap_create_basic_pdu+0x30/0x1ac) from [<c0521c78>] (l2cap_chan_send+0x100/0x1d4)
[ 1384.972425] [<c0521c78>] (l2cap_chan_send+0x100/0x1d4) from [<c0526b7c>] (l2cap_sock_sendmsg+0xa8/0x104)
[ 1384.972440] [<c0526b7c>] (l2cap_sock_sendmsg+0xa8/0x104) from [<c045481c>] (sock_sendmsg+0xac/0xcc)
[ 1384.972453] [<c045481c>] (sock_sendmsg+0xac/0xcc) from [<c0454dec>] (kernel_sendmsg+0x2c/0x34)
[ 1384.972469] [<c0454dec>] (kernel_sendmsg+0x2c/0x34) from [<c0530598>] (rfcomm_send_frame+0x58/0x7c)
[ 1384.972481] [<c0530598>] (rfcomm_send_frame+0x58/0x7c) from [<c0530810>] (rfcomm_send_ua+0x98/0xbc)
[ 1384.972494] [<c0530810>] (rfcomm_send_ua+0x98/0xbc) from [<c0531b04>] (rfcomm_recv_disc+0xac/0x100)
[ 1384.972506] [<c0531b04>] (rfcomm_recv_disc+0xac/0x100) from [<c05334e0>] (rfcomm_recv_frame+0x144/0x264)
[ 1384.972519] [<c05334e0>] (rfcomm_recv_frame+0x144/0x264) from [<c0533674>] (rfcomm_process_rx+0x74/0xfc)
[ 1384.972531] [<c0533674>] (rfcomm_process_rx+0x74/0xfc) from [<c0533754>] (rfcomm_process_sessions+0x58/0x160)
[ 1384.972543] [<c0533754>] (rfcomm_process_sessions+0x58/0x160) from [<c05338c4>] (rfcomm_run+0x68/0x110)
[ 1384.972558] [<c05338c4>] (rfcomm_run+0x68/0x110) from [<c0049db4>] (kthread+0xb8/0xbc)
[ 1384.972576] [<c0049db4>] (kthread+0xb8/0xbc) from [<c000f168>] (ret_from_fork+0x14/0x2c)
[ 1384.972586] Code: e3100004 e1a07003 e5946000 1a000057 (e5969008)
[ 1384.972614] ---[ end trace 6170b7ce00144e8c ]---
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
I can reproduce this crash with bluetooth-next kernel merged onto my v3.10
system. It is usually happens when the device is at sleep state and remote
device disconnects and removes bonding.
This patch is based on bluetooth-next tree.
---
net/bluetooth/l2cap_core.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0cef677..4af3821 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2439,6 +2439,9 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
int err;
struct sk_buff_head seg_queue;
+ if (!chan->conn)
+ return -ENOTCONN;
+
/* Connectionless channel */
if (chan->chan_type == L2CAP_CHAN_CONN_LESS) {
skb = l2cap_create_connless_pdu(chan, msg, len, priority);
--
1.7.4.1
^ permalink raw reply related
* [PATCH] Bluetooth: Fix rejecting SMP security request in slave role
From: johan.hedberg @ 2013-11-05 9:30 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The SMP security request is for a slave role device to request the
master role device to initiate a pairing request. If we receive this
command while we're in the slave role we should reject it appropriately.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/smp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 85a2796cac61..4b07acb8293c 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -742,6 +742,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn);
+ if (!(conn->hcon->link_mode & HCI_LM_MASTER))
+ return SMP_CMD_NOTSUPP;
+
hcon->pending_sec_level = authreq_to_seclevel(rp->auth_req);
if (smp_ltk_encrypt(conn, hcon->pending_sec_level))
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] android/daemon: Send update name notification on mgmt evt
From: Luiz Augusto von Dentz @ 2013-11-05 9:05 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1383641621-25933-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Tue, Nov 5, 2013 at 10:53 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Wehen receiving mgmt event local_name_changed we shall send notification
> to the HAL that local name is changed.
> ---
> android/adapter.c | 46 +++++++++++++++++++++++-----------------------
> 1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/android/adapter.c b/android/adapter.c
> index 383cf07..b6f6096 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -66,6 +66,28 @@ struct bt_adapter {
> static struct bt_adapter *adapter;
> static GSList *found_devices = NULL;
>
> +static void adapter_name_changed(const uint8_t *name)
> +{
> + struct hal_ev_adapter_props_changed *ev;
> + size_t len = strlen((const char *) name);
> + uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
> +
> + memset(buf, 0, sizeof(buf));
> + ev = (void *) buf;
> +
> + ev->num_props = 1;
> + ev->status = HAL_STATUS_SUCCESS;
> + ev->props[0].type = HAL_PROP_ADAPTER_NAME;
> + /* Android expects value without NULL terminator */
> + ev->props[0].len = len;
> + memcpy(ev->props->val, name, len);
> +
> + DBG("Adapter name changed to: %s", name);
> +
> + ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
> + HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
> +}
> +
> static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
> const void *param, void *user_data)
> {
> @@ -84,7 +106,7 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
> g_free(adapter->name);
> adapter->name = g_strdup((const char *) rp->name);
>
> - /* TODO Update services if needed */
> + adapter_name_changed(rp->name);
> }
This is okay, but you should call this function from
set_adapter_name_complete to make sure we are synchronized with the
upper stack.
^ permalink raw reply
* [PATCH] android/daemon: Send update name notification on mgmt evt
From: Andrei Emeltchenko @ 2013-11-05 8:53 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Wehen receiving mgmt event local_name_changed we shall send notification
to the HAL that local name is changed.
---
android/adapter.c | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 383cf07..b6f6096 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -66,6 +66,28 @@ struct bt_adapter {
static struct bt_adapter *adapter;
static GSList *found_devices = NULL;
+static void adapter_name_changed(const uint8_t *name)
+{
+ struct hal_ev_adapter_props_changed *ev;
+ size_t len = strlen((const char *) name);
+ uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
+
+ memset(buf, 0, sizeof(buf));
+ ev = (void *) buf;
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+ ev->props[0].type = HAL_PROP_ADAPTER_NAME;
+ /* Android expects value without NULL terminator */
+ ev->props[0].len = len;
+ memcpy(ev->props->val, name, len);
+
+ DBG("Adapter name changed to: %s", name);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+}
+
static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
@@ -84,7 +106,7 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
g_free(adapter->name);
adapter->name = g_strdup((const char *) rp->name);
- /* TODO Update services if needed */
+ adapter_name_changed(rp->name);
}
static void powered_changed(void)
@@ -142,28 +164,6 @@ static void scan_mode_changed(void)
g_free(ev);
}
-static void adapter_name_changed(const uint8_t *name)
-{
- struct hal_ev_adapter_props_changed *ev;
- size_t len = strlen((const char *) name);
- uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
-
- memset(buf, 0, sizeof(buf));
- ev = (void *) buf;
-
- ev->num_props = 1;
- ev->status = HAL_STATUS_SUCCESS;
- ev->props[0].type = HAL_PROP_ADAPTER_NAME;
- /* Android expects value without NULL terminator */
- ev->props[0].len = len;
- memcpy(ev->props->val, name, len);
-
- DBG("Adapter name changed to: %s", name);
-
- ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
- HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
-}
-
static void settings_changed(uint32_t settings)
{
uint32_t changed_mask;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH 07/11] android/hid: Implement hid set report in daemon
From: Johan Hedberg @ 2013-11-05 8:31 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383603615-9953-8-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
> This patch requests hid device to set report.
> ---
> android/hal-hidhost.c | 1 +
> android/hal-msg.h | 1 +
> android/hid.c | 40 ++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 40 insertions(+), 2 deletions(-)
Again, split this into separate patches.
> diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
> index 027e3b8..040d517 100644
> --- a/android/hal-hidhost.c
> +++ b/android/hal-hidhost.c
> @@ -284,6 +284,7 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
> return BT_STATUS_PARM_INVALID;
>
> memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
> + cmd.report = report;
>
> switch (reportType) {
> case BTHH_INPUT_REPORT:
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index eaa5c9c..e1fd027 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -292,6 +292,7 @@ struct hal_cmd_hid_get_report {
> struct hal_cmd_hid_set_report {
> uint8_t bdaddr[6];
> uint8_t type;
> + char *report;
> } __attribute__((packed));
Seriously? Trying to send pointers over IPC :)
Also verify that whatever you add matches what we have in
hal-ipc-api.txt (and if the API documentation is wrong or missing
something fix it).
Johan
^ permalink raw reply
* Re: [PATCH 11/11] android/hid: Handle uhid events
From: Andrei Emeltchenko @ 2013-11-05 8:29 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383603615-9953-12-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Tue, Nov 05, 2013 at 12:20:15AM +0200, Ravi kumar Veeramally wrote:
> Handling few uhid events and described scenarios. OUTPUT and
> FEATURE events are not yet handled.
> ---
> android/hid.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/android/hid.c b/android/hid.c
> index 74de02f..fccaa87 100644
> --- a/android/hid.c
> +++ b/android/hid.c
> @@ -149,6 +149,11 @@ static void hid_device_free(struct hid_device *dev)
> g_free(dev);
> }
>
> +static void handle_uhid_event(struct hid_device *dev, struct uhid_event *ev)
> +{
> + DBG("unsupported event");
> +}
> +
> static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
> gpointer user_data)
> {
> @@ -172,7 +177,40 @@ static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
> }
>
> DBG("uHID event type %d received", ev.type);
> - /* TODO Handle events */
> +
> + switch (ev.type) {
> + case UHID_START:
> + case UHID_STOP:
> + /* These are called to start and stop the underlying hardware.
> + * We open the channels before creating the device so the
> + * hardware is always ready. No need to handle these.
> + * The kernel never destroys a device itself! Only an explicit
> + * UHID_DESTROY request can remove a device. */
> +
> + break;
> + case UHID_OPEN:
> + case UHID_CLOSE:
> + /* OPEN/CLOSE are sent whenever user-space opens any interface
> + * provided by the kernel HID device. Whenever the open-count
> + * is non-zero we must be ready for I/O. As long as it is zero,
> + * we can decide to drop all I/O and put the device
> + * asleep This is optional, though. */
> + break;
> + case UHID_OUTPUT:
> + case UHID_FEATURE:
> + handle_uhid_event(dev, &ev);
> + break;
> + case UHID_OUTPUT_EV:
> + /* This is only sent by kernels prior to linux-3.11. It
> + * requires us to parse HID-descriptors in user-space to
> + * properly handle it. This is redundant as the kernel
> + * does it already. That's why newer kernels assemble
> + * the output-reports and send it to us via UHID_OUTPUT. */
> + DBG("Unsupported uHID event: type %d", ev.u.output_ev.type);
Use handle_uhid_event helper? You could add printing event type there.
Best regards
Andrei Emeltchenko
> + break;
> + default:
> + warn("unexpected uHID event");
> + }
>
> return TRUE;
>
> --
> 1.8.1.2
>
> --
> 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
^ permalink raw reply
* Re: [PATCH 06/11] android/hid: Implement hid get report in daemon
From: Johan Hedberg @ 2013-11-05 8:29 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383603615-9953-7-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
> This patch requests hid device report and reads reply
> message and sends notification to hal.
> ---
> android/hal-hidhost.c | 1 +
> android/hal-msg.h | 8 ++++
> android/hid.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 111 insertions(+), 2 deletions(-)
Again, I'd split this into separate patches. One to update the
hal-msg.h, one for the daemon and another for the HAL.
> +#define HAL_EV_HID_GET_REPORT 0x84
> +struct hal_ev_hid_get_report {
> + uint8_t bdaddr[6];
> + uint8_t status;
> + uint16_t len;
> + uint8_t data[0];
> +} __attribute__((packed));
In our hal-ipc.api.txt this event is defined as 0x85. Not 0x84. Is the
code or documentation wrong?
Also, please follow the same alignment for the variables in the struct
as elsewhere in hal-msg.h.
Johan
^ permalink raw reply
* Re: [PATCH 03/11] android/hid: Implement hid get protocol in daemon
From: Johan Hedberg @ 2013-11-05 8:24 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383603615-9953-4-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
> This patch requests hid device protocol mode and reads reply
> message and sends notification to hal.
> ---
> android/hal-msg.h | 9 +++++
> android/hid.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 113 insertions(+), 4 deletions(-)
I've applied patches 1 and 2, but from this one onwards there were
sevaral issues.
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index f381862..214daa9 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -442,6 +442,8 @@ struct hal_ev_hid_conn_state {
> uint8_t state;
> } __attribute__((packed));
>
> +#define HAL_HID_STATUS_OK 0x00
> +
> #define HAL_EV_HID_INFO 0x82
> struct hal_ev_hid_info {
> uint8_t bdaddr[6];
> @@ -456,6 +458,13 @@ struct hal_ev_hid_info {
> uint8_t descr[884];
> } __attribute__((packed));
>
> +#define HAL_EV_HID_PROTO_MODE 0x83
> +struct hal_ev_hid_protocol {
> + uint8_t bdaddr[6];
> + uint8_t status;
> + uint8_t mode;
> +} __attribute__((packed));
To be consistent, shouldn't the struct be called hal_ev_hid_proto_mode?
Also, I'd split this hal-msg.h update into a separate patch. Am I right
to assume hal-ipc-api.txt doesn't need updating for this one?
> @@ -76,6 +84,7 @@ struct hid_device {
> guint intr_watch;
> int uhid_fd;
> guint uhid_watch_id;
> + int hid_msg;
> };
>
> static int device_cmp(gconstpointer s, gconstpointer user_data)
> @@ -243,12 +252,74 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond,
> return FALSE;
> }
>
> +static void bt_hid_notify_protocol_mode(struct hid_device *dev, uint8_t *buf,
> + int len)
To be consistent with the struct names you might use "proto" instead of
"protocol" here.
> +static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
> +{
> + struct hid_device *dev = data;
> + int fd, bread;
> + uint8_t buf[UHID_DATA_MAX];
> +
> + DBG("");
> +
> + fd = g_io_channel_unix_get_fd(chan);
> + bread = read(fd, buf, sizeof(buf));
> + if (bread < 0) {
> + error("read: %s(%d)", strerror(errno), -errno);
> + return TRUE;
> + }
> +
> + switch (dev->hid_msg) {
> + case HID_MSG_GET_PROTOCOL:
> + bt_hid_notify_protocol_mode(dev, buf, bread);
> + break;
> + default:
> + DBG("unhandled hid msg type 0x%02x", dev->hid_msg);
> + }
> +
> + /* reset msg type request */
> + dev->hid_msg = -1;
Do we really need to do this tracking of what we wrote to the socket.
Isn't it possible to infer the type of procedure from the content of the
data that we read from the socket?
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Fix to set proper bdaddr_type for RFCOMM connect
From: Seung-Woo Kim @ 2013-11-05 8:15 UTC (permalink / raw)
To: linux-bluetooth, marcel; +Cc: gustavo, johan.hedberg, sw0312.kim, s.syam
In-Reply-To: <FF845DCC-A87F-4B35-A9A4-0F031DC7CE0B@holtmann.org>
L2CAP socket validates proper bdaddr_type for connect, so this
patch fixes to set explictly bdaddr_type for RFCOMM connect.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
net/bluetooth/rfcomm/core.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index ca55ea1..facd8a7 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -720,6 +720,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = __constant_cpu_to_le16(RFCOMM_PSM);
addr.l2_cid = 0;
+ addr.l2_bdaddr_type = BDADDR_BREDR;
*err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
if (*err == 0 || *err == -EINPROGRESS)
return s;
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH 1/2] Bluetooth: Remove unneeded check in hci_disconn_complete_evt()
From: Johan Hedberg @ 2013-11-05 8:09 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1383587847-16523-2-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
On Mon, Nov 04, 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 checking this flag in hci_
> disconn_complete_evt() since neither mgmt_disconnect_failed() nor
> mgmt_device_disconnected() depend on it. Below follows more details:
> * mgmt_disconnect_failed() removes pending MGMT_OP_DISCONNECT
> commands, it doesn't matter if that connection was notified or not.
> * mgmt_device_disconnected() sends the mgmt event only if the link
> type is ACL_LINK or LE_LINK. For those connection type, the flag is
> always set.
>
> So this patch removes the HCI_CONN_MGMT_CONNECTED check.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> net/bluetooth/hci_event.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 142aa61..560296d 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1792,16 +1792,14 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> if (ev->status == 0)
> conn->state = BT_CLOSED;
>
> - if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) {
> - if (ev->status) {
> - mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
> - conn->dst_type, ev->status);
> - } else {
> - u8 reason = hci_to_mgmt_reason(ev->reason);
> + if (ev->status) {
> + mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
> + conn->dst_type, ev->status);
> + } else {
> + u8 reason = hci_to_mgmt_reason(ev->reason);
>
> - mgmt_device_disconnected(hdev, &conn->dst, conn->type,
> - conn->dst_type, reason);
> - }
> + mgmt_device_disconnected(hdev, &conn->dst, conn->type,
> + conn->dst_type, reason);
> }
>
> if (ev->status == 0) {
It looks to me like this would cause an invalid mgmt_device_disconnected
event to be sent of the ACL goes down before we notify over mgmt that
it's connected. This could e.g. happen if the ACL disconnection happens
before we complete the implicit name resolving (which is the main reason
why this flag exists to begin with). Am I missing something here?
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix RFCOMM bind fail for L2CAP sock
From: Marcel Holtmann @ 2013-11-05 7:58 UTC (permalink / raw)
To: Seung-Woo Kim
Cc: linux-bluetooth@vger.kernel.org development, Gustavo F. Padovan,
Johan Hedberg, Syam Sidhardhan
In-Reply-To: <5278A066.5020409@samsung.com>
Hi Seung-Woo,
>>> L2CAP socket bind checks its bdaddr type but RFCOMM kernel thread
>>> does not assign proper bdaddr type for L2CAP sock. This can cause
>>> that RFCOMM failure.
>>>
>>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>>> ---
>>> The issue is came from following commit, but it is only in bluetooth-next tree,
>>> so this patch is not needed for stable tree.
>>>
>>> commit 80c1a2e76dbb36588facb265ab364b1302f7ef8c
>>> Author: Johan Hedberg <johan.hedberg@intel.com>
>>> Date: Mon Oct 14 21:17:52 2013 +0300
>>>
>>> Bluetooth: Reject invalid bdaddr types for sockets
>>>
>>> This patch is based on commit cca34b785a21d220176038c45071ffe842e99fd3 of
>>> bluetooth-next tree.
>>> ---
>>> net/bluetooth/rfcomm/core.c | 2 ++
>>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> good catch. Patch has been applied to bluetooth-next tree.
>>
>> You might also want to send a patch that adds the l2_bdaddr_type setting before the connect() call.
>
> Case of kernel_connect() in rfcomm_session_create(), it reuses
> l2_bdaddr_type used for kernel_bind(), so it works fine for me: I tested
> both incoming connection and outgoing connection cases of rfcomm.
> But if you prefer explicit setting for connect(), please let me know.
I realized that it will just work fine. But it is better style to add an explicit setting in the connect() case as well. It is less error prone in the future.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix RFCOMM bind fail for L2CAP sock
From: Seung-Woo Kim @ 2013-11-05 7:38 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth@vger.kernel.org development, Gustavo F. Padovan,
Johan Hedberg, Syam Sidhardhan, Seung-Woo Kim
In-Reply-To: <CE0DCFC3-31E3-4693-9C7C-703CA43A0883@holtmann.org>
Hello Marcel Holtmann,
On 2013년 11월 05일 16:26, Marcel Holtmann wrote:
> Hi Seung-Woo,
>
>> L2CAP socket bind checks its bdaddr type but RFCOMM kernel thread
>> does not assign proper bdaddr type for L2CAP sock. This can cause
>> that RFCOMM failure.
>>
>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>> ---
>> The issue is came from following commit, but it is only in bluetooth-next tree,
>> so this patch is not needed for stable tree.
>>
>> commit 80c1a2e76dbb36588facb265ab364b1302f7ef8c
>> Author: Johan Hedberg <johan.hedberg@intel.com>
>> Date: Mon Oct 14 21:17:52 2013 +0300
>>
>> Bluetooth: Reject invalid bdaddr types for sockets
>>
>> This patch is based on commit cca34b785a21d220176038c45071ffe842e99fd3 of
>> bluetooth-next tree.
>> ---
>> net/bluetooth/rfcomm/core.c | 2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> good catch. Patch has been applied to bluetooth-next tree.
>
> You might also want to send a patch that adds the l2_bdaddr_type setting before the connect() call.
Case of kernel_connect() in rfcomm_session_create(), it reuses
l2_bdaddr_type used for kernel_bind(), so it works fine for me: I tested
both incoming connection and outgoing connection cases of rfcomm.
But if you prefer explicit setting for connect(), please let me know.
Best Regards,
- Seung-Woo Kim
>
> Regards
>
> Marcel
>
>
--
Seung-Woo Kim
Samsung Software R&D Center
--
^ permalink raw reply
* RE: [BUG] Crash during disconnecting and removing bond from remote device
From: 김승우 @ 2013-11-05 7:29 UTC (permalink / raw)
To: 'Johan Hedberg'; +Cc: linux-bluetooth, s.syam, sw0312.kim
In-Reply-To: <20131101075718.GA13221@x220.p-661hnu-f1>
Hi Johan Hedberg,
Sorry for late response.
> -----Original Message-----
> From: Johan Hedberg [mailto:johan.hedberg@gmail.com]
> Sent: Friday, November 01, 2013 4:57 PM
> To: Seung-Woo Kim
> Cc: linux-bluetooth@vger.kernel.org; s.syam@samsung.com
> Subject: Re: [BUG] Crash during disconnecting and removing bond from
> remote device
>
> Hi Seung-Woo Kim,
>
> On Mon, Oct 28, 2013, Seung-Woo Kim wrote:
> > I used 3.10.14 with RFCOMM tty patches in 3.12-rc, and I tested
> > disconnecting and removing a bond from remote device. and I got
> > following crash.
>
> This looks like a potentially valid issue, but you'd need to dress up the
> fix as a proper patch (i.e. git format-patch + git send-email). It'd also
> be good if you could confirm that the issue is reproducable with the
> latest bluetooth-next kernel.
I tried with bluetooth-next kernel and there is no issue I mentioned. But
if you consider to apply the patch, then I will post the formatted patch.
Please let me know if you want.
Best Regards,
- Seung-Woo Kim
>
> Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix RFCOMM bind fail for L2CAP sock
From: Marcel Holtmann @ 2013-11-05 7:26 UTC (permalink / raw)
To: Seung-Woo Kim
Cc: linux-bluetooth@vger.kernel.org development, Gustavo F. Padovan,
Johan Hedberg, Syam Sidhardhan
In-Reply-To: <1383634944-4141-1-git-send-email-sw0312.kim@samsung.com>
Hi Seung-Woo,
> L2CAP socket bind checks its bdaddr type but RFCOMM kernel thread
> does not assign proper bdaddr type for L2CAP sock. This can cause
> that RFCOMM failure.
>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> ---
> The issue is came from following commit, but it is only in bluetooth-next tree,
> so this patch is not needed for stable tree.
>
> commit 80c1a2e76dbb36588facb265ab364b1302f7ef8c
> Author: Johan Hedberg <johan.hedberg@intel.com>
> Date: Mon Oct 14 21:17:52 2013 +0300
>
> Bluetooth: Reject invalid bdaddr types for sockets
>
> This patch is based on commit cca34b785a21d220176038c45071ffe842e99fd3 of
> bluetooth-next tree.
> ---
> net/bluetooth/rfcomm/core.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
good catch. Patch has been applied to bluetooth-next tree.
You might also want to send a patch that adds the l2_bdaddr_type setting before the connect() call.
Regards
Marcel
^ permalink raw reply
* [PATCH] Bluetooth: Fix RFCOMM bind fail for L2CAP sock
From: Seung-Woo Kim @ 2013-11-05 7:02 UTC (permalink / raw)
To: linux-bluetooth, marcel, gustavo, johan.hedberg; +Cc: sw0312.kim, s.syam
L2CAP socket bind checks its bdaddr type but RFCOMM kernel thread
does not assign proper bdaddr type for L2CAP sock. This can cause
that RFCOMM failure.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
The issue is came from following commit, but it is only in bluetooth-next tree,
so this patch is not needed for stable tree.
commit 80c1a2e76dbb36588facb265ab364b1302f7ef8c
Author: Johan Hedberg <johan.hedberg@intel.com>
Date: Mon Oct 14 21:17:52 2013 +0300
Bluetooth: Reject invalid bdaddr types for sockets
This patch is based on commit cca34b785a21d220176038c45071ffe842e99fd3 of
bluetooth-next tree.
---
net/bluetooth/rfcomm/core.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 94d06cb..ca55ea1 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -694,6 +694,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = 0;
addr.l2_cid = 0;
+ addr.l2_bdaddr_type = BDADDR_BREDR;
*err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
if (*err < 0)
goto failed;
@@ -1983,6 +1984,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = __constant_cpu_to_le16(RFCOMM_PSM);
addr.l2_cid = 0;
+ addr.l2_bdaddr_type = BDADDR_BREDR;
err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
if (err < 0) {
BT_ERR("Bind failed %d", err);
--
1.7.4.1
^ permalink raw reply related
* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Hui Wang @ 2013-11-05 2:32 UTC (permalink / raw)
To: Stevie Trujillo; +Cc: marcel, tedd.an, linux-bluetooth
In-Reply-To: <20131104141539.772e1636@localhost>
On 11/04/2013 09:15 PM, Stevie Trujillo wrote:
> Hello, I've been trying to use my computer as "handsfree" with
> "Hands-Free Profile" using "Intel Corporation Centrino Wireless-N
> 1030". I accept() the BTPROTO_SCO socket, but never recv() any
> data. Your post looked similar!
>
> When googling I found this:
>
> http://www.netbsd.org/docs/guide/en/chap-bluetooth.html#chap-bluetooth-audio
> SCO Audio will not work with ehci(4) USB controllers, since support
> for Isochronous data over EHCI is missing in NetBSD.
>
> Does Linux support this? (I have no idea what it means)
Hi Stevie,
Thanks for your input, I don't know the answer of your question, but at
least the camera works well on the EHCI bus, and camera transfers the
ISO packets over EHCI bus.
Regards,
Hui.
>
> I'm sorry if this mail is somewhat broken. I could only find your email
> on "gmane" and it had encrypted all your email addresses!
>
> On Mon, 04 Nov 2013 13:59:35 +0800
> Hui Wang <hui.wang-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> wrote:
>
>> On 11/03/2013 03:05 AM, Marcel Holtmann wrote:
>>> Hi Hui,
>>>
>> <snip>
>>>> The attachment lenovo-k4450-btmon-v1.log is the log of intel 7260
>>>> init procedure + scan headset + connect headset + play sound.
>>> I looked through the logs and the controller init is just fine. So
>>> in theory this should route the SCO audio frames over HCI. For some
>>> reason it does not and I have no idea why not.
>>>
>>> That it makes a different between EHCI and XHCI is strange. I can
>>> not explain this. Maybe Tedd can help you since I have no further
>>> insights in our chips at this moment.
>> Thanks Marcel for your kind help and analysis.
>>
>> Tedd, did you reproduce this issue on the machines with intel 7260 BT
>> module connected to the EHCI bus? Did you have any idea on this issue?
>
^ permalink raw reply
* [PATCH 11/11] android/hid: Handle uhid events
From: Ravi kumar Veeramally @ 2013-11-04 22:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383603615-9953-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Handling few uhid events and described scenarios. OUTPUT and
FEATURE events are not yet handled.
---
android/hid.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/android/hid.c b/android/hid.c
index 74de02f..fccaa87 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -149,6 +149,11 @@ static void hid_device_free(struct hid_device *dev)
g_free(dev);
}
+static void handle_uhid_event(struct hid_device *dev, struct uhid_event *ev)
+{
+ DBG("unsupported event");
+}
+
static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -172,7 +177,40 @@ static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
}
DBG("uHID event type %d received", ev.type);
- /* TODO Handle events */
+
+ switch (ev.type) {
+ case UHID_START:
+ case UHID_STOP:
+ /* These are called to start and stop the underlying hardware.
+ * We open the channels before creating the device so the
+ * hardware is always ready. No need to handle these.
+ * The kernel never destroys a device itself! Only an explicit
+ * UHID_DESTROY request can remove a device. */
+
+ break;
+ case UHID_OPEN:
+ case UHID_CLOSE:
+ /* OPEN/CLOSE are sent whenever user-space opens any interface
+ * provided by the kernel HID device. Whenever the open-count
+ * is non-zero we must be ready for I/O. As long as it is zero,
+ * we can decide to drop all I/O and put the device
+ * asleep This is optional, though. */
+ break;
+ case UHID_OUTPUT:
+ case UHID_FEATURE:
+ handle_uhid_event(dev, &ev);
+ break;
+ case UHID_OUTPUT_EV:
+ /* This is only sent by kernels prior to linux-3.11. It
+ * requires us to parse HID-descriptors in user-space to
+ * properly handle it. This is redundant as the kernel
+ * does it already. That's why newer kernels assemble
+ * the output-reports and send it to us via UHID_OUTPUT. */
+ DBG("Unsupported uHID event: type %d", ev.u.output_ev.type);
+ break;
+ default:
+ warn("unexpected uHID event");
+ }
return TRUE;
--
1.8.1.2
^ permalink raw reply related
* [PATCH 10/11] android/hid: Handle invalid parameters in hal
From: Ravi kumar Veeramally @ 2013-11-04 22:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383603615-9953-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hal-hidhost.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 45767b8..412258c 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -204,9 +204,8 @@ static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,
case BTHH_BOOT_MODE:
cmd.mode = HAL_HID_BOOT_PROTOCOL;
break;
- case BTHH_UNSUPPORTED_MODE:
- cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
- break;
+ default:
+ return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
@@ -236,9 +235,8 @@ static bt_status_t hh_set_protocol(bt_bdaddr_t *bd_addr,
case BTHH_BOOT_MODE:
cmd.mode = HAL_HID_BOOT_PROTOCOL;
break;
- case BTHH_UNSUPPORTED_MODE:
- cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
- break;
+ default:
+ return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
@@ -275,6 +273,8 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
case BTHH_FEATURE_REPORT:
cmd.type = HAL_HID_FEATURE_REPORT;
break;
+ default:
+ return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_GET_REPORT,
@@ -308,6 +308,8 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
case BTHH_FEATURE_REPORT:
cmd.type = HAL_HID_FEATURE_REPORT;
break;
+ default:
+ return BT_STATUS_PARM_INVALID;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_SET_REPORT,
--
1.8.1.2
^ permalink raw reply related
* [PATCH 09/11] android/hid: Replace header checking magic number with defines
From: Ravi kumar Veeramally @ 2013-11-04 22:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383603615-9953-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hid.c b/android/hid.c
index 2682b21e6..74de02f 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -200,7 +200,7 @@ static gboolean intr_io_watch_cb(GIOChannel *chan, gpointer data)
}
/* Discard non-data packets */
- if (bread == 0 || buf[0] != 0xA1)
+ if (bread == 0 || buf[0] != (HID_MSG_DATA | HID_DATA_TYPE_INPUT))
return TRUE;
/* send data to uHID device skipping HIDP header byte */
--
1.8.1.2
^ permalink raw reply related
* [PATCH 08/11] android/hid: Handle get report notification in hal
From: Ravi kumar Veeramally @ 2013-11-04 22:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383603615-9953-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/hal-hidhost.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 040d517..45767b8 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -68,6 +68,15 @@ static void handle_protocol_mode(void *buf)
ev->status, ev->mode);
}
+static void handle_get_report(void *buf)
+{
+ struct hal_ev_hid_get_report *ev = buf;
+
+ if (bt_hh_cbacks->get_report_cb)
+ bt_hh_cbacks->get_report_cb((bt_bdaddr_t *) ev->bdaddr,
+ ev->status, ev->data, ev->len);
+}
+
/* will be called from notification thread context */
void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
{
@@ -84,6 +93,9 @@ void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
case HAL_EV_HID_PROTO_MODE:
handle_protocol_mode(buf);
break;
+ case HAL_EV_HID_GET_REPORT:
+ handle_get_report(buf);
+ break;
default:
DBG("Unhandled callback opcode=0x%x", opcode);
break;
--
1.8.1.2
^ permalink raw reply related
* [PATCH 07/11] android/hid: Implement hid set report in daemon
From: Ravi kumar Veeramally @ 2013-11-04 22:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383603615-9953-1-git-send-email-ravikumar.veeramally@linux.intel.com>
This patch requests hid device to set report.
---
android/hal-hidhost.c | 1 +
android/hal-msg.h | 1 +
android/hid.c | 40 ++++++++++++++++++++++++++++++++++++++--
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 027e3b8..040d517 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -284,6 +284,7 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
return BT_STATUS_PARM_INVALID;
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd.report = report;
switch (reportType) {
case BTHH_INPUT_REPORT:
diff --git a/android/hal-msg.h b/android/hal-msg.h
index eaa5c9c..e1fd027 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -292,6 +292,7 @@ struct hal_cmd_hid_get_report {
struct hal_cmd_hid_set_report {
uint8_t bdaddr[6];
uint8_t type;
+ char *report;
} __attribute__((packed));
#define HAL_OP_HID_SEND_DATA 0x09
diff --git a/android/hid.c b/android/hid.c
index 6cb9604..2682b21e6 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -56,6 +56,7 @@
/* HID message types */
#define HID_MSG_GET_REPORT 0x40
+#define HID_MSG_SET_REPORT 0x50
#define HID_MSG_GET_PROTOCOL 0x60
#define HID_MSG_SET_PROTOCOL 0x70
#define HID_MSG_DATA 0xa0
@@ -846,9 +847,44 @@ static uint8_t bt_hid_get_report(struct hal_cmd_hid_get_report *cmd,
static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *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;
+ dev->hid_msg = HID_MSG_SET_REPORT;
+ req_size = 1 + strlen(cmd->report);
+ req = g_try_malloc0(req_size);
+ if (!req)
+ return HAL_STATUS_NOMEM;
+
+ req[0] = HID_MSG_SET_REPORT | cmd->type;
+ memcpy(req + 1, cmd->report, req_size - 1);
+
+ fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+ if (write(fd, req, req_size) < 0) {
+ error("error while querying device protocol");
+ g_free(req);
+ return HAL_STATUS_FAILED;
+ }
+
+ g_free(req);
+ return HAL_STATUS_SUCCESS;
}
static uint8_t bt_hid_send_data(struct hal_cmd_hid_send_data *cmd,
--
1.8.1.2
^ permalink raw reply related
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