* [PATCH 7/7] Bluetooth: Fix updating scan mode in set_bredr()
From: johan.hedberg @ 2013-10-14 10:52 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381747965-24599-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
Now that the connectable setting is also applicable for the LE side it's
possible that the HCI_CONNECTABLE flag is already set when changing the
BR/EDR setting from false to true while the controller is powered. In
this situation we need to update the BR/EDR scan mode to reflect the
setting. Additionally, since HCI_CONNECTABLE also applies to LE we must
not clear the HCI_CONNECTABLE flag when disabling bredr.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4f3fd50..abaa58a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3612,7 +3612,6 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
if (!hdev_is_powered(hdev)) {
if (!cp->val) {
- clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
@@ -3655,7 +3654,12 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
hci_req_init(&req, hdev);
+
+ if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
+ set_bredr_scan(&req);
+
hci_update_ad(&req);
+
err = hci_req_run(&req, set_bredr_complete);
if (err < 0)
mgmt_pending_remove(cmd);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Adjust header for proc socket information
From: Johan Hedberg @ 2013-10-14 11:24 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381741525-22607-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> The exposed socket information do not contain source or destination
> addresses. So adjust the header accordingly.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/af_bluetooth.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Introduce L2CAP channel flag for defer setup
From: Johan Hedberg @ 2013-10-14 11:24 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381743934-29348-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> The L2CAP core should not look into the socket flags to figure out the
> setting of defer setup. So introduce a L2CAP channel flag that mirrors
> the socket flag.
>
> Since the defer setup option is only set in one place this becomes a
> really easy thing to do.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 15 +++++++--------
> net/bluetooth/l2cap_sock.c | 7 +++++--
> 3 files changed, 13 insertions(+), 10 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Introduce L2CAP channel callback for resuming
From: Johan Hedberg @ 2013-10-14 11:25 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381744434-35580-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> Clearing the BT_SK_SUSPEND socket flag from the L2CAP core is causing
> a dependency on the socket. So intead of doing that, use a channel
> callback into the socket handling to resume.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 6 +-----
> net/bluetooth/l2cap_sock.c | 9 +++++++++
> 3 files changed, 11 insertions(+), 5 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] sdptool: Clarify 'add' and 'remove' commands in manual
From: Johan Hedberg @ 2013-10-14 11:27 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <3234061.FlIIUUDOzO@uw000953>
Hi Szymon,
On Mon, Oct 14, 2013, Szymon Janc wrote:
> > Adapters are no longer notified about external changes in SDP
> > database. This results in 'add' and 'remove' commands being
> > usefull only for SDP testing or qualification.
> > ---
> > tools/sdptool.1 | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/tools/sdptool.1 b/tools/sdptool.1
> > index 88ad818..ea95933 100644
> > --- a/tools/sdptool.1
> > +++ b/tools/sdptool.1
> > @@ -91,9 +91,15 @@ the \fB--handle\fP option.
> > .IP "" 10
> > You can specify a channel to add the service on
> > using the \fB--channel\fP option.
> > +.IP "" 10
> > +NOTE: Local adapters configuration will not be updated and this command should
> > +be used only for SDP testing.
> > .IP "\fBdel record_handle\fP" 10
> > Remove a service from the local
> > SDP database.
> > +.IP "" 10
> > +NOTE: Local adapters configuration will not be updated and this command should
> > +be used only for SDP testing.
> > .IP "\fBget [--tree] [--raw] [--xml] [--bdaddr bdaddr] record_handle\fP" 10
> > Retrieve a service from the local
> > SDP database.
> >
>
> ping
Applied now. Sorry for the delay.
Johan
^ permalink raw reply
* Re: [PATCH 1/7] Bluetooth: Add connectable argument to enable_advertising()
From: Marcel Holtmann @ 2013-10-14 11:29 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381747965-24599-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> We want to be able to control whether enable_advertising() enables
> connectable or non-connectable advertising based on the connectable
> setting of the adapter. We could have the function check directly for
> the HCI_CONNECTABLE flag, but since the flag may not be set or unset
> before we call the function it's necessary to pass an explicit parameter
> value to it.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 020f95b..6f07523 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1418,7 +1418,7 @@ unlock:
> return err;
> }
>
> -static void enable_advertising(struct hci_request *req)
> +static void enable_advertising(struct hci_request *req, bool connectable)
> {
> struct hci_dev *hdev = req->hdev;
> struct hci_cp_le_set_adv_param cp;
> @@ -1427,7 +1427,10 @@ static void enable_advertising(struct hci_request *req)
> memset(&cp, 0, sizeof(cp));
> cp.min_interval = __constant_cpu_to_le16(0x0800);
> cp.max_interval = __constant_cpu_to_le16(0x0800);
> - cp.type = LE_ADV_IND;
> + if (connectable)
> + cp.type = LE_ADV_IND;
> + else
> + cp.type = LE_ADV_NONCONN_IND;
this is the part that I do not like. Having the extra parameter seems rather pointless. We could check for the HCI_CONNECTABLE bit in dev_flags right here.
> if (bacmp(&hdev->bdaddr, BDADDR_ANY))
> cp.own_address_type = ADDR_LE_DEV_PUBLIC;
> else
> @@ -3323,7 +3326,8 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
> hci_req_init(&req, hdev);
>
> if (val)
> - enable_advertising(&req);
> + enable_advertising(&req,
> + test_bit(HCI_CONNECTABLE, &hdev->dev_flags));
> else
> disable_advertising(&req);
>
> @@ -3948,7 +3952,9 @@ static int powered_update_hci(struct hci_dev *hdev)
> &hdev->static_addr);
>
> if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
> - enable_advertising(&req);
> + enable_advertising(&req,
> + test_bit(HCI_CONNECTABLE,
> + &hdev->dev_flags));
> }
>
> link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
> @@ -4735,7 +4741,7 @@ void mgmt_reenable_advertising(struct hci_dev *hdev)
> return;
>
> hci_req_init(&req, hdev);
> - enable_advertising(&req);
> + enable_advertising(&req, test_bit(HCI_CONNECTABLE, &hdev->dev_flags));
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/7] Bluetooth: Add connectable argument to enable_advertising()
From: Johan Hedberg @ 2013-10-14 11:36 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <9E7A5B1E-F415-4F2D-BDBF-B6C4ACB6B142@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> > We want to be able to control whether enable_advertising() enables
> > connectable or non-connectable advertising based on the connectable
> > setting of the adapter. We could have the function check directly for
> > the HCI_CONNECTABLE flag, but since the flag may not be set or unset
> > before we call the function it's necessary to pass an explicit parameter
> > value to it.
> >
> > Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> > ---
> > net/bluetooth/mgmt.c | 16 +++++++++++-----
> > 1 file changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> > index 020f95b..6f07523 100644
> > --- a/net/bluetooth/mgmt.c
> > +++ b/net/bluetooth/mgmt.c
> > @@ -1418,7 +1418,7 @@ unlock:
> > return err;
> > }
> >
> > -static void enable_advertising(struct hci_request *req)
> > +static void enable_advertising(struct hci_request *req, bool connectable)
> > {
> > struct hci_dev *hdev = req->hdev;
> > struct hci_cp_le_set_adv_param cp;
> > @@ -1427,7 +1427,10 @@ static void enable_advertising(struct hci_request *req)
> > memset(&cp, 0, sizeof(cp));
> > cp.min_interval = __constant_cpu_to_le16(0x0800);
> > cp.max_interval = __constant_cpu_to_le16(0x0800);
> > - cp.type = LE_ADV_IND;
> > + if (connectable)
> > + cp.type = LE_ADV_IND;
> > + else
> > + cp.type = LE_ADV_NONCONN_IND;
>
> this is the part that I do not like. Having the extra parameter seems
> rather pointless. We could check for the HCI_CONNECTABLE bit in
> dev_flags right here.
This is what I tried to explain in the commit message. When we do
set_connectable() we want to call enable_advertising() with an explicit
value since the HCI_CONNECTABLE flag gets toggled only when the HCI
commands have been successful.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] gdbus: Check for NULL DBusPendingCall in g_dbus_send_message_with_reply
From: Luiz Augusto von Dentz @ 2013-10-14 11:38 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1996678.hfgLy9qM2S@uw000953>
Hi Szymon,
On Mon, Oct 14, 2013 at 11:12 AM, Szymon Janc <szymon.janc@tieto.com> wrote:
>
>> From D-Bus documentation for dbus_connection_send_with_reply():
>> "Warning: if the connection is disconnected or you try to send Unix file
>> descriptors on a connection that does not support them, the
>> DBusPendingCall will be set to NULL, so be careful with this."
>>
>> Check this in g_dbus_send_message_with_reply so that callers don't need
>> to double check for NULL if g_dbus_send_message_with_reply returned
>> TRUE.
>>
>> This also fix crash if passing FD over D-Bus is blocked e.g. by SELinux
>> policy.
>>
>> bluetoothd[1894]: profiles/audio/avdtp.c:session_cb()
>> bluetoothd[1894]: profiles/audio/avdtp.c:avdtp_parse_cmd() Received
>> SET_CONFIGURATION_CMD
>> bluetoothd[1894]: profiles/audio/a2dp.c:endpoint_setconf_ind() Source
>> 0x6c5000: Set_Configuration_Ind
>> bluetoothd[1894]: profiles/audio/avdtp.c:avdtp_ref() 0x6df360: ref=1
>> bluetoothd[1894]: profiles/audio/a2dp.c:setup_ref() 0x6d32b0: ref=1
>> process 1894: arguments to dbus_pending_call_set_notify() were incorrect,
>> assertion "pending != NULL" failed in file dbus-pending-call.c line
>> 636.
>> This is normally a bug in some application using the D-Bus library.
>> ---
>> gdbus/object.c | 11 ++++++++++-
>> 1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdbus/object.c b/gdbus/object.c
>> index 0822fe8..268fed5 100644
>> --- a/gdbus/object.c
>> +++ b/gdbus/object.c
>> @@ -1510,11 +1510,20 @@ gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
>> DBusMessage *message,
>> DBusPendingCall **call, int timeout)
>> {
>> + dbus_bool_t ret;
>> +
>> /* Flush pending signal to guarantee message order */
>> g_dbus_flush(connection);
>>
>> - return dbus_connection_send_with_reply(connection, message, call,
>> + ret = dbus_connection_send_with_reply(connection, message, call,
>> timeout);
>> +
>> + if (ret == TRUE && call != NULL && *call == NULL) {
>> + error("Unable to send message (passing fd blocked?)");
>> + return FALSE;
>> + }
>> +
>> + return ret;
>> }
>>
>> gboolean g_dbus_send_error_valist(DBusConnection *connection,
>>
>
> ping
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/7] Bluetooth: Add connectable argument to enable_advertising()
From: Marcel Holtmann @ 2013-10-14 11:43 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20131014113622.GE26222@x220.p-661hnu-f1>
Hi Johan,
>>> We want to be able to control whether enable_advertising() enables
>>> connectable or non-connectable advertising based on the connectable
>>> setting of the adapter. We could have the function check directly for
>>> the HCI_CONNECTABLE flag, but since the flag may not be set or unset
>>> before we call the function it's necessary to pass an explicit parameter
>>> value to it.
>>>
>>> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
>>> ---
>>> net/bluetooth/mgmt.c | 16 +++++++++++-----
>>> 1 file changed, 11 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>>> index 020f95b..6f07523 100644
>>> --- a/net/bluetooth/mgmt.c
>>> +++ b/net/bluetooth/mgmt.c
>>> @@ -1418,7 +1418,7 @@ unlock:
>>> return err;
>>> }
>>>
>>> -static void enable_advertising(struct hci_request *req)
>>> +static void enable_advertising(struct hci_request *req, bool connectable)
>>> {
>>> struct hci_dev *hdev = req->hdev;
>>> struct hci_cp_le_set_adv_param cp;
>>> @@ -1427,7 +1427,10 @@ static void enable_advertising(struct hci_request *req)
>>> memset(&cp, 0, sizeof(cp));
>>> cp.min_interval = __constant_cpu_to_le16(0x0800);
>>> cp.max_interval = __constant_cpu_to_le16(0x0800);
>>> - cp.type = LE_ADV_IND;
>>> + if (connectable)
>>> + cp.type = LE_ADV_IND;
>>> + else
>>> + cp.type = LE_ADV_NONCONN_IND;
>>
>> this is the part that I do not like. Having the extra parameter seems
>> rather pointless. We could check for the HCI_CONNECTABLE bit in
>> dev_flags right here.
>
> This is what I tried to explain in the commit message. When we do
> set_connectable() we want to call enable_advertising() with an explicit
> value since the HCI_CONNECTABLE flag gets toggled only when the HCI
> commands have been successful.
I have a bad feeling with doing it like this. So I rather try to avoid this. We might need an internal difference between BR/EDR connectable and LE connectable. So that at least we can track this internally independent.
The whole feeding test_bit() as parameter is getting out of control quickly. So I would propose to have one extra flag that gets set.
Regards
Marcel
^ permalink raw reply
* Re: [PATCHv3 14/15] android: Add makefile for hciconfig
From: Andrei Emeltchenko @ 2013-10-14 11:51 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <60443344-0A54-4EF4-ABBB-1EAAE168E541@holtmann.org>
Hi Marcel,
On Wed, Oct 09, 2013 at 09:59:42PM +0200, Marcel Holtmann wrote:
> Hi Andrei,
>
> >
> > ---
> > android/Android.mk | 34 ++++++++++++++++++++++++++++++++++
> > 1 file changed, 34 insertions(+)
> >
> > diff --git a/android/Android.mk b/android/Android.mk
> > index e7a70d0..09c4579 100644
> > --- a/android/Android.mk
> > +++ b/android/Android.mk
> > @@ -123,3 +123,37 @@ $(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bl
> > LOCAL_MODULE := libbluetooth
> >
> > include $(BUILD_SHARED_LIBRARY)
> > +
> > +#
> > +# hciconfig
> > +#
>
> why are we building this one. Only btmgmt should be needed for testing. If at all.
>
Can btmon now save packet dump in a format understandable for wireshark?
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCHv3 14/15] android: Add makefile for hciconfig
From: Marcel Holtmann @ 2013-10-14 12:06 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <20131014115131.GG2861@aemeltch-MOBL1>
Hi Andrei,
>>>
>>> ---
>>> android/Android.mk | 34 ++++++++++++++++++++++++++++++++++
>>> 1 file changed, 34 insertions(+)
>>>
>>> diff --git a/android/Android.mk b/android/Android.mk
>>> index e7a70d0..09c4579 100644
>>> --- a/android/Android.mk
>>> +++ b/android/Android.mk
>>> @@ -123,3 +123,37 @@ $(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bl
>>> LOCAL_MODULE := libbluetooth
>>>
>>> include $(BUILD_SHARED_LIBRARY)
>>> +
>>> +#
>>> +# hciconfig
>>> +#
>>
>> why are we building this one. Only btmgmt should be needed for testing. If at all.
>>
>
> Can btmon now save packet dump in a format understandable for wireshark?
btmon stores in the new BTSnoop format that allows for multiple controllers in the same trace. If Wireshark does not support these, then that should be fixed in Wireshark.
Regards
Marcel
^ permalink raw reply
* [PATCH BlueZ] audio/AVCTP: Fix sending requests with same transaction id
From: Luiz Augusto von Dentz @ 2013-10-14 12:46 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If a request is outstanding in the processed list its transaction shall
not be reused as it can cause the wrong callback to be called.
This can be reproduced in very rare occasions where e.g. a notification
using the same transaction of the current request arrives before the
response itself.
---
profiles/audio/avctp.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 845027f..dac7a66 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1480,7 +1480,28 @@ static struct avctp_pending_req *pending_create(struct avctp_channel *chan,
GDestroyNotify destroy)
{
struct avctp_pending_req *p;
+ GSList *l, *tmp;
+ if (!chan->processed)
+ goto done;
+
+ tmp = g_slist_copy(chan->processed);
+
+ /* Find first unused transaction id */
+ for (l = tmp; l; l = l->next) {
+ struct avctp_pending_req *req = l->data;
+
+ if (req->transaction == chan->transaction) {
+ chan->transaction++;
+ chan->transaction %= 16;
+ tmp = g_slist_delete_link(tmp, l);
+ l = tmp;
+ }
+ }
+
+ g_slist_free(tmp);
+
+done:
p = g_new0(struct avctp_pending_req, 1);
p->chan = chan;
p->transaction = chan->transaction;
--
1.8.3.1
^ permalink raw reply related
* [PATCH] android: Start Android Bluetooth daemon
From: Andrei Emeltchenko @ 2013-10-14 12:56 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381485723-15898-5-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Start Android Bluetooth daemon from HAL init(). Make sure
that daemon is in "running" state.
---
android/hal_bluetooth.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/android/hal_bluetooth.c b/android/hal_bluetooth.c
index 517f0b4..9bb9dcf 100644
--- a/android/hal_bluetooth.c
+++ b/android/hal_bluetooth.c
@@ -23,11 +23,16 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
+#include <cutils/sockets.h>
+#include <cutils/properties.h>
+
#define LOG_TAG "BlueZ"
#include <cutils/log.h>
#include "hal.h"
+#define SERVICE_NAME "bluetoothd"
+
bt_callbacks_t *bt_hal_cbacks = NULL;
static bool interface_ready(void)
@@ -35,6 +40,33 @@ static bool interface_ready(void)
return bt_hal_cbacks != NULL;
}
+static bool start_bt_daemon(void)
+{
+ int tries = 40; /* wait 4 seconds for completion */
+
+ ALOGD(__func__);
+
+ /* Start Android Bluetooth daemon service */
+ property_set("ctl.start", SERVICE_NAME);
+
+ while (tries-- > 0) {
+ char val[PROPERTY_VALUE_MAX];
+
+ if (property_get("init.svc." SERVICE_NAME, val, NULL)) {
+ if (!strcmp(val, "running")) {
+ ALOGI("Android BlueZ daemon started");
+ return true;
+ }
+ } else {
+ return false;
+ }
+
+ usleep(100000);
+ }
+
+ return false;
+}
+
static int init(bt_callbacks_t *callbacks)
{
ALOGD(__func__);
@@ -42,10 +74,13 @@ static int init(bt_callbacks_t *callbacks)
if (interface_ready())
return BT_STATUS_SUCCESS;
- /* store reference to user callbacks */
- bt_hal_cbacks = callbacks;
+ if (start_bt_daemon()) {
+ /* TODO: open channel */
+
+ bt_hal_cbacks = callbacks;
- /* TODO: Init here bluezd task */
+ return BT_STATUS_SUCCESS;
+ }
return BT_STATUS_UNSUPPORTED;
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 0/5] Bluetooth: Clean up Set Connectable related code
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
Hi,
This is a set of cleanup patches (and one fix) split out from my earlier
set. I'm hoping to get these in first to make it easier to understand
how the code works and what the possible ways of adding LE Advertising
hooks are.
The main thing with these patches is that we make a clear separation of
what happens if someone uses a raw HCI socket compared to sending a Set
Connectable command using the management interface. Now both cases have
their clear functions for handling the HCI_CONNECTABLE flag and the
necessary mgmt events.
----------------------------------------------------------------
Johan Hedberg (5):
Bluetooth: Reorganize set_connectable HCI command sending
Bluetooth: Move move logic into set_connectable complete callback
Bluetooth: Add missing error handling for Set Connectable
Bluetooth: Move static advertising functions to avoid forward declarations
Bluetooth: Fix updating advertising data needlessly
net/bluetooth/hci_event.c | 2 +-
net/bluetooth/mgmt.c | 122 ++++++++++++++++++++++++++++------------------
2 files changed, 75 insertions(+), 49 deletions(-)
^ permalink raw reply
* [PATCH 1/5] Bluetooth: Reorganize set_connectable HCI command sending
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch moves all the decisions of which HCI commands to send (or not
to send) to the code between hci_req_init() and hci_req_run() this
allows us to further extend the request with further commands but still
keep the same logic of handling whether to return a direct mgmt response
in the case that no HCI commands were sent.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 020f95b..cfd8d44 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1144,30 +1144,29 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
goto failed;
}
- if (!!cp->val == test_bit(HCI_PSCAN, &hdev->flags)) {
- err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev);
- goto failed;
- }
-
cmd = mgmt_pending_add(sk, MGMT_OP_SET_CONNECTABLE, hdev, data, len);
if (!cmd) {
err = -ENOMEM;
goto failed;
}
- if (cp->val) {
- scan = SCAN_PAGE;
- } else {
- scan = 0;
+ hci_req_init(&req, hdev);
- if (test_bit(HCI_ISCAN, &hdev->flags) &&
- hdev->discov_timeout > 0)
- cancel_delayed_work(&hdev->discov_off);
- }
+ if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) &&
+ cp->val != test_bit(HCI_PSCAN, &hdev->flags)) {
- hci_req_init(&req, hdev);
+ if (cp->val) {
+ scan = SCAN_PAGE;
+ } else {
+ scan = 0;
- hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+ if (test_bit(HCI_ISCAN, &hdev->flags) &&
+ hdev->discov_timeout > 0)
+ cancel_delayed_work(&hdev->discov_off);
+ }
+
+ hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+ }
/* If we're going from non-connectable to connectable or
* vice-versa when fast connectable is enabled ensure that fast
@@ -1179,8 +1178,13 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
write_fast_connectable(&req, false);
err = hci_req_run(&req, set_connectable_complete);
- if (err < 0)
+ if (err < 0) {
mgmt_pending_remove(cmd);
+ if (err == -ENODATA)
+ err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE,
+ hdev);
+ goto failed;
+ }
failed:
hci_dev_unlock(hdev);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/5] Bluetooth: Move move logic into set_connectable complete callback
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch moves the responsibility of setting/clearing the
HCI_CONNECTABLE flag to the request completion callback of the Set
Connectable command. This will allow us to cleanly add support for LE
Advertising hooks in later patches.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index cfd8d44..8dcea77 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1075,6 +1075,8 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
static void set_connectable_complete(struct hci_dev *hdev, u8 status)
{
struct pending_cmd *cmd;
+ struct mgmt_mode *cp;
+ bool changed;
BT_DBG("status 0x%02x", status);
@@ -1084,8 +1086,17 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status)
if (!cmd)
goto unlock;
+ cp = cmd->param;
+ if (cp->val)
+ changed = !test_and_set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ else
+ changed = test_and_clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+
send_settings_rsp(cmd->sk, MGMT_OP_SET_CONNECTABLE, hdev);
+ if (changed)
+ new_settings(hdev, cmd->sk);
+
mgmt_pending_remove(cmd);
unlock:
@@ -4053,10 +4064,16 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
int mgmt_connectable(struct hci_dev *hdev, u8 connectable)
{
- struct pending_cmd *cmd;
bool changed = false;
int err = 0;
+ /* Nothing needed here if there's a pending command since that
+ * commands request completion callback takes care of everything
+ * necessary.
+ */
+ if (mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev))
+ return 0;
+
if (connectable) {
if (!test_and_set_bit(HCI_CONNECTABLE, &hdev->dev_flags))
changed = true;
@@ -4065,10 +4082,8 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable)
changed = true;
}
- cmd = mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev);
-
if (changed)
- err = new_settings(hdev, cmd ? cmd->sk : NULL);
+ err = new_settings(hdev, NULL);
return err;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 3/5] Bluetooth: Add missing error handling for Set Connectable
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
If the HCI commands related to the Set Connectable command fail we will
get a non-zero status in the request completion callback. In such a case
we must respond with the appropriate command status message to user space.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8dcea77..a5c015c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1086,6 +1086,12 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status)
if (!cmd)
goto unlock;
+ if (status) {
+ u8 mgmt_err = mgmt_status(status);
+ cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
+ goto remove_cmd;
+ }
+
cp = cmd->param;
if (cp->val)
changed = !test_and_set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
@@ -1097,6 +1103,7 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status)
if (changed)
new_settings(hdev, cmd->sk);
+remove_cmd:
mgmt_pending_remove(cmd);
unlock:
--
1.8.3.1
^ permalink raw reply related
* [PATCH 4/5] Bluetooth: Move static advertising functions to avoid forward declarations
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
These functions will soon be used by set_connectable() so move them to a
location in mgmt.c that doesn't require forward declarations.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 56 ++++++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a5c015c..caa552c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1072,6 +1072,34 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
}
+static void enable_advertising(struct hci_request *req)
+{
+ struct hci_dev *hdev = req->hdev;
+ struct hci_cp_le_set_adv_param cp;
+ u8 enable = 0x01;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.min_interval = __constant_cpu_to_le16(0x0800);
+ cp.max_interval = __constant_cpu_to_le16(0x0800);
+ cp.type = LE_ADV_IND;
+ if (bacmp(&hdev->bdaddr, BDADDR_ANY))
+ cp.own_address_type = ADDR_LE_DEV_PUBLIC;
+ else
+ cp.own_address_type = ADDR_LE_DEV_RANDOM;
+ cp.channel_map = 0x07;
+
+ hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp);
+
+ hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
+}
+
+static void disable_advertising(struct hci_request *req)
+{
+ u8 enable = 0x00;
+
+ hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
+}
+
static void set_connectable_complete(struct hci_dev *hdev, u8 status)
{
struct pending_cmd *cmd;
@@ -1440,34 +1468,6 @@ unlock:
return err;
}
-static void enable_advertising(struct hci_request *req)
-{
- struct hci_dev *hdev = req->hdev;
- struct hci_cp_le_set_adv_param cp;
- u8 enable = 0x01;
-
- memset(&cp, 0, sizeof(cp));
- cp.min_interval = __constant_cpu_to_le16(0x0800);
- cp.max_interval = __constant_cpu_to_le16(0x0800);
- cp.type = LE_ADV_IND;
- if (bacmp(&hdev->bdaddr, BDADDR_ANY))
- cp.own_address_type = ADDR_LE_DEV_PUBLIC;
- else
- cp.own_address_type = ADDR_LE_DEV_RANDOM;
- cp.channel_map = 0x07;
-
- hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp);
-
- hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
-}
-
-static void disable_advertising(struct hci_request *req)
-{
- u8 enable = 0x00;
-
- hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
-}
-
static void le_enable_complete(struct hci_dev *hdev, u8 status)
{
struct cmd_lookup match = { NULL, hdev };
--
1.8.3.1
^ permalink raw reply related
* [PATCH 5/5] Bluetooth: Fix updating advertising data needlessly
From: johan.hedberg @ 2013-10-14 13:20 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We need to ensure that the advertising data is up-to-date whenever
advertising is enabled, but when disabling advertising we do not need to
worry about it (since it will eventually get fixed as soon as
advertising is enabled again). This patch fixes this in the command
complete callback for set_adv_enable.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index aa6fed3..da2bc3d 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -924,7 +924,7 @@ static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
}
- if (!test_bit(HCI_INIT, &hdev->flags)) {
+ if (*sent && !test_bit(HCI_INIT, &hdev->flags)) {
struct hci_request req;
hci_req_init(&req, hdev);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCHv3 14/15] android: Add makefile for hciconfig
From: Michal Labedzki @ 2013-10-14 13:39 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Andrei Emeltchenko, linux-bluetooth
In-Reply-To: <863CEBAE-1469-4E15-A90A-ED373C614FAB@holtmann.org>
[-- Attachment #1: Type: text/plain, Size: 2108 bytes --]
Hello Andrei,
If you want to have support for new format of BNSNOOP in Wireshark please
create new bug/feature request on Wireshark bugzilla:
https://bugs.wireshark.org/bugzilla/buglist.cgi?resolution=---&query_format=advanced&list_id=10586
Please attach example trace file(s).
Also if anyone known a bug in Wireshark or need new feature please use
bugzilla too.
There is a second way to sniffing Bluetooth with Wireshark: if you have two
Bluetooth USB dongles then you can sniffing over USB (optionally filtering
by "hci_usb" {+ is SCO in logs; - is that only for USB devices}).
By the way: Wireshark can support BlueZ BTSNOOP format, but btmon can
support "pcap" or "pcapng" format too. Most similar tools use them.
PS. Wireshark seems to decode whole Bluetooth stack, also tshark can be
replacement for your btmon.
Pozdrawiam / Best regards
-------------------------------------------------------------------------------------------------------------
Michał Łabędzki, 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ław, 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ółka z ograniczoną odpowiedzialnością z siedzibą w
Szczecinie, ul. Malczewskiego 26. Zarejestrowana w Sądzie Rejonowym
Szczecin-Centrum w Szczecinie, XIII Wydział Gospodarczy Krajowego Rejestru
Sądowego pod numerem 0000124858. NIP: 8542085557. REGON: 812023656. Kapitał
zakładowy: 4 271500 PLN
[-- Attachment #2: Type: text/html, Size: 3185 bytes --]
^ permalink raw reply
* Re: [PATCH 0/5] Bluetooth: Clean up Set Connectable related code
From: Marcel Holtmann @ 2013-10-14 13:46 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381756807-14900-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This is a set of cleanup patches (and one fix) split out from my earlier
> set. I'm hoping to get these in first to make it easier to understand
> how the code works and what the possible ways of adding LE Advertising
> hooks are.
>
> The main thing with these patches is that we make a clear separation of
> what happens if someone uses a raw HCI socket compared to sending a Set
> Connectable command using the management interface. Now both cases have
> their clear functions for handling the HCI_CONNECTABLE flag and the
> necessary mgmt events.
>
> ----------------------------------------------------------------
> Johan Hedberg (5):
> Bluetooth: Reorganize set_connectable HCI command sending
> Bluetooth: Move move logic into set_connectable complete callback
> Bluetooth: Add missing error handling for Set Connectable
> Bluetooth: Move static advertising functions to avoid forward declarations
> Bluetooth: Fix updating advertising data needlessly
>
> net/bluetooth/hci_event.c | 2 +-
> net/bluetooth/mgmt.c | 122 ++++++++++++++++++++++++++++------------------
> 2 files changed, 75 insertions(+), 49 deletions(-)
all 5 patches have been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Allow using obexd without systemd in the user session
From: Luiz Augusto von Dentz @ 2013-10-14 15:02 UTC (permalink / raw)
To: Bastien Nocera
Cc: Marcel Holtmann, Giovanni Campagna,
linux-bluetooth@vger.kernel.org, Giovanni Campagna
In-Reply-To: <1381595148.21761.0.camel@nuvo>
Hi Bastien,
On Sat, Oct 12, 2013 at 7:25 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Sat, 2013-10-12 at 18:08 +0200, Marcel Holtmann wrote:
>> Hi Giovanni,
> <snip>
>> that is something your distro specific package should be fixing if
>> that is needed. The focus is on integration with systemd and nothing
>> else. You can use --disable-systemd and provide your own set of D-Bus
>> service files.
>
> There aren't any distributions that ship systemd for user sessions
> though.
How far we are with this? If that will take a while perhaps we should
support the old D-Bus service too.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCHv2 0/4] Initial patches splitted
From: Johan Hedberg @ 2013-10-14 15:30 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1381485723-15898-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Oct 11, 2013, Andrei Emeltchenko wrote:
> This is small chunk form my previous patch series splitted for easy review.
> I need to understand what is current coding style for our project, so far it seems
> very different from BlueZ I took as example first. Please comment.
>
> Changes:
> * PATCHv2: removed unused function
>
> Andrei Emeltchenko (4):
> android: Add Adapter Bluetooth HAL template
> android: Add Socket Bluetooth HAL template
> android: Enable Socket interface
> android: Start Android Bluetooth daemon
>
> android/Android.mk | 20 +++
> android/hal.h | 18 +++
> android/hal_bluetooth.c | 384 +++++++++++++++++++++++++++++++++++++++++++++++
> android/hal_bt_sock.c | 85 +++++++++++
> 4 files changed, 507 insertions(+)
> create mode 100644 android/hal.h
> create mode 100644 android/hal_bluetooth.c
> create mode 100644 android/hal_bt_sock.c
All four patches have been applied to bluez.git.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] android: Add initial Android Bluetooth HAL protocol API doc
From: Johan Hedberg @ 2013-10-14 15:30 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1381737959-9138-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Mon, Oct 14, 2013, Szymon Janc wrote:
> This IPC is used to communicate Android BlueZ daemon and HAL.
>
> Currently specified are BT HAL "bluetooth" (BT_HARDWARE_MODULE_ID)
> and following profile HALs:
> "socket" (BT_PROFILE_SOCKETS_ID)
> "hidhost" (BT_PROFILE_HIDHOST_ID)
> "pan" (BT_PROFILE_PAN_ID)
> "handsfree" (BT_PROFILE_HANDSFREE_ID)
> "ad2p" (BT_PROFILE_ADVANCED_AUDIO_ID)
> "health" (BT_PROFILE_HEALTH_ID)
> ---
> android/hal-ipc-api.txt | 1247 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 1247 insertions(+)
> create mode 100644 android/hal-ipc-api.txt
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Check that scan window is smaller or equal than scan interval
From: Marcel Holtmann @ 2013-10-14 16:55 UTC (permalink / raw)
To: linux-bluetooth
The scan window parameter for connection establishment and passive
scanning needs to be smaller or equal than the scan interval.
Instead of waiting for a controller to reject these values later on,
just reject them right away.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index caa552c..40c85ed 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3423,6 +3423,10 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
MGMT_STATUS_INVALID_PARAMS);
+ if (window > interval)
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
+ MGMT_STATUS_INVALID_PARAMS);
+
hci_dev_lock(hdev);
hdev->le_scan_interval = interval;
--
1.8.3.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