* Re: [PATCH] Bluetooth: Fix minor coding style issue in set_connectable()
From: Johan Hedberg @ 2013-10-15 8:28 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381793925-14134-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> There is a minor coding style violation and so just fix it. No actual
> logic has changed.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/mgmt.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for entering limited discoverable mode
From: Johan Hedberg @ 2013-10-15 7:40 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
In-Reply-To: <20131015073157.GA24495@x220.p-661hnu-f1>
Hi,
On Tue, Oct 15, 2013, Johan Hedberg wrote:
> On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> > + if (cp->val) {
> > + struct hci_cp_write_current_iac_lap cp;
> > +
> > + if (timeout > 0) {
> > + /* Limited discoverable mode */
>
> Wouldn't we want to follow the recommendation from the Core spec here,
> volume 3, part C, section 4.1.2.1:
>
> "A Bluetooth device should not be in limited discoverable mode for more than
> TGAP(104)"
>
> TGAP(104) in turn is defined as 1 minute (vol 3, part C, Appendix A).
We might even want to limit this to 30 seconds so the same can be used
for LE once this is hooked up to advertising:
TGAP(lim_adv_timeout) 30.72s Maximum time to remain Required value
advertising when in the
limited discoverable mode
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for entering limited discoverable mode
From: Johan Hedberg @ 2013-10-15 7:31 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381792099-8732-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> + if (cp->val) {
> + struct hci_cp_write_current_iac_lap cp;
> +
> + if (timeout > 0) {
> + /* Limited discoverable mode */
Wouldn't we want to follow the recommendation from the Core spec here,
volume 3, part C, section 4.1.2.1:
"A Bluetooth device should not be in limited discoverable mode for more than
TGAP(104)"
TGAP(104) in turn is defined as 1 minute (vol 3, part C, Appendix A).
Johan
^ permalink raw reply
* Re: [PATCH BlueZ] audio/AVCTP: Fix sending requests with same transaction id
From: Johan Hedberg @ 2013-10-15 6:58 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1381754763-27278-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Oct 14, 2013, Luiz Augusto von Dentz wrote:
> 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(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ 1/3] audio/AVDTP: Fix crash after disconnecting
From: Johan Hedberg @ 2013-10-15 6:57 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1381745687-5677-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Oct 14, 2013, Luiz Augusto von Dentz wrote:
> If the session is disconnected while process_discover is pending the
> source id is not removed causing the following crash:
> at 0x414C08: finalize_discovery (avdtp.c:1050)
> by 0x414C5A: process_discover (avdtp.c:3346)
> by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x40A3B6: main (main.c:595)
> Address 0x5e25de8 is 1,144 bytes inside a block of size 1,176 free'd
> at 0x4A074C4: free (in
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> by 0x3D4604D9AE: g_free (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x4152F2: connection_lost (avdtp.c:1206)
> by 0x4162C4: cancel_request (avdtp.c:2662)
> by 0x4164BD: request_timeout (avdtp.c:2672)
> by 0x3D46048962: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x3D46047E05: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x3D46048157: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x3D46048559: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
> by 0x40A3B6: main (main.c:595)
> ---
> profiles/audio/avdtp.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
All three patches have been applied. Thanks.
Johan
^ permalink raw reply
* pull request: bluetooth-next 2013-10-14
From: Gustavo Padovan @ 2013-10-14 23:52 UTC (permalink / raw)
To: linville; +Cc: linux-wireless, linux-bluetooth, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 12473 bytes --]
Hi John,
More patches for 3.12, busy times for Bluetooth. More than a 100 commits since
the last pull. The bulk of work comes from Johan and Marcel, they are doing
fixes and improvements all over the Bluetooth subsystem, as the diffstat can
show.
Please pull or let me know of any problems! Thanks.
Gustavo
--
The following changes since commit 4f3e219d95a3c31b916dcd5e2631c4e440736f79:
Bluetooth: Only one command per L2CAP LE signalling is supported (2013-10-03 16:09:59 +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 4b836f393bd8ed111857a6ee1865e44627266ec6:
Bluetooth: Read current IAC LAP on controller setup (2013-10-14 19:31:18 -0300)
----------------------------------------------------------------
Andre Guedes (4):
Bluetooth: Rename hci_conn variable in hci_connect_le()
Bluetooth: Initialize hci_conn fields in hci_connect_le
Bluetooth: Use HCI request for LE connection
Bluetooth: Refactor hci_connect_le
Johan Hedberg (17):
Bluetooth: Rename HCI_LE_PERIPHERAL to HCI_ADVERTISING
Bluetooth: Add public mgmt function to send New Settings event
Bluetooth: Fix re-enabling advertising after a connection
Bluetooth: Fix changing advertising setting while LE is connected
Bluetooth: Fix potential double-frees of L2CAP skbs
Bluetooth: Fix checking for HCI_SETUP flag when receiving mgmt commands
Bluetooth: Reorganize set_connectable HCI command sending
Bluetooth: Move more 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
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
Bluetooth: Reject invalid bdaddr types for sockets
Bluetooth: Check that bind() bdaddr type matches connect()
Johannes Berg (1):
Bluetooth: Fix variable shadow warnings
Marcel Holtmann (117):
Bluetooth: Fix controller list for AMP discover response
Bluetooth: Remove useless external function to count controllers
Bluetooth: Add constants for AMP controller type
Bluetooth: Separate AMP controller type from HCI device type
Bluetooth: Use explicit AMP controller id value for BR/EDR
Bluetooth: Rename AMP status constants and use them
Bluetooth: Remove pointless inline function
Bluetooth: Remove check for number of AMP controller
Bluetooth: Move hci_amp_capable() function into L2CAP core
Bluetooth: Simplify check if L2CAP connection is AMP capable
Bluetooth: Check for non BR/EDR controller in AMP discover response
Bluetooth: Reject enabling controllers without valid addresses
Bluetooth: Use explicit check for BR/EDR device type
Bluetooth: Simplify device type check for AMP discover response
Bluetooth: Use random address if public address is not available
Bluetooth: Add HCI structure for LE advertising parameters command
Bluetooth: Make it clear that disabling LE disables advertising
Bluetooth: Use helper functions for enabling/disabling advertising
Bluetooth: Add constants for LE advertising types
Bluetooth: Set LE advertising parameters before enabling it
Bluetooth: Use helper function for re-enabling advertising
Bluetooth: Remove no longer needed mgmt_new_settings() function
Bluetooth: Remove mgmt_valid_hdev() helper function
Bluetooth: Send new settings only when pairable changes
Bluetooth: Make mgmt_index_added() and mgmt_index_removed() return void
Bluetooth: Make mgmt_set_powered_failed() return void
Bluetooth: Make mgmt_disconnect_failed() return void
Bluetooth: Make mgmt_connect_failed() return void
Bluetooth: Make mgmt_device_connected() return void
Bluetooth: Make mgmt_device_disconnected() return void
Bluetooth: Make mgmt_device_found() return void
Bluetooth: Make mgmt_remote_name() return void
Bluetooth: Make mgmt_discovering() return void
Bluetooth: Power off AMP controllers after setup phase
Bluetooth: Make mgmt power down notification for BR/EDR explicit
Bluetooth: List powered down AMP controllers correctly
Bluetooth: Read supported features and commands on AMP controllers
Bluetooth: Read location data on AMP controller init
Bluetooth: Read flow control mode on AMP controller init
Bluetooth: Remove unneeded val variable when setting SSP
Bluetooth: Restrict high speed support to SSP enabled controllers
Bluetooth: Fix too long line with set_advertising() function
Bluetooth: Use hci_conn_num() for checking number of LE connections
Bluetooth: Use hci_conn_num() instead of direct connection hash access
Bluetooth: AMP contollers do not support the legacy ioctls
Bluetooth: Remove unused bfusb_ioctl() callback
Bluetooth: Remove unused bluecard_hci_ioctl() callback
Bluetooth: Remove unused bt3c_hci_ioctl() callback
Bluetooth: Remove unused btuart_hci_ioctl() callback
Bluetooth: Remove unused dtl1_hci_ioctl() callback
Bluetooth: Remove unused btmrvl_ioctl() callback
Bluetooth: Remove hdev->ioctl driver callback
Bluetooth: Move amp.h header file into net/bluetooth/
Bluetooth: Move a2mp.h header file into net/bluetooth/
Bluetooth: Move smp.h header file into net/bluetooth/
Bluetooth: Move skb->dev assignment for hdev->send into central place
Bluetooth: Remove pointless check of hci_send_frame parameter
Bluetooth: Remove return value from hci_send_frame() function
Bluetooth: Remove unused h4_check_data_len() function
Bluetooth: Provide hdev parameter to hci_recv_frame() driver callback
Bluetooth: Add hdev parameter to hdev->send driver callback
Bluetooth: Remove pointless parameter check in bfusb_send_frame()
Bluetooth: Remove pointless parameter check in bluecard_hci_send_frame()
Bluetooth: Remove pointless parameter check in bt3c_hci_send_frame()
Bluetooth: Remove pointless parameter check in btmrvl_send_frame()
Bluetooth: Remove pointless parameter check in btuart_hci_send_frame()
Bluetooth: Remove pointless parameter check in dtl1_hci_send_frame()
Bluetooth: Remove pointless parameter check in hci_uart_send_frame()
Bluetooth: Remove pointless parameter check in vhci_send_frame()
Bluetooth: Declare btusb_table[] and blacklist_table[] as const
Bluetooth: Declare bfusb_table[] as const
Bluetooth: Declare bpa10x_table[] as const
Bluetooth: Declare ath3k_table[] and ath3k_blist_tbl[] as const
Bluetooth: Make LE scan interval and window a controller option
Bluetooth: Add management command for setting LE scan parameters
Bluetooth: Fix endless loop with HCI_QUIRK_RESET_ON_CLOSE
Bluetooth: Don't advertise high speed support without SSP
Bluetooth: Add MGMT_OP_SET_SCAN_PARAMS to supported commands list
Bluetooth: Fix HCI init for 1st generation BlueFRITZ! devices
Bluetooth: Fix PSM value for L2CAP connectionless data packets
Bluetooth: Limit security mode 4 level 0 to connection oriented channels
Bluetooth: Allow 3D profile to use security mode 4 level 0
Bluetooth: The L2CAP fixed channel connectionless data is supported
Bluetooth: Unicast connectionless data reception is supported
Bluetooth: Remove l2cap_conn->dst usage from AMP manager
Bluetooth: Remove l2cap_conn->src and l2cap_conn->dst usage from SMP
Bluetooth: Remove l2cap_conn->src and l2cap_conn->dst usage from L2CAP
Bluetooth: Remove l2cap_conn->src and l2cap_conn->dst pointers
Bluetooth: Remove pointless bdaddr_to_le() helper function
Bluetooth: Store the source address type of LE connections
Bluetooth: Store source address of HCI connections
Bluetooth: Update source address and type for incoming LE connections
Bluetooth: Use hci_conn->src address for SMP functions
Bluetooth: Use hci_conn->src address for L2CAP functions
Bluetooth: Fix input address type for SMP C1 function
Bluetooth: Fix coding style violations in SMP handling
Bluetooth: Update L2CAP socket source address from HCI connection
Bluetooth: Store address information in L2CAP channel structure
Bluetooth: Return the correct address type for L2CAP sockets
Bluetooth: Access RFCOMM session addresses through L2CAP channel
Bluetooth: Access CMTP session addresses through L2CAP channel
Bluetooth: Access HIDP session addresses through L2CAP channel
Bluetooth: Access BNEP session addresses through L2CAP channel
Bluetooth: Use SCO addresses from HCI connection directly
Bluetooth: Store SCO address information in its own socket structure
Bluetooth: Store RFCOMM address information in its own socket structure
Bluetooth: Remove src and dst fields from bt_sock structure
Bluetooth: Use l2cap_pi(sk) directly where possible
Bluetooth: Add support for per socket msg_name callback
Bluetooth: Provide msg_name callback for L2CAP connectionless channels
Bluetooth: Increase minor version of core module
Bluetooth: Adjust header for proc socket information
Bluetooth: Introduce L2CAP channel flag for defer setup
Bluetooth: Introduce L2CAP channel callback for resuming
Bluetooth: Check that scan window is smaller or equal than scan interval
Bluetooth: Read number of supported IAC on controller setup
Bluetooth: Read current IAC LAP on controller setup
drivers/bluetooth/ath3k.c | 4 +-
drivers/bluetooth/bfusb.c | 31 +--
drivers/bluetooth/bluecard_cs.c | 30 +--
drivers/bluetooth/bpa10x.c | 11 +-
drivers/bluetooth/bt3c_cs.c | 30 +--
drivers/bluetooth/btmrvl_main.c | 26 +-
drivers/bluetooth/btmrvl_sdio.c | 8 +-
drivers/bluetooth/btsdio.c | 6 +-
drivers/bluetooth/btuart_cs.c | 30 +--
drivers/bluetooth/btusb.c | 21 +-
drivers/bluetooth/btwilink.c | 9 +-
drivers/bluetooth/dtl1_cs.c | 30 +--
drivers/bluetooth/hci_bcsp.c | 5 +-
drivers/bluetooth/hci_h4.c | 24 --
drivers/bluetooth/hci_h5.c | 2 +-
drivers/bluetooth/hci_ldisc.c | 12 +-
drivers/bluetooth/hci_ll.c | 14 +-
drivers/bluetooth/hci_vhci.c | 15 +-
include/net/bluetooth/bluetooth.h | 5 +-
include/net/bluetooth/hci.h | 49 +++-
include/net/bluetooth/hci_core.h | 79 ++-----
include/net/bluetooth/l2cap.h | 14 +-
include/net/bluetooth/mgmt.h | 7 +
include/net/bluetooth/rfcomm.h | 2 +
include/net/bluetooth/sco.h | 5 +-
net/bluetooth/a2mp.c | 63 ++---
{include/net => net}/bluetooth/a2mp.h | 0
net/bluetooth/af_bluetooth.c | 23 +-
net/bluetooth/amp.c | 10 +-
{include/net => net}/bluetooth/amp.h | 0
net/bluetooth/bnep/core.c | 18 +-
net/bluetooth/cmtp/core.c | 6 +-
net/bluetooth/hci_conn.c | 156 ++++++++----
net/bluetooth/hci_core.c | 156 +++++++-----
net/bluetooth/hci_event.c | 103 ++++----
net/bluetooth/hci_sock.c | 10 +-
net/bluetooth/hidp/core.c | 18 +-
net/bluetooth/l2cap_core.c | 221 ++++++++++-------
net/bluetooth/l2cap_sock.c | 86 +++++--
net/bluetooth/mgmt.c | 550 ++++++++++++++++++++++++++++++-------------
net/bluetooth/rfcomm/core.c | 19 +-
net/bluetooth/rfcomm/sock.c | 28 ++-
net/bluetooth/sco.c | 44 ++--
net/bluetooth/smp.c | 81 ++++---
{include/net => net}/bluetooth/smp.h | 0
45 files changed, 1192 insertions(+), 869 deletions(-)
rename {include/net => net}/bluetooth/a2mp.h (100%)
rename {include/net => net}/bluetooth/amp.h (100%)
rename {include/net => net}/bluetooth/smp.h (100%)
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* [PATCH] Bluetooth: Fix minor coding style issue in set_connectable()
From: Marcel Holtmann @ 2013-10-14 23:38 UTC (permalink / raw)
To: linux-bluetooth
There is a minor coding style violation and so just fix it. No actual
logic has changed.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index cba15da..9048653 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1297,14 +1297,13 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) &&
cp->val != test_bit(HCI_PSCAN, &hdev->flags)) {
-
if (cp->val) {
scan = SCAN_PAGE;
} else {
scan = 0;
if (test_bit(HCI_ISCAN, &hdev->flags) &&
- hdev->discov_timeout > 0)
+ hdev->discov_timeout > 0)
cancel_delayed_work(&hdev->discov_off);
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH] Bluetooth: Add support for entering limited discoverable mode
From: Marcel Holtmann @ 2013-10-14 23:08 UTC (permalink / raw)
To: linux-bluetooth
The limited discoverable mode should be used when a device is only
discoverable for a certain amount of time and after that it returns
back into being non-discoverable.
The management interface allows to specify a timeout parameter when
makeing a device discoverable. If such a timeout is specified or
changed, enter limited discoverable mode. Otherwise enter general
discoverable mode.
Devices in limited discoverable mode can still be found by the
general discovery procedure. It is mandatory that a device sets
both GIAC and LIAC when entering limited discoverable mode.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 6 ++++++
net/bluetooth/mgmt.c | 41 +++++++++++++++++++++++++++++++++++++----
2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index b096f5f..ab96f3b 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -823,6 +823,12 @@ struct hci_rp_read_num_supported_iac {
#define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
+#define HCI_OP_WRITE_CURRENT_IAC_LAP 0x0c3a
+struct hci_cp_write_current_iac_lap {
+ __u8 num_iac;
+ __u8 iac_lap[6];
+} __packed;
+
#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
#define HCI_MAX_EIR_LENGTH 240
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 861e389..cba15da 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1041,6 +1041,8 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
}
if (!!cp->val == test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) {
+ u16 current_timeout = hdev->discov_timeout;
+
if (hdev->discov_timeout > 0) {
cancel_delayed_work(&hdev->discov_off);
hdev->discov_timeout = 0;
@@ -1052,8 +1054,16 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
msecs_to_jiffies(hdev->discov_timeout * 1000));
}
- err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev);
- goto failed;
+ /* A change in timeout means that the device is switching
+ * from one discoverable mode to another. In that case
+ * the IAC LAP needs to be changed.
+ */
+ if ((current_timeout > 0 && timeout > 0) ||
+ (current_timeout == 0 && timeout == 0)) {
+ err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE,
+ hdev);
+ goto failed;
+ }
}
cmd = mgmt_pending_add(sk, MGMT_OP_SET_DISCOVERABLE, hdev, data, len);
@@ -1066,10 +1076,33 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
scan = SCAN_PAGE;
- if (cp->val)
+ if (cp->val) {
+ struct hci_cp_write_current_iac_lap cp;
+
+ if (timeout > 0) {
+ /* Limited discoverable mode */
+ cp.num_iac = 2;
+ cp.iac_lap[0] = 0x00; /* LIAC */
+ cp.iac_lap[1] = 0x8b;
+ cp.iac_lap[2] = 0x9e;
+ cp.iac_lap[3] = 0x33; /* GIAC */
+ cp.iac_lap[4] = 0x8b;
+ cp.iac_lap[5] = 0x9e;
+ } else {
+ /* General discoverable mode */
+ cp.num_iac = 1;
+ cp.iac_lap[0] = 0x33; /* GIAC */
+ cp.iac_lap[1] = 0x8b;
+ cp.iac_lap[2] = 0x9e;
+ }
+
+ hci_req_add(&req, HCI_OP_WRITE_CURRENT_IAC_LAP,
+ (cp.num_iac * 3) + 1, &cp);
+
scan |= SCAN_INQUIRY;
- else
+ } else {
cancel_delayed_work(&hdev->discov_off);
+ }
hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Read current IAC LAP on controller setup
From: Gustavo Padovan @ 2013-10-14 22:32 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381784796-52321-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
2013-10-14 Marcel Holtmann <marcel@holtmann.org>:
> Read the current IAC LAP values when initializing the controller. The
> values are not used, but it is good to have them in the trace files
> for debugging purposes.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 2 ++
> net/bluetooth/hci_core.c | 3 +++
> 2 files changed, 5 insertions(+)
Both patches have been pushed to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply
* [PATCH] Bluetooth: Read current IAC LAP on controller setup
From: Marcel Holtmann @ 2013-10-14 21:06 UTC (permalink / raw)
To: linux-bluetooth
Read the current IAC LAP values when initializing the controller. The
values are not used, but it is good to have them in the trace files
for debugging purposes.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_core.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 8567f44..b096f5f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -821,6 +821,8 @@ struct hci_rp_read_num_supported_iac {
__u8 num_iac;
} __packed;
+#define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
+
#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
#define HCI_MAX_EIR_LENGTH 240
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b5ef05e..7add9c9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -373,6 +373,9 @@ static void bredr_setup(struct hci_request *req)
/* Read Number of Supported IAC */
hci_req_add(req, HCI_OP_READ_NUM_SUPPORTED_IAC, 0, NULL);
+ /* Read Current IAC LAP */
+ hci_req_add(req, HCI_OP_READ_CURRENT_IAC_LAP, 0, NULL);
+
/* Clear Event Filters */
flt_type = HCI_FLT_CLEAR_ALL;
hci_req_add(req, HCI_OP_SET_EVENT_FLT, 1, &flt_type);
--
1.8.3.1
^ permalink raw reply related
* [PATCH] Bluetooth: Read number of supported IAC on controller setup
From: Marcel Holtmann @ 2013-10-14 20:56 UTC (permalink / raw)
To: linux-bluetooth
When initializing a controller make sure to read out the number of
supported IAC and store its result. This value is needed to determine
if limited discoverable for BR/EDR can be configured or not.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 6 ++++++
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 6 +++++-
net/bluetooth/hci_event.c | 19 +++++++++++++++++++
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index c8a91cb..8567f44 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -815,6 +815,12 @@ struct hci_cp_host_buffer_size {
__le16 sco_max_pkt;
} __packed;
+#define HCI_OP_READ_NUM_SUPPORTED_IAC 0x0c38
+struct hci_rp_read_num_supported_iac {
+ __u8 status;
+ __u8 num_iac;
+} __packed;
+
#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
#define HCI_MAX_EIR_LENGTH 240
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 0326b16..4e20842 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -159,6 +159,7 @@ struct hci_dev {
__u16 manufacturer;
__u16 lmp_subver;
__u16 voice_setting;
+ __u8 num_iac;
__u8 io_capability;
__s8 inq_tx_power;
__u16 page_scan_interval;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0e05ede..b5ef05e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -370,6 +370,9 @@ static void bredr_setup(struct hci_request *req)
/* Read Voice Setting */
hci_req_add(req, HCI_OP_READ_VOICE_SETTING, 0, NULL);
+ /* Read Number of Supported IAC */
+ hci_req_add(req, HCI_OP_READ_NUM_SUPPORTED_IAC, 0, NULL);
+
/* Clear Event Filters */
flt_type = HCI_FLT_CLEAR_ALL;
hci_req_add(req, HCI_OP_SET_EVENT_FLT, 1, &flt_type);
@@ -2271,7 +2274,8 @@ struct hci_dev *hci_alloc_dev(void)
hdev->pkt_type = (HCI_DM1 | HCI_DH1 | HCI_HV1);
hdev->esco_type = (ESCO_HV1);
hdev->link_mode = (HCI_LM_ACCEPT);
- hdev->io_capability = 0x03; /* No Input No Output */
+ hdev->num_iac = 0x01; /* One IAC support is mandatory */
+ hdev->io_capability = 0x03; /* No Input No Output */
hdev->inq_tx_power = HCI_TX_POWER_INVALID;
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index da2bc3d..5391469 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -418,6 +418,21 @@ static void hci_cc_write_voice_setting(struct hci_dev *hdev,
hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
}
+static void hci_cc_read_num_supported_iac(struct hci_dev *hdev,
+ struct sk_buff *skb)
+{
+ struct hci_rp_read_num_supported_iac *rp = (void *) skb->data;
+
+ BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+
+ if (rp->status)
+ return;
+
+ hdev->num_iac = rp->num_iac;
+
+ BT_DBG("%s num iac %d", hdev->name, hdev->num_iac);
+}
+
static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -2135,6 +2150,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_cc_write_voice_setting(hdev, skb);
break;
+ case HCI_OP_READ_NUM_SUPPORTED_IAC:
+ hci_cc_read_num_supported_iac(hdev, skb);
+ break;
+
case HCI_OP_WRITE_SSP_MODE:
hci_cc_write_ssp_mode(hdev, skb);
break;
--
1.8.3.1
^ permalink raw reply related
* [RFC BlueZ v0] doc: Add GATT API
From: Claudio Takahasi @ 2013-10-14 19:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch proposes an unified GATT API for local and remote services.
---
Partial implementation of the proposed API:
git://git.infradead.org/users/cktakahasi/bluez.git gatt-api-devel
doc/gatt-api.txt | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 158 insertions(+)
create mode 100644 doc/gatt-api.txt
diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
new file mode 100644
index 0000000..af4d68d
--- /dev/null
+++ b/doc/gatt-api.txt
@@ -0,0 +1,158 @@
+BlueZ D-Bus GATT API description
+********************************
+
+GATT local and remote services share the same high-level D-Bus API. Local
+refers to local GATT based service exported by a BlueZ plugin or an external
+application. Remote refers to GATT services exported by the peer.
+
+BlueZ acts as a proxy, translating ATT operations to D-Bus method calls and
+Properties (or the opposite). Support for D-Bus Object Manager is mandatory for
+external services to allow seamless GATT declarations (Service, Characteristic
+and Descriptors) discovery.
+
+Service hierarchy
+=================
+
+GATT remote and local service representation. Object path for local services
+is freely definable.
+
+External local services should register the services using ServiceManager1
+registration method and must implement ServiceAgent1 interface.
+
+Service org.bluez
+Interface org.bluez.Service1 [Experimental]
+Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX
+
+Properties string UUID [read-only]
+
+ 128-bit UUID of the GATT based service. It represents
+ the UUID of a local external service or remote GATT
+ service.
+
+ array{object} Includes [read-only]: Not implemented
+
+ Array of object paths representing the included
+ services of this service.
+
+
+Characteristic hierarchy
+========================
+
+For local GATT defined services, the object paths need to follow the service
+path hierarchy and are freely definable.
+
+Service org.bluez
+Interface org.bluez.Characteristic1 [Experimental]
+Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY
+
+Properties string UUID [read-only]
+
+ 128-bit characteristic UUID. It represents the UUID of
+ a local external characteristic or remote GATT
+ characteristic.
+
+ object Service [read-only]
+
+ Object path of the GATT service the characteristc
+ belongs to.
+
+ array{byte} Value [read-write]
+
+ Cached Value of the characteristic. If present, the
+ value will be cached by bluetoothd and updated when the
+ PropertiesChanged signal is emitted.
+
+ External services must emit this signal when the
+ characteristic supports notification/indication, so
+ that clients can be notified of the new value.
+
+ array{string} Flags [read-only, optional]
+
+ Defines how the characteristic value can be used. See
+ Core spec page 1898, "Table 3.5: Characteristic
+ Properties bit field" and page 1900, "Table 3.8:
+ Characteristic Extended Properties bit field". Allowed
+ values: "broadcast", "read", "write-without-response",
+ "write", "notify", "indicate",
+ "authenticated-signed-writes", "reliable-write", and
+ "writable-auxiliaries".
+
+
+Characteristic Descriptors hierarchy
+====================================
+
+Local or remote GATT characteristic descriptors hierarchy.
+
+Service org.bluez
+Interface org.bluez.Descriptor1 [Experimental]
+Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ
+
+Properties string UUID [read-only]
+
+ 128-bit descriptor UUID. It represents the UUID of a
+ local external descriptor or remote descriptor.
+
+ object Characteristic [read-only]
+
+ Object path of the GATT characteristc the descriptor
+ belongs to.
+
+ array{byte} Value [read-write]
+
+ Raw characteristic descriptor value. For external GATT
+ services, value changes should be reported through
+ PropertiesChanged signal.
+
+ string Permissions [read-only]: To be defined
+
+ Defines read/write authentication and authorization
+ requirements.
+
+Service Manager hierarchy
+=========================
+
+ServiceManager allows external applications to register GATT based services.
+Services should follow the API for Service and Characteristic described above.
+
+For GATT local services, services and characteristics definitions are
+discovered automatically using D-Bus Object Manager.
+
+Service org.bluez
+Interface org.bluez.ServiceManager1 [Experimental]
+Object path /org/bluez
+
+Methods RegisterApplication(object application, dict options)
+
+ Registers remote application services exported under
+ the interface Service1. Characteristic objects must
+ be hierarchical to their service and must use the
+ interface Characteristic1. D-Bus Object Manager is
+ used to fetch the exported objects.
+
+ "application" object path together with the D-Bus system
+ bus connection ID define the identification of the
+ application registering a GATT based service.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.AlreadyExists
+
+ UnregisterApplication(object application)
+
+ This unregisters the application that has been
+ previously registered. The object path parameter
+ must match the same value that has been used
+ on registration.
+
+ Possible errors: org.bluez.Error.DoesNotExist
+
+Service Agent hierarchy
+=======================
+
+Service org.bluez
+Interface org.bluez.ServiceAgent1 [Experimental]
+Object path freely definable
+
+Methods void Release()
+
+ Release this agent. At this point, it will not be used
+ by BlueZ anymore and can be destroyed by the owner.
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Check that scan window is smaller or equal than scan interval
From: Johan Hedberg @ 2013-10-14 18:36 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381769732-19707-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Mon, Oct 14, 2013, Marcel Holtmann wrote:
> 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(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 2/2] Bluetooth: Check that bind() bdaddr type matches connect()
From: Marcel Holtmann @ 2013-10-14 18:27 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381774673-14150-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> 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(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Reject invalid bdaddr types for sockets
From: Marcel Holtmann @ 2013-10-14 18:27 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381774673-14150-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> 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(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* 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
* [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
* [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 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 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 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 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 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
* 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] 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