* Re: pull request: bluetooth 2013-10-30
From: John W. Linville @ 2013-11-05 20:58 UTC (permalink / raw)
To: Gustavo Padovan, linux-wireless, linux-bluetooth, linux-kernel
In-Reply-To: <20131030193842.GA2271@joana>
On Wed, Oct 30, 2013 at 05:38:42PM -0200, Gustavo Padovan wrote:
> Hi John,
>
> A last fix to the 3.12. I ended forgetting to send it before, I hope we can
> still make the way to 3.12. It is a revert and it fixes an issue with bluetooth
> suspend/hibernate that had many bug reports. Please pull or let me know of any
> problems. Thanks!
>
> Gustavo
> --
> The following changes since commit c7515d2365a6b8a018950198ebe1f5be793cd4bb:
>
> brcmsmac: call bcma_core_pci_power_save() from non-atomic context (2013-09-26 14:02:34 -0400)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth master
>
> for you to fetch changes up to b1a8014471b01dd862de9f91bbbff1296afac42d:
>
> Bluetooth: revert: "Bluetooth: Add missing reset_resume dev_pm_ops" (2013-10-02 16:01:49 -0300)
Pulling now...
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
* Re: pull request: bluetooth-next 2013-10-21
From: John W. Linville @ 2013-11-05 20:50 UTC (permalink / raw)
To: Gustavo Padovan, linux-wireless, linux-bluetooth, linux-kernel
In-Reply-To: <20131021223736.GA2043@joana>
On Mon, Oct 21, 2013 at 08:37:36PM -0200, Gustavo Padovan wrote:
> Hi John,
>
> One more big pull request for 3.13. These are the patches we queued during
> last week. Here you will find a lot of improvements to the HCI and L2CAP and
> MGMT layers with the main ones being a better debugfs support and end of work
> of splitting L2CAP into Core and Socket parts.
>
> Please pull!
>
> Gustavo
>
> ---
> The following changes since commit 4b836f393bd8ed111857a6ee1865e44627266ec6:
>
> Bluetooth: Read current IAC LAP on controller setup (2013-10-14 19:31:18 -0300)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next for-upstream
>
> for you to fetch changes up to d78a32a8fcf775111ccc9ba611a08ca5c29784b6:
>
> Bluetooth: Remove sk member from struct l2cap_chan (2013-10-21 13:50:56 -0700)
Pulling now...
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Stevie Trujillo @ 2013-11-05 18:44 UTC (permalink / raw)
To: Hui Wang; +Cc: marcel, tedd.an, linux-bluetooth
In-Reply-To: <527858A5.2080801@canonical.com>
On Tue, 05 Nov 2013 10:32:05 +0800
Hui Wang <hui.wang@canonical.com> wrote:
> 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.
Hello again! Have you tried comparing usbmon output (I used Wireshark)
when running on EHCI and XHCI? My bluetooth card is inside the
computer, so I'm only able to do EHCI.
I see 1 ISO come in right after the SCO thing opens. It has some
error stuff inside (ENOSPC). No idea how it is supposed to behave,
since I can't compare with a good one.
Sorry if this is a stupid idea :P
^ permalink raw reply
* [PATCH v2 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
From: Szymon Janc @ 2013-11-05 18:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
This will be also used in Android daemon.
---
v2: fixed missing brackets around 'v' as suggested by Marcel
src/adapter.c | 1 -
src/shared/mgmt.h | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 30bcc4d..d904a56 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -99,7 +99,6 @@ static GSList *adapters = NULL;
static struct mgmt *mgmt_master = NULL;
-#define MGMT_VERSION(v, r) ((v << 16) + (r))
static uint8_t mgmt_version = 0;
static uint8_t mgmt_revision = 0;
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 60a2128..e23cc7d 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -24,6 +24,8 @@
#include <stdbool.h>
#include <stdint.h>
+#define MGMT_VERSION(v, r) (((v) << 16) + (r))
+
typedef void (*mgmt_destroy_func_t)(void *user_data);
struct mgmt;
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH_v3 01/04] android/hid: Implement hid get protocol in daemon
From: ravikumar.veeramally @ 2013-11-05 17:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20131105155821.GA19994@x220.p-661hnu-f1>
Hi Johan,
> Hi Ravi,
>
> On Tue, Nov 05, 2013, Ravi Kumar Veeramally wrote:
>> >On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
>> >>+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->last_hid_msg) {
>> >>+ case HID_MSG_GET_PROTOCOL:
>> >>+ bt_hid_notify_proto_mode(dev, buf, bread);
>> >>+ break;
>> >>+ default:
>> >>+ DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
>> >>+ }
>> >This doesn't really make sense to me. If you only set last_hid_msg when
>> >you send a code that you do support, then why would the value of
>> >last_hid_msg ever contain a type that you do not support? (assuming you
>> >always add an entry to this switch statement in the same patch that you
>> >add a corresponding write for the type).
>> >
>> >Also, since you don't seem to be using last_hid_msg for anything else
>> >than printing this debug message, I'm wondering is there really any
>> >value for it? Previously (based on our IRC) discussion I understood
>> that
>> >it had some actual functional value that helped determine what to send
>> >to the HAL, but now I'm not seeing it anywhere in the patch. I might
>> >have missed it though (in which case please enlighten me :)
>> I don't know if I understand you correctly, but at the end of all
>> patches
>> it looks like this.
>> switch (dev->last_hid_msg) {
>> case HID_MSG_GET_PROTOCOL:
>> case HID_MSG_SET_PROTOCOL:
>> bt_hid_notify_proto_mode(dev, buf, bread);
>> break;
>> case HID_MSG_GET_REPORT:
>> bt_hid_notify_get_report(dev, buf, bread);
>> break;
>> default:
>> DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
>> }
>>
>> based on last_hid_msg switch case, it will call respective function,
>> default statement is for debug purpose if we miss something from hid
>> device.
>
> I only saw the first two case statements and didn't look deeper into the
> patch set, sorry. In this case I do see the point of the variable and
> you may keep it as is.
Ok, np.
>
> My earlier comment about the debug statement still holds though, i.e. if
> the default entry gets triggered last_hid_msg will not contain the
> unknown msg type. In this case this will simply be an unexpected message
> whose type we do not know (and if there's a debug log that's what it
> should say).
I will remove the debug statement which doesn't help much.
Thanks,
Ravi.
^ permalink raw reply
* Re: [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
From: Marcel Holtmann @ 2013-11-05 16:57 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
> This will be also used in Android daemon.
> ---
> src/adapter.c | 1 -
> src/shared/mgmt.h | 2 ++
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 30bcc4d..d904a56 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -99,7 +99,6 @@ static GSList *adapters = NULL;
>
> static struct mgmt *mgmt_master = NULL;
>
> -#define MGMT_VERSION(v, r) ((v << 16) + (r))
> static uint8_t mgmt_version = 0;
> static uint8_t mgmt_revision = 0;
>
> diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> index 60a2128..99ea96f 100644
> --- a/src/shared/mgmt.h
> +++ b/src/shared/mgmt.h
> @@ -24,6 +24,8 @@
> #include <stdbool.h>
> #include <stdint.h>
>
> +#define MGMT_VERSION(v, r) ((v << 16) + (r))
you also need (v) here.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/2] android/debug: Export print uuid function
From: Marcel Holtmann @ 2013-11-05 16:56 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1383660378-23198-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
> The function will be reused in socket HAL.
> ---
> android/client/textconv.c | 2 +-
> android/client/textconv.h | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/android/client/textconv.c b/android/client/textconv.c
> index 9a2f7e6..e6f327f 100644
> --- a/android/client/textconv.c
> +++ b/android/client/textconv.c
> @@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
> return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
> }
>
> -static char *btuuid2str(const bt_uuid_t *uuid)
> +char *btuuid2str(const bt_uuid_t *uuid)
> {
> static char buf[MAX_UUID_STR_LEN];
>
> diff --git a/android/client/textconv.h b/android/client/textconv.h
> index 1c848ef..7520b04 100644
> --- a/android/client/textconv.h
> +++ b/android/client/textconv.h
> @@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
>
> char *btproperty2str(const bt_property_t *property);
> char *bdaddr2str(const bt_bdaddr_t *bd_addr);
> +char *btuuid2str(const bt_uuid_t *uuid);
this is totally backwards then. The HAL should not depend on client code.
Regards
Marcel
^ permalink raw reply
* [PATCH] android: Add option to specify controller index to use
From: Szymon Janc @ 2013-11-05 16:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This will be usefull while testing on Linux where more controllers
can be present.
---
This is on top of patchset starting with patch
"adapter: Move MGMT_VERSION macro to mgmt.h"
android/main.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/android/main.c b/android/main.c
index 72e47f2..994d796 100644
--- a/android/main.c
+++ b/android/main.c
@@ -455,10 +455,13 @@ static guint setup_signalfd(void)
}
static gboolean option_version = FALSE;
+static gint option_index = MGMT_INDEX_NONE;
static GOptionEntry options[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit", NULL },
+ { "index", 'i', 0, G_OPTION_ARG_INT, &option_index,
+ "Use specified controller", "INDEX"},
{ NULL }
};
@@ -481,6 +484,8 @@ static void adapter_ready(int err)
static void mgmt_index_added_event(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
+ uint16_t opt_index = option_index;
+
DBG("index %u", index);
if (adapter_index != MGMT_INDEX_NONE) {
@@ -488,6 +493,11 @@ static void mgmt_index_added_event(uint16_t index, uint16_t length,
return;
}
+ if (opt_index != MGMT_INDEX_NONE && opt_index != index) {
+ DBG("skip event for index %u (option %u)", index, opt_index);
+ return;
+ }
+
if (adapter_timeout > 0) {
g_source_remove(adapter_timeout);
adapter_timeout = 0;
@@ -521,7 +531,9 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
const struct mgmt_rp_read_index_list *rp = param;
+ uint16_t opt_index = option_index;
uint16_t num;
+ int i;
DBG("");
@@ -548,19 +560,26 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
if (adapter_index != MGMT_INDEX_NONE)
return;
- if (num < 1) {
- adapter_timeout = g_timeout_add_seconds(STARTUP_GRACE_SECONDS,
- adapter_timeout_handler, NULL);
- if (adapter_timeout == 0) {
- error("%s: Failed init timeout", __func__);
- goto error;
- }
+ for (i = 0; i < num; i++) {
+ uint16_t index = btohs(rp->index[i]);
+
+ if (opt_index != MGMT_INDEX_NONE && opt_index != index)
+ continue;
+
+ adapter_index = index;
+ bt_adapter_init(adapter_index, mgmt_if, adapter_ready);
return;
}
- adapter_index = btohs(rp->index[0]);
- bt_adapter_init(adapter_index, mgmt_if, adapter_ready);
- return;
+ if (adapter_index != MGMT_INDEX_NONE)
+ return;
+
+ adapter_timeout = g_timeout_add_seconds(STARTUP_GRACE_SECONDS,
+ adapter_timeout_handler, NULL);
+ if (adapter_timeout > 0)
+ return;
+
+ error("%s: Failed init timeout", __func__);
error:
g_main_loop_quit(event_loop);
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH_v3 01/04] android/hid: Implement hid get protocol in daemon
From: Johan Hedberg @ 2013-11-05 15:58 UTC (permalink / raw)
To: Ravi Kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <5278F248.9080605@linux.intel.com>
Hi Ravi,
On Tue, Nov 05, 2013, Ravi Kumar Veeramally wrote:
> >On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
> >>+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->last_hid_msg) {
> >>+ case HID_MSG_GET_PROTOCOL:
> >>+ bt_hid_notify_proto_mode(dev, buf, bread);
> >>+ break;
> >>+ default:
> >>+ DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
> >>+ }
> >This doesn't really make sense to me. If you only set last_hid_msg when
> >you send a code that you do support, then why would the value of
> >last_hid_msg ever contain a type that you do not support? (assuming you
> >always add an entry to this switch statement in the same patch that you
> >add a corresponding write for the type).
> >
> >Also, since you don't seem to be using last_hid_msg for anything else
> >than printing this debug message, I'm wondering is there really any
> >value for it? Previously (based on our IRC) discussion I understood that
> >it had some actual functional value that helped determine what to send
> >to the HAL, but now I'm not seeing it anywhere in the patch. I might
> >have missed it though (in which case please enlighten me :)
> I don't know if I understand you correctly, but at the end of all patches
> it looks like this.
> switch (dev->last_hid_msg) {
> case HID_MSG_GET_PROTOCOL:
> case HID_MSG_SET_PROTOCOL:
> bt_hid_notify_proto_mode(dev, buf, bread);
> break;
> case HID_MSG_GET_REPORT:
> bt_hid_notify_get_report(dev, buf, bread);
> break;
> default:
> DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
> }
>
> based on last_hid_msg switch case, it will call respective function,
> default statement is for debug purpose if we miss something from hid device.
I only saw the first two case statements and didn't look deeper into the
patch set, sorry. In this case I do see the point of the variable and
you may keep it as is.
My earlier comment about the debug statement still holds though, i.e. if
the default entry gets triggered last_hid_msg will not contain the
unknown msg type. In this case this will simply be an unexpected message
whose type we do not know (and if there's a debug log that's what it
should say).
Johan
^ permalink raw reply
* bluez-5.10/monitor/packet.c:4335: possible missing break ?
From: David Binderman @ 2013-11-05 15:02 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hello there,
I just ran the static analysis checker "cppcheck" over the source code of bluez-5.10
It said
[monitor/packet.c:4335] -> [monitor/packet.c:4338]: (warning) Variable 'str' is reassigned a value
before the old one has been used. 'break;' missing?
Source code is
case 0x03:
str = "Allow Scan Request from White List Only, "
"Allow Connect Request from White List Only";
default:
str = "Reserved";
break;
Suggest add a break statement to the 0x03 case.
Regards
David Binderman
^ permalink raw reply
* [PATCH 5/5] android: Stop mainloop if reading index list failed
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
If reading index list failed mainloop should be stopped since adapter
init guard timer is not yet running.
---
android/main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/android/main.c b/android/main.c
index 4bb5101..72e47f2 100644
--- a/android/main.c
+++ b/android/main.c
@@ -528,12 +528,12 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
if (status) {
error("%s: Failed to read index list: %s (0x%02x)",
__func__, mgmt_errstr(status), status);
- return;
+ goto error;
}
if (length < sizeof(*rp)) {
error("%s: Wrong size of read index list response", __func__);
- return;
+ goto error;
}
num = btohs(rp->num_controllers);
@@ -542,7 +542,7 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
if (num * sizeof(uint16_t) + sizeof(*rp) != length) {
error("%s: Incorrect pkt size for index list rsp", __func__);
- return;
+ goto error;
}
if (adapter_index != MGMT_INDEX_NONE)
@@ -553,13 +553,17 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
adapter_timeout_handler, NULL);
if (adapter_timeout == 0) {
error("%s: Failed init timeout", __func__);
- g_main_loop_quit(event_loop);
+ goto error;
}
return;
}
adapter_index = btohs(rp->index[0]);
bt_adapter_init(adapter_index, mgmt_if, adapter_ready);
+ return;
+
+error:
+ g_main_loop_quit(event_loop);
}
static void read_commands_complete(uint8_t status, uint16_t length,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 4/5] android: Stop mainloop if reading version failed
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
If reading mgmt version failed or kernel supported version is to old
mainloop should be stopped.
---
android/main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/android/main.c b/android/main.c
index d68abe1..4bb5101 100644
--- a/android/main.c
+++ b/android/main.c
@@ -592,12 +592,12 @@ static void read_version_complete(uint8_t status, uint16_t length,
if (status) {
error("Failed to read version information: %s (0x%02x)",
mgmt_errstr(status), status);
- return;
+ goto error;
}
if (length < sizeof(*rp)) {
error("Wrong size response");
- return;
+ goto error;
}
mgmt_version = rp->version;
@@ -608,7 +608,7 @@ static void read_version_complete(uint8_t status, uint16_t length,
if (MGMT_VERSION(mgmt_version, mgmt_revision) < MGMT_VERSION(1, 3)) {
error("Version 1.3 or later of management interface required");
- return;
+ goto error;
}
mgmt_send(mgmt_if, MGMT_OP_READ_COMMANDS, MGMT_INDEX_NONE, 0, NULL,
@@ -624,6 +624,9 @@ static void read_version_complete(uint8_t status, uint16_t length,
return;
error("Failed to read controller index list");
+
+error:
+ g_main_loop_quit(event_loop);
}
static bool init_mgmt_interface(void)
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/5] android: Remove mgmt_version and mgmt_revision static variables
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
There is no need to keep those as Android daemon is expecting new
enough kernel to operate.
---
android/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/android/main.c b/android/main.c
index 7ee47fc..d68abe1 100644
--- a/android/main.c
+++ b/android/main.c
@@ -68,9 +68,6 @@
static GMainLoop *event_loop;
static struct mgmt *mgmt_if = NULL;
-static uint8_t mgmt_version = 0;
-static uint8_t mgmt_revision = 0;
-
static uint16_t adapter_index = MGMT_INDEX_NONE;
static guint adapter_timeout = 0;
@@ -588,6 +585,7 @@ static void read_version_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
const struct mgmt_rp_read_version *rp = param;
+ uint8_t mgmt_version, mgmt_revision;
DBG("");
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/5] android: Require at least 1.3 version of mgmt interface
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383661128-25029-1-git-send-email-szymon.janc@tieto.com>
Android daemon is not providing old kernels compatibility features.
---
android/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/main.c b/android/main.c
index 7d36976..7ee47fc 100644
--- a/android/main.c
+++ b/android/main.c
@@ -608,8 +608,8 @@ static void read_version_complete(uint8_t status, uint16_t length,
info("Bluetooth management interface %u.%u initialized",
mgmt_version, mgmt_revision);
- if (mgmt_version < 1) {
- error("Version 1.0 or later of management interface required");
+ if (MGMT_VERSION(mgmt_version, mgmt_revision) < MGMT_VERSION(1, 3)) {
+ error("Version 1.3 or later of management interface required");
return;
}
--
1.8.4.2
^ permalink raw reply related
* [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This will be also used in Android daemon.
---
src/adapter.c | 1 -
src/shared/mgmt.h | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 30bcc4d..d904a56 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -99,7 +99,6 @@ static GSList *adapters = NULL;
static struct mgmt *mgmt_master = NULL;
-#define MGMT_VERSION(v, r) ((v << 16) + (r))
static uint8_t mgmt_version = 0;
static uint8_t mgmt_revision = 0;
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 60a2128..99ea96f 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -24,6 +24,8 @@
#include <stdbool.h>
#include <stdint.h>
+#define MGMT_VERSION(v, r) ((v << 16) + (r))
+
typedef void (*mgmt_destroy_func_t)(void *user_data);
struct mgmt;
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/2] android/hal: Add UUID debug print in socket HAL
From: Andrei Emeltchenko @ 2013-11-05 14:06 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1383660378-23198-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-sock.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index 131877a..5e64409 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
#include "hal-msg.h"
#include "hal.h"
+#include "client/textconv.h"
+
static bt_status_t sock_listen_rfcomm(const char *service_name,
const uint8_t *uuid, int chan,
int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
int *sock, int flags)
{
if ((!uuid && chan <= 0) || !sock) {
- error("%s: invalid params: uuid %p, chan %d, sock %p",
- __func__, uuid, chan, sock);
+ error("Invalid params: uuid %s, chan %d, sock %p",
+ btuuid2str((bt_uuid_t *) uuid), chan, sock);
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %p chan %d sock %p type %d service_name %s",
- uuid, chan, sock, type, service_name);
+ DBG("uuid %s chan %d sock %p type %d service_name %s",
+ btuuid2str((bt_uuid_t *) uuid), chan,
+ sock, type, service_name);
switch (type) {
case BTSOCK_RFCOMM:
@@ -76,12 +79,13 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
struct hal_op_sock_connect cmd;
if ((!uuid && chan <= 0) || !bdaddr || !sock) {
- error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
- bdaddr, uuid, chan, sock);
+ error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+ bdaddr, btuuid2str((bt_uuid_t *) uuid), chan, sock);
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+ DBG("uuid %s chan %d sock %p type %d", btuuid2str((bt_uuid_t *) uuid),
+ chan, sock, type);
cmd.flags = flags;
cmd.type = type;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/2] android/debug: Export print uuid function
From: Andrei Emeltchenko @ 2013-11-05 14:06 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The function will be reused in socket HAL.
---
android/client/textconv.c | 2 +-
android/client/textconv.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 9a2f7e6..e6f327f 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
}
-static char *btuuid2str(const bt_uuid_t *uuid)
+char *btuuid2str(const bt_uuid_t *uuid)
{
static char buf[MAX_UUID_STR_LEN];
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..7520b04 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
char *btproperty2str(const bt_property_t *property);
char *bdaddr2str(const bt_bdaddr_t *bd_addr);
+char *btuuid2str(const bt_uuid_t *uuid);
DECINTMAP(bt_status_t);
DECINTMAP(bt_state_t);
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH_v3 03/04] android/hid: Implement hid get report in daemon
From: Ravi Kumar Veeramally @ 2013-11-05 13:55 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131105131606.GC15228@x220.p-661hnu-f1>
On 11/05/2013 03:16 PM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
>> + if (!((buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_INPUT)) ||
>> + (buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_OUTPUT)) ||
>> + (buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_FEATURE)))) {
>> + ev = g_malloc(len);
>> + memset(ev, 0, ev_len);
> Is it intentional that you allocate a different length than what you
> memset to 0 here? If they should be the same just use g_malloc0, and if
> not a code comment might be in order (to explain what the actual
> intention is).
Ok, type, it should be ev_len.
>> + ev = g_malloc(ev_len);
>> + memset(ev, 0, ev_len);
> Here g_malloc0 makes more sense.
>
>> + ev->status = HAL_HID_STATUS_OK;
>> + bdaddr2android(&dev->dst, ev->bdaddr);
>> +
>> + /* Report porotocol mode reply contains id after hdr, in boot
>> + * protocol mode id doesn't exist */
>> + if (dev->boot_dev) {
>> + ev->len = len - 1;
>> + memcpy(ev->data, buf + 1, ev->len);
>> + } else {
>> + ev->len = len - 2;
>> + memcpy(ev->data, buf + 2, ev->len);
>> + }
>> +
>> +send:
>> + ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_GET_REPORT,
>> + ev_len, ev, -1);
> This doesn't look right for your first allocation (you claim that the
> length of ev is ev_len, but in fact you allocated len amount of bytes.
Ok. I will fix it.
Thanks,
Ravi.
^ permalink raw reply
* Re: [PATCH_v3 02/04] android/hid: Implement hid set protocol in daemon
From: Ravi Kumar Veeramally @ 2013-11-05 13:52 UTC (permalink / raw)
To: linux-bluetooth, Johan Hedberg
In-Reply-To: <20131105131232.GB15228@x220.p-661hnu-f1>
Hi Johan,
On 11/05/2013 03:12 PM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
>> static uint8_t bt_hid_set_protocol(struct hal_cmd_hid_set_protocol *cmd,
>> uint16_t len)
>> {
>> - DBG("Not Implemented");
>> + struct hid_device *dev;
>> + GSList *l;
>> + bdaddr_t dst;
>> + int fd;
>> + uint8_t hdr[1];
> If it's just one element there's no need for an array. Just use
> "uint8_t hdr;" instead.
>
>> + hdr[0] = HID_MSG_SET_PROTOCOL | cmd->mode;
> And then here hdr = ...;
>
>> + fd = g_io_channel_unix_get_fd(dev->ctrl_io);
>> +
>> + if (write(fd, hdr, sizeof(hdr)) < 0) {
> And here &hdr, sizeof(hdr)
Ok.
Thanks,
Ravi.
^ permalink raw reply
* Re: [PATCH_v3 01/04] android/hid: Implement hid get protocol in daemon
From: Ravi Kumar Veeramally @ 2013-11-05 13:27 UTC (permalink / raw)
To: linux-bluetooth, johan.hedberg@gmail.com >> Johan Hedberg
In-Reply-To: <20131105131050.GA15228@x220.p-661hnu-f1>
Hi Johan,
On 11/05/2013 03:10 PM, Johan Hedberg wrote:
> Hi Ravi,
>
> On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
>> +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->last_hid_msg) {
>> + case HID_MSG_GET_PROTOCOL:
>> + bt_hid_notify_proto_mode(dev, buf, bread);
>> + break;
>> + default:
>> + DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
>> + }
> This doesn't really make sense to me. If you only set last_hid_msg when
> you send a code that you do support, then why would the value of
> last_hid_msg ever contain a type that you do not support? (assuming you
> always add an entry to this switch statement in the same patch that you
> add a corresponding write for the type).
>
> Also, since you don't seem to be using last_hid_msg for anything else
> than printing this debug message, I'm wondering is there really any
> value for it? Previously (based on our IRC) discussion I understood that
> it had some actual functional value that helped determine what to send
> to the HAL, but now I'm not seeing it anywhere in the patch. I might
> have missed it though (in which case please enlighten me :)
I don't know if I understand you correctly, but at the end of all patches
it looks like this.
switch (dev->last_hid_msg) {
case HID_MSG_GET_PROTOCOL:
case HID_MSG_SET_PROTOCOL:
bt_hid_notify_proto_mode(dev, buf, bread);
break;
case HID_MSG_GET_REPORT:
bt_hid_notify_get_report(dev, buf, bread);
break;
default:
DBG("unhandled hid msg type 0x%02x", dev->last_hid_msg);
}
based on last_hid_msg switch case, it will call respective function,
default statement is for debug purpose if we miss something from hid device.
Thanks,
Ravi.
^ permalink raw reply
* [PATCH] monitor: Fallback to 80 columns terminal if not able to get real size
From: Szymon Janc @ 2013-11-05 13:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This makes num_columns always return valid number of columns, which is
expected by print_packets function.
This also fix garbage prints while using btmon via adb shell.
---
monitor/display.c | 8 ++++----
monitor/display.h | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/monitor/display.c b/monitor/display.c
index b8dce1f..af4171f 100644
--- a/monitor/display.c
+++ b/monitor/display.c
@@ -58,10 +58,10 @@ int num_columns(void)
if (__builtin_expect(!!(cached_num_columns < 0), 0)) {
struct winsize ws;
- if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
- return -1;
-
- if (ws.ws_col > 0)
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0 ||
+ ws.ws_col == 0)
+ cached_num_columns = FALLBACK_TERMINAL_WIDTH;
+ else
cached_num_columns = ws.ws_col;
}
diff --git a/monitor/display.h b/monitor/display.h
index 6139cc2..885eb34 100644
--- a/monitor/display.h
+++ b/monitor/display.h
@@ -40,6 +40,8 @@ bool use_color(void);
#define COLOR_ERROR "\x1B[1;31m"
+#define FALLBACK_TERMINAL_WIDTH 80
+
#define print_indent(indent, color1, prefix, title, color2, fmt, args...) \
do { \
printf("%*c%s%s%s%s" fmt "%s\n", (indent), ' ', \
--
1.8.4.1
^ permalink raw reply related
* Re: [PATCH BlueZ] android/hid: Fix passing wrong adapter address to bt_io_listen
From: Johan Hedberg @ 2013-11-05 13:22 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1383657140-10758-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Tue, Nov 05, 2013, Luiz Augusto von Dentz wrote:
> ---
> android/hid.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCHv2 6/6] android: Add support for getting adapter uuids
From: Marcin Kraglak @ 2013-11-05 13:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383657700-22313-1-git-send-email-marcin.kraglak@tieto.com>
Implement get adapter uuids command. It will pack supported
uuids to structure and send it via notification socket
---
android/adapter.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 89db078..6ce2211 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1291,13 +1291,47 @@ static bool get_name(void)
return true;
}
+static void swap_uuid(const uint8_t *src, uint8_t *dst)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ dst[15 - i] = src[i];
+}
+
static bool get_uuids(void)
{
- DBG("Not implemented");
+ struct hal_ev_adapter_props_changed *ev;
+ unsigned int i;
+ int len;
+ uint8_t *p;
- /* TODO: Add implementation */
+ len = sizeof(*ev) + sizeof(struct hal_property) +
+ NELEM(supported_services) * sizeof(uint128_t);
- return false;
+ ev = g_malloc(len);
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_UUIDS;
+ ev->props[0].len = sizeof(uint128_t) * NELEM(supported_services);
+ p = ev->props->val;
+
+ for (i = 0; i < NELEM(supported_services); i++) {
+ /* we have to swap supported uuids
+ * because hal expects them in reversed order
+ * than mgmt intrface */
+ swap_uuid(supported_services[i].uuid, p);
+ p += sizeof(uint128_t);
+ }
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+ g_free(ev);
+
+ return true;
}
static bool get_class(void)
--
1.8.4.1
^ permalink raw reply related
* [PATCHv2 5/6] android: Implement class of device property callback
From: Marcin Kraglak @ 2013-11-05 13:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383657700-22313-1-git-send-email-marcin.kraglak@tieto.com>
This will send adapter property with class of device
to notification socket.
---
android/adapter.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 70b9265..89db078 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -212,6 +212,30 @@ static void scan_mode_changed(void)
g_free(ev);
}
+static void send_adapter_class(void)
+{
+ struct hal_ev_adapter_props_changed *ev;
+ int len;
+
+ len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(uint32_t);
+
+ ev = g_malloc(len);
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_CLASS;
+ ev->props[0].len = sizeof(uint32_t);
+ memcpy(ev->props->val, &adapter->dev_class, sizeof(uint32_t));
+
+ DBG("Adapter class %u", adapter->dev_class);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+ g_free(ev);
+}
+
static void settings_changed(uint32_t settings)
{
uint32_t changed_mask;
@@ -280,7 +304,7 @@ static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
adapter->dev_class = dev_class;
- /* TODO: Inform prop change: Class */
+ send_adapter_class();
/* TODO: Gatt attrib set*/
}
@@ -1278,11 +1302,11 @@ static bool get_uuids(void)
static bool get_class(void)
{
- DBG("Not implemented");
+ DBG("");
- /* TODO: Add implementation */
+ send_adapter_class();
- return false;
+ return true;
}
static bool get_type(void)
--
1.8.4.1
^ permalink raw reply related
* [PATCHv2 4/6] android: Add supported uuids when adapter is initialized
From: Marcin Kraglak @ 2013-11-05 13:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1383657700-22313-1-git-send-email-marcin.kraglak@tieto.com>
It will set class of device with proper service hints.
We set it statically because we want to keep code simple.
---
android/adapter.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 0f24cac..70b9265 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -52,6 +52,29 @@ static GIOChannel *notification_io = NULL;
/* This list contains addresses which are asked for records */
static GSList *browse_reqs;
+/*
+ * This is an array of supported uuids and service hints. We add them via mgmt
+ * interface when adapter is initialized. Uuids are in reverse orded.
+ */
+static const struct mgmt_cp_add_uuid supported_services[] = {
+ /* OBEX_OPP_UUID */
+ { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00 },
+ .svc_hint = 0x10 },
+ /* HFP_AG_UUID */
+ { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x1f, 0x11, 0x00, 0x00 },
+ .svc_hint = 0x40 },
+ /* ADVANCED_AUDIO_UUID */
+ { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00 },
+ .svc_hint = 0x08 },
+ /* PANU_UUID */
+ { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00 },
+ .svc_hint = 0x02 }
+};
+
struct bt_adapter {
uint16_t index;
struct mgmt *mgmt;
@@ -980,6 +1003,39 @@ static void load_link_keys(GSList *keys)
}
}
+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_uuids(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < NELEM(supported_services); i++)
+ mgmt_send(adapter->mgmt, MGMT_OP_ADD_UUID, adapter->index,
+ sizeof(supported_services[i]),
+ &supported_services[i], add_uuid_complete,
+ NULL, NULL);
+}
+
+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 set_mode_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -995,6 +1051,9 @@ static void set_mode_complete(uint8_t status, uint16_t length,
* event handling functions here.
*/
new_settings_callback(adapter->index, length, param, NULL);
+
+ clear_uuids();
+ add_uuids();
}
static bool set_mode(uint16_t opcode, uint8_t mode)
--
1.8.4.1
^ 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