* 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
* Re: [PATCH] Allow using obexd without systemd in the user session
From: Bastien Nocera @ 2013-10-14 18:02 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Marcel Holtmann, Giovanni Campagna,
linux-bluetooth@vger.kernel.org, Giovanni Campagna
In-Reply-To: <CABBYNZJt2n_DZmR2SQk8HvgkRgf4yuPJnYr=HFxqb3H-Y0mQyw@mail.gmail.com>
On Mon, 2013-10-14 at 18:02 +0300, Luiz Augusto von Dentz wrote:
> 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.
It's planned for GNOME 3.12 for GNOME, so in about 6 months time
(April-ish release date).
^ permalink raw reply
* [PATCH 0/4] Bluetooth: Associate connectable setting with adv type
From: johan.hedberg @ 2013-10-14 18:15 UTC (permalink / raw)
To: linux-bluetooth
Hi,
Here's a rewritten patch set to allow associating the connectable
setting with the advertising type. Unlike the first attempt this one
doesn't introduce a new parameter to enable_advertising() but instead
does a pending mgmt command lookup to help determine the right
advertising type.
There's also a fourth patch to do similar refactoring for
set_discoverable as we did for set_connectable wrt. splitting raw HCI
sockets from mgmt control, but I didn't quite get around to tying that
to the advertising data yet (the general discoverable flag).
Johan
----------------------------------------------------------------
Johan Hedberg (4):
Bluetooth: Make Set Connectable also update the LE advertising type
Bluetooth: Move set_bredr_scan() to avoid forward declaration
Bluetooth: Fix updating scan mode in set_bredr()
Bluetooth: Convert Set Discoverable to use an asynchronous request
net/bluetooth/mgmt.c | 144 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 109 insertions(+), 35 deletions(-)
^ permalink raw reply
* [PATCH 1/4] Bluetooth: Make Set Connectable also update the LE advertising type
From: johan.hedberg @ 2013-10-14 18:15 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381774527-13746-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch updates the Set Connectable Management command to also update
the LE advertising type to either connectable or non-connectable
advertising. An extra helper function is needed for getting the right
advertising type since we can not only rely on the HCI_CONNECTABLE flag
but must also check for a pending Set Connectable command (in which case
the flag does not yet have its final value).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index caa552c..a07b081 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1072,6 +1072,25 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
}
+static u8 get_adv_type(struct hci_dev *hdev)
+{
+ struct pending_cmd *cmd;
+ bool connectable;
+
+ /* If there's a pending mgmt command the flag will not yet have
+ * it's final value, so check for this first.
+ */
+ cmd = mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev);
+ if (cmd) {
+ struct mgmt_mode *cp = cmd->param;
+ connectable = !!cp->val;
+ } else {
+ connectable = test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ }
+
+ return connectable ? LE_ADV_IND : LE_ADV_NONCONN_IND;
+}
+
static void enable_advertising(struct hci_request *req)
{
struct hci_dev *hdev = req->hdev;
@@ -1081,7 +1100,7 @@ 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;
+ cp.type = get_adv_type(hdev);
if (bacmp(&hdev->bdaddr, BDADDR_ANY))
cp.own_address_type = ADDR_LE_DEV_PUBLIC;
else
@@ -1144,15 +1163,15 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
struct mgmt_mode *cp = data;
struct pending_cmd *cmd;
struct hci_request req;
- u8 scan, status;
+ u8 scan;
int err;
BT_DBG("request for %s", hdev->name);
- status = mgmt_bredr_support(hdev);
- if (status)
+ if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) &&
+ !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
- status);
+ MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
@@ -1223,6 +1242,12 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
if (cp->val || test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags))
write_fast_connectable(&req, false);
+ if (test_bit(HCI_ADVERTISING, &hdev->dev_flags) &&
+ hci_conn_num(hdev, LE_LINK) == 0) {
+ disable_advertising(&req);
+ enable_advertising(&req);
+ }
+
err = hci_req_run(&req, set_connectable_complete);
if (err < 0) {
mgmt_pending_remove(cmd);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/4] Bluetooth: Move set_bredr_scan() to avoid forward declaration
From: johan.hedberg @ 2013-10-14 18:15 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381774527-13746-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The set_bredr_scan() function will soon be needed by the set_bredr()
function, so move it to a new location to avoid having to add a forward
declaration.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a07b081..48aa239 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3558,6 +3558,26 @@ unlock:
return err;
}
+static void set_bredr_scan(struct hci_request *req)
+{
+ struct hci_dev *hdev = req->hdev;
+ u8 scan = 0;
+
+ /* Ensure that fast connectable is disabled. This function will
+ * not do anything if the page scan parameters are already what
+ * they should be.
+ */
+ write_fast_connectable(req, false);
+
+ if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
+ scan |= SCAN_PAGE;
+ if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
+ scan |= SCAN_INQUIRY;
+
+ if (scan)
+ hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+}
+
static void set_bredr_complete(struct hci_dev *hdev, u8 status)
{
struct pending_cmd *cmd;
@@ -3917,26 +3937,6 @@ void mgmt_index_removed(struct hci_dev *hdev)
mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
}
-static void set_bredr_scan(struct hci_request *req)
-{
- struct hci_dev *hdev = req->hdev;
- u8 scan = 0;
-
- /* Ensure that fast connectable is disabled. This function will
- * not do anything if the page scan parameters are already what
- * they should be.
- */
- write_fast_connectable(req, false);
-
- if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
- scan |= SCAN_PAGE;
- if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
- scan |= SCAN_INQUIRY;
-
- if (scan)
- hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
-}
-
static void powered_complete(struct hci_dev *hdev, u8 status)
{
struct cmd_lookup match = { NULL, hdev };
--
1.8.3.1
^ permalink raw reply related
* [PATCH 3/4] Bluetooth: Fix updating scan mode in set_bredr()
From: johan.hedberg @ 2013-10-14 18:15 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381774527-13746-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 48aa239..0bad451 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3640,7 +3640,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);
@@ -3683,7 +3682,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
* [PATCH 4/4] Bluetooth: Convert Set Discoverable to use an asynchronous request
From: johan.hedberg @ 2013-10-14 18:15 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381774527-13746-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch converts Set Discoverable to use an asynchronous request
along with its own completion callback. This is necessary for splitting
raw HCI socket use cases from mgmt, as well as for enabling the hooking
up of Advertising parameters together with the HCI_DISCOVERABLE flag
(coming in later patches).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 63 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 54 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 0bad451..813012f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -935,11 +935,52 @@ static u8 mgmt_le_support(struct hci_dev *hdev)
return MGMT_STATUS_SUCCESS;
}
+static void set_discoverable_complete(struct hci_dev *hdev, u8 status)
+{
+ struct pending_cmd *cmd;
+ struct mgmt_mode *cp;
+ bool changed;
+
+ BT_DBG("status 0x%02x", status);
+
+ hci_dev_lock(hdev);
+
+ cmd = mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev);
+ 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_DISCOVERABLE,
+ &hdev->dev_flags);
+ else
+ changed = test_and_clear_bit(HCI_DISCOVERABLE,
+ &hdev->dev_flags);
+
+ send_settings_rsp(cmd->sk, MGMT_OP_SET_DISCOVERABLE, hdev);
+
+ if (changed)
+ new_settings(hdev, cmd->sk);
+
+remove_cmd:
+ mgmt_pending_remove(cmd);
+
+unlock:
+ hci_dev_unlock(hdev);
+}
+
static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
u16 len)
{
struct mgmt_cp_set_discoverable *cp = data;
struct pending_cmd *cmd;
+ struct hci_request req;
u16 timeout;
u8 scan, status;
int err;
@@ -1021,6 +1062,8 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
goto failed;
}
+ hci_req_init(&req, hdev);
+
scan = SCAN_PAGE;
if (cp->val)
@@ -1028,7 +1071,9 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
else
cancel_delayed_work(&hdev->discov_off);
- err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+ hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+
+ err = hci_req_run(&req, set_discoverable_complete);
if (err < 0)
mgmt_pending_remove(cmd);
@@ -4074,10 +4119,16 @@ void mgmt_set_powered_failed(struct hci_dev *hdev, int err)
int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
{
- struct cmd_lookup match = { NULL, hdev };
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_DISCOVERABLE, hdev))
+ return 0;
+
if (discoverable) {
if (!test_and_set_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
changed = true;
@@ -4086,14 +4137,8 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
changed = true;
}
- mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp,
- &match);
-
if (changed)
- err = new_settings(hdev, match.sk);
-
- if (match.sk)
- sock_put(match.sk);
+ err = new_settings(hdev, NULL);
return err;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets
From: johan.hedberg @ 2013-10-14 18:17 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
We need to verify that the bdaddr type passed to connect() and bind() is
within the set of valid values. If it is not we need to cleanly fail
with EINVAL.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/l2cap_sock.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f1b462f..982915d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -69,6 +69,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
if (la.l2_cid && la.l2_psm)
return -EINVAL;
+ if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
+ return -EINVAL;
+
lock_sock(sk);
if (sk->sk_state != BT_OPEN) {
@@ -144,6 +147,9 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
if (la.l2_cid && la.l2_psm)
return -EINVAL;
+ if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
+ return -EINVAL;
+
err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
&la.l2_bdaddr, la.l2_bdaddr_type);
if (err)
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect()
From: johan.hedberg @ 2013-10-14 18:17 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381774673-14150-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
If a socket was bound to an address type other than BR/EDR (such as LE)
we should reject trying to connect it to a BR/EDR address. The same
applies for binding to BR/EDR and trying to connect to non-BR/EDR.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/l2cap_sock.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 982915d..87e17b7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -150,6 +150,12 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
return -EINVAL;
+ if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
+ return -EINVAL;
+
+ if (chan->src_type != BDADDR_BREDR && la.l2_bdaddr_type == BDADDR_BREDR)
+ return -EINVAL;
+
err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
&la.l2_bdaddr, la.l2_bdaddr_type);
if (err)
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH 0/4] Bluetooth: Associate connectable setting with adv type
From: Marcel Holtmann @ 2013-10-14 18:24 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381774527-13746-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> Here's a rewritten patch set to allow associating the connectable
> setting with the advertising type. Unlike the first attempt this one
> doesn't introduce a new parameter to enable_advertising() but instead
> does a pending mgmt command lookup to help determine the right
> advertising type.
>
> There's also a fourth patch to do similar refactoring for
> set_discoverable as we did for set_connectable wrt. splitting raw HCI
> sockets from mgmt control, but I didn't quite get around to tying that
> to the advertising data yet (the general discoverable flag).
>
> Johan
>
> ----------------------------------------------------------------
> Johan Hedberg (4):
> Bluetooth: Make Set Connectable also update the LE advertising type
> Bluetooth: Move set_bredr_scan() to avoid forward declaration
> Bluetooth: Fix updating scan mode in set_bredr()
> Bluetooth: Convert Set Discoverable to use an asynchronous request
>
> net/bluetooth/mgmt.c | 144 ++++++++++++++++++++++++++++++++++++++-------------
> 1 file changed, 109 insertions(+), 35 deletions(-)
all four patches have been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox