* [PATCH v2 3/6] android: Define path for HAL communication socket
From: Szymon Janc @ 2013-10-20 9:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382262838-25725-1-git-send-email-szymon.janc@tieto.com>
This socket will be used by android daemon and libhal to communitate.
---
android/hal-msg.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4c5ca69..4440fc8 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -21,6 +21,8 @@
*
*/
+static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
+
struct hal_msg_hdr {
uint8_t service_id;
uint8_t opcode;
--
1.8.4
^ permalink raw reply related
* [PATCH v2 2/6] android: Improve cutils/log.h stubs
From: Szymon Janc @ 2013-10-20 9:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382262838-25725-1-git-send-email-szymon.janc@tieto.com>
Provide dummy function that will use ALOG* macros parameters. This fix
build errors about set-but-not-used used local variables on linux.
---
android/cutils/log.h | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/android/cutils/log.h b/android/cutils/log.h
index d87da72..389542b 100644
--- a/android/cutils/log.h
+++ b/android/cutils/log.h
@@ -17,11 +17,13 @@
#ifndef _CUTILS_LOG_H
#define _CUTILS_LOG_H
-#define ALOGV(...)
-#define ALOGD(...)
-#define ALOGI(...)
-#define ALOGW(...)
-#define ALOGE(...)
+static inline void ALOG() {};
+
+#define ALOGV(...) ALOG("V", __VA_ARGS__)
+#define ALOGD(...) ALOG("D", __VA_ARGS__)
+#define ALOGI(...) ALOG("I", __VA_ARGS__)
+#define ALOGW(...) ALOG("W", __VA_ARGS__)
+#define ALOGE(...) ALOG("E", __VA_ARGS__)
#define LOG_ALWAYS_FATAL(...) do { ALOGE(__VA_ARGS__); exit(1); } while (0)
#endif // _CUTILS_LOG_H
--
1.8.4
^ permalink raw reply related
* [PATCH v2 1/6] android: Fix missing log cleanup on daemon exit
From: Szymon Janc @ 2013-10-20 9:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382262838-25725-1-git-send-email-szymon.janc@tieto.com>
---
android/main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/main.c b/android/main.c
index c3fb80e..cfa728d 100644
--- a/android/main.c
+++ b/android/main.c
@@ -341,5 +341,7 @@ int main(int argc, char *argv[])
info("Exit");
+ __btd_log_cleanup();
+
return EXIT_SUCCESS;
}
--
1.8.4
^ permalink raw reply related
* [PATCH v2 0/6] Initial Android IPC
From: Szymon Janc @ 2013-10-20 9:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
V2:
- simplify daemon code
- sockets handling cleanup
- other minor fixes
--
BR
Szymon Janc
Szymon Janc (6):
android: Fix missing log cleanup on daemon exit
android: Improve cutils/log.h stubs
android: Define path for HAL communication socket
android: Connect daemon to HAL library
android: Make HAL library wait for daemon to connect on init
android: Remove not needed property_get function form cutils stubs
android/cutils/log.h | 10 ++--
android/cutils/properties.h | 27 ----------
android/hal-bluetooth.c | 126 ++++++++++++++++++++++++++++++++++++--------
android/hal-msg.h | 2 +
android/main.c | 124 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 234 insertions(+), 55 deletions(-)
--
1.8.4
^ permalink raw reply
* [PATCH v2] Bluetooth: Update Set Discoverable to support LE
From: johan.hedberg @ 2013-10-20 8:55 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-10-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch updates the Set Discoverable management command to also be
applicable for LE. In particular this affects the advertising flags
where we can say "general discoverable" or "limited discoverable".
Since the device flags may not be up-to-date when the advertising data
is written this patch introduces a get_adv_discov_flags() helper
function which also looks at any pending mgmt commands (a pending
set_discoverable would be the exception when the flags are not yet
correct).
The patch also adds HCI_DISCOVERABLE flag clearing to the
mgmt_discoverable_timeout function, since the code was previously
relying on the mgmt_discoverable callback to handle this, which is only
called for the BR/EDR-only HCI_Write_Scan_Enable command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
v2:
* Fix advertising flags update when disabling connectable while
discoverable is enabled.
* Fix redundant check for HCI_LE_ENABLED
net/bluetooth/mgmt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 63 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 796db58..5ac0b9a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -599,12 +599,35 @@ static void update_scan_rsp_data(struct hci_request *req)
hci_req_add(req, HCI_OP_LE_SET_SCAN_RSP_DATA, sizeof(cp), &cp);
}
+static u8 get_adv_discov_flags(struct hci_dev *hdev)
+{
+ struct pending_cmd *cmd;
+
+ /* If there's a pending mgmt command the flags will not yet have
+ * their final values, so check for this first.
+ */
+ cmd = mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev);
+ if (cmd) {
+ struct mgmt_mode *cp = cmd->param;
+ if (cp->val == 0x01)
+ return LE_AD_GENERAL;
+ else if (cp->val == 0x02)
+ return LE_AD_LIMITED;
+ } else {
+ if (test_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags))
+ return LE_AD_LIMITED;
+ else if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
+ return LE_AD_GENERAL;
+ }
+
+ return 0;
+}
+
static u8 create_adv_data(struct hci_dev *hdev, u8 *ptr)
{
u8 ad_len = 0, flags = 0;
- if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
- flags |= LE_AD_GENERAL;
+ flags |= get_adv_discov_flags(hdev);
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
if (lmp_le_br_capable(hdev))
@@ -1120,15 +1143,15 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
struct pending_cmd *cmd;
struct hci_request req;
u16 timeout;
- 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_DISCOVERABLE,
- status);
+ MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
@@ -1228,6 +1251,12 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_req_init(&req, hdev);
+ /* The procedure for LE-only controllers is much simpler - just
+ * update the advertising data.
+ */
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
+ goto update_ad;
+
scan = SCAN_PAGE;
if (cp->val) {
@@ -1260,6 +1289,9 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan);
+update_ad:
+ update_adv_data(&req);
+
err = hci_req_run(&req, set_discoverable_complete);
if (err < 0)
mgmt_pending_remove(cmd);
@@ -1451,8 +1483,15 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_req_init(&req, hdev);
- if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) &&
- cp->val != test_bit(HCI_PSCAN, &hdev->flags)) {
+ /* If BR/EDR is not enabled and we disable advertising as a
+ * by-product of disabling connectable, we need to update the
+ * advertising flags.
+ */
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
+ if (!cp->val)
+ clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
+ update_adv_data(&req);
+ } else if (cp->val != test_bit(HCI_PSCAN, &hdev->flags)) {
if (cp->val) {
scan = SCAN_PAGE;
} else {
@@ -4348,6 +4387,7 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev)
* safe to unconditionally clear the flag.
*/
clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
+ clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
hci_req_init(&req, hdev);
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
@@ -4356,10 +4396,13 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev)
sizeof(scan), &scan);
}
update_class(&req);
+ update_adv_data(&req);
hci_req_run(&req, NULL);
hdev->discov_timeout = 0;
+ new_settings(hdev, NULL);
+
hci_dev_unlock(hdev);
}
@@ -4379,8 +4422,19 @@ void mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
else
changed = test_and_clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
- if (changed)
+ if (changed) {
+ struct hci_request req;
+
+ /* In case this change in discoverable was triggered by
+ * a disabling of connectable there could be a need to
+ * update the advertising flags.
+ */
+ hci_req_init(&req, hdev);
+ update_adv_data(&req);
+ hci_req_run(&req, NULL);
+
new_settings(hdev, NULL);
+ }
}
void mgmt_connectable(struct hci_dev *hdev, u8 connectable)
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH 9/9] Bluetooth: Update Set Discoverable to support LE
From: Marcel Holtmann @ 2013-10-19 22:11 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1382215103-6968-10-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch updates the Set Discoverable management command to also be
> applicable for LE. In particular this affects the advertising flags
> where we can say "general discoverable" or "limited discoverable".
>
> Since the device flags may not be up-to-date when the advertising data
> is written this patch introduces a get_adv_discov_flags() helper
> function which also looks at any pending mgmt commands (a pending
> set_discoverable would be the exception when the flags are not yet
> correct).
>
> The patch also adds HCI_DISCOVERABLE flag clearing to the
> mgmt_discoverable_timeout function, since the code was previously
> relying on the mgmt_discoverable callback to handle this, which is only
> called for the BR/EDR-only HCI_Write_Scan_Enable command.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 43 insertions(+), 6 deletions(-)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 796db58..73ed132 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -599,12 +599,35 @@ static void update_scan_rsp_data(struct hci_request *req)
> hci_req_add(req, HCI_OP_LE_SET_SCAN_RSP_DATA, sizeof(cp), &cp);
> }
>
> +static u8 get_adv_discov_flags(struct hci_dev *hdev)
> +{
> + struct pending_cmd *cmd;
> +
> + /* If there's a pending mgmt command the flags will not yet have
> + * their final values, so check for this first.
> + */
> + cmd = mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev);
> + if (cmd) {
> + struct mgmt_mode *cp = cmd->param;
> + if (cp->val == 0x01)
> + return LE_AD_GENERAL;
> + else if (cp->val == 0x02)
> + return LE_AD_LIMITED;
> + } else {
> + if (test_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags))
> + return LE_AD_LIMITED;
> + else if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
> + return LE_AD_GENERAL;
> + }
> +
> + return 0;
> +}
> +
> static u8 create_adv_data(struct hci_dev *hdev, u8 *ptr)
> {
> u8 ad_len = 0, flags = 0;
>
> - if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
> - flags |= LE_AD_GENERAL;
> + flags |= get_adv_discov_flags(hdev);
>
> if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
> if (lmp_le_br_capable(hdev))
> @@ -1120,15 +1143,15 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
> struct pending_cmd *cmd;
> struct hci_request req;
> u16 timeout;
> - 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_DISCOVERABLE,
> - status);
> + MGMT_STATUS_REJECTED);
>
> if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
> return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
> @@ -1228,6 +1251,12 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
>
> hci_req_init(&req, hdev);
>
> + /* The procedure for LE-only controllers is much simpler - just
> + * update the advertising data.
> + */
> + if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
> + goto update_ad;
> +
> scan = SCAN_PAGE;
>
> if (cp->val) {
> @@ -1260,6 +1289,10 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
>
> hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan);
>
> +update_ad:
> + if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
> + update_adv_data(&req);
> +
actually update_adv_data() check for HCI_LE_ENABLED all by itself. So this check is just duplicated and not needed here.
Regards
Marcel
^ permalink raw reply
* [PATCH 9/9] Bluetooth: Update Set Discoverable to support LE
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch updates the Set Discoverable management command to also be
applicable for LE. In particular this affects the advertising flags
where we can say "general discoverable" or "limited discoverable".
Since the device flags may not be up-to-date when the advertising data
is written this patch introduces a get_adv_discov_flags() helper
function which also looks at any pending mgmt commands (a pending
set_discoverable would be the exception when the flags are not yet
correct).
The patch also adds HCI_DISCOVERABLE flag clearing to the
mgmt_discoverable_timeout function, since the code was previously
relying on the mgmt_discoverable callback to handle this, which is only
called for the BR/EDR-only HCI_Write_Scan_Enable command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 796db58..73ed132 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -599,12 +599,35 @@ static void update_scan_rsp_data(struct hci_request *req)
hci_req_add(req, HCI_OP_LE_SET_SCAN_RSP_DATA, sizeof(cp), &cp);
}
+static u8 get_adv_discov_flags(struct hci_dev *hdev)
+{
+ struct pending_cmd *cmd;
+
+ /* If there's a pending mgmt command the flags will not yet have
+ * their final values, so check for this first.
+ */
+ cmd = mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev);
+ if (cmd) {
+ struct mgmt_mode *cp = cmd->param;
+ if (cp->val == 0x01)
+ return LE_AD_GENERAL;
+ else if (cp->val == 0x02)
+ return LE_AD_LIMITED;
+ } else {
+ if (test_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags))
+ return LE_AD_LIMITED;
+ else if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
+ return LE_AD_GENERAL;
+ }
+
+ return 0;
+}
+
static u8 create_adv_data(struct hci_dev *hdev, u8 *ptr)
{
u8 ad_len = 0, flags = 0;
- if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
- flags |= LE_AD_GENERAL;
+ flags |= get_adv_discov_flags(hdev);
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
if (lmp_le_br_capable(hdev))
@@ -1120,15 +1143,15 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
struct pending_cmd *cmd;
struct hci_request req;
u16 timeout;
- 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_DISCOVERABLE,
- status);
+ MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
@@ -1228,6 +1251,12 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_req_init(&req, hdev);
+ /* The procedure for LE-only controllers is much simpler - just
+ * update the advertising data.
+ */
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
+ goto update_ad;
+
scan = SCAN_PAGE;
if (cp->val) {
@@ -1260,6 +1289,10 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan);
+update_ad:
+ if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
+ update_adv_data(&req);
+
err = hci_req_run(&req, set_discoverable_complete);
if (err < 0)
mgmt_pending_remove(cmd);
@@ -4348,6 +4381,7 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev)
* safe to unconditionally clear the flag.
*/
clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
+ clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
hci_req_init(&req, hdev);
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
@@ -4356,10 +4390,13 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev)
sizeof(scan), &scan);
}
update_class(&req);
+ update_adv_data(&req);
hci_req_run(&req, NULL);
hdev->discov_timeout = 0;
+ new_settings(hdev, NULL);
+
hci_dev_unlock(hdev);
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 8/9] Bluetooth: Move HCI_LIMITED_DISCOVERABLE changes to a general place
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We'll soon be introducing also LE support for the Set Discoverable
management command, so move the HCI_LIMITED_DISCOVERABLE flag clearing
and setting out from the if-branch that is only used for a BR/EDR
specific HCI command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 67b95a8..796db58 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1220,6 +1220,12 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
cancel_delayed_work(&hdev->discov_off);
hdev->discov_timeout = timeout;
+ /* Limited discoverable mode */
+ if (cp->val == 0x02)
+ set_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
+ else
+ clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
+
hci_req_init(&req, hdev);
scan = SCAN_PAGE;
@@ -1229,8 +1235,6 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
if (cp->val == 0x02) {
/* Limited discoverable mode */
- set_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
-
hci_cp.num_iac = 2;
hci_cp.iac_lap[0] = 0x00; /* LIAC */
hci_cp.iac_lap[1] = 0x8b;
@@ -1240,8 +1244,6 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_cp.iac_lap[5] = 0x9e;
} else {
/* General discoverable mode */
- clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
-
hci_cp.num_iac = 1;
hci_cp.iac_lap[0] = 0x33; /* GIAC */
hci_cp.iac_lap[1] = 0x8b;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 7/9] Bluetooth: Fix sending write_scan_enable when BR/EDR is disabled
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We should only send the HCI_Write_Scan_Enable command from
mgmt_set_powered_failed() when BR/EDR support is enabled. This is
particularly important when the discoverable setting is also tied to LE.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 20f6309..67b95a8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4337,7 +4337,6 @@ void mgmt_set_powered_failed(struct hci_dev *hdev, int err)
void mgmt_discoverable_timeout(struct hci_dev *hdev)
{
struct hci_request req;
- u8 scan = SCAN_PAGE;
hci_dev_lock(hdev);
@@ -4349,7 +4348,11 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev)
clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
hci_req_init(&req, hdev);
- hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan);
+ if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
+ u8 scan = SCAN_PAGE;
+ hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE,
+ sizeof(scan), &scan);
+ }
update_class(&req);
hci_req_run(&req, NULL);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 6/9] Bluetooth: Move mgmt_pending_find to avoid forward declarations
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We will soon need this function for updating the advertising data, so
move it higher up in mgmt.c to avoid a forward declaration.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 51d0446..20f6309 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -536,6 +536,18 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
return ptr;
}
+static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev)
+{
+ struct pending_cmd *cmd;
+
+ list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
+ if (cmd->opcode == opcode)
+ return cmd;
+ }
+
+ return NULL;
+}
+
static u8 create_scan_rsp_data(struct hci_dev *hdev, u8 *ptr)
{
u8 ad_len = 0;
@@ -886,18 +898,6 @@ static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,
}
}
-static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev)
-{
- struct pending_cmd *cmd;
-
- list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
- if (cmd->opcode == opcode)
- return cmd;
- }
-
- return NULL;
-}
-
static void mgmt_pending_remove(struct pending_cmd *cmd)
{
list_del(&cmd->list);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 5/9] Bluetooth: Fix updating settings when there are no HCI commands to send
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
It is possible that the Set Connectable management command doesn't cause
any HCI commands to send (such as when BR/EDR is disabled). We can't
just send a response to user space in this case but must also update the
necessary device flags and settings. This patch fixes the issue by using
the recently introduced set_connectable_update_settings function.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b74a157..51d0446 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1483,8 +1483,8 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
if (err < 0) {
mgmt_pending_remove(cmd);
if (err == -ENODATA)
- err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE,
- hdev);
+ err = set_connectable_update_settings(hdev, sk,
+ cp->val);
goto failed;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 4/9] Bluetooth: Refactor set_connectable settings update to separate function
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We will need to directly update the device flags and notify user space
of the new settings not just when we're powered off but also if it turns
out that there are no HCI commands to send (which can happen in
particular when BR/EDR is disabled). Since this is a considerable amount
of code, refactor it to a separate function so it can be reused for the
"no HCI commands to send" case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c363285..b74a157 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1381,6 +1381,32 @@ unlock:
hci_dev_unlock(hdev);
}
+static int set_connectable_update_settings(struct hci_dev *hdev,
+ struct sock *sk, u8 val)
+{
+ bool changed = false;
+ int err;
+
+ if (!!val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
+ changed = true;
+
+ if (val) {
+ set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ } else {
+ clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
+ }
+
+ err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev);
+ if (err < 0)
+ return err;
+
+ if (changed)
+ return new_settings(hdev, sk);
+
+ return 0;
+}
+
static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
u16 len)
{
@@ -1404,25 +1430,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) {
- bool changed = false;
-
- if (!!cp->val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
- changed = true;
-
- if (cp->val) {
- set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
- } else {
- clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
- clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
- }
-
- err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev);
- if (err < 0)
- goto failed;
-
- if (changed)
- err = new_settings(hdev, sk);
-
+ err = set_connectable_update_settings(hdev, sk, cp->val);
goto failed;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 3/9] Bluetooth: Add missing check for BREDR_ENABLED flag in update_class()
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We shouldn't be sending the HCI_Write_Class_Of_Device command when
BR/EDR is disabled since this is a BR/EDR-only command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index dd0bd4a..c363285 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -749,6 +749,9 @@ static void update_class(struct hci_request *req)
if (!hdev_is_powered(hdev))
return;
+ if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
+ return;
+
if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
return;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/9] Bluetooth: Check for flag instead of features in update_adv_data()
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
It's better to check for the device flag instead of device features so
that we avoid unnecessary HCI commands when the feature is supported but
disabled (i.e. the flag is unset).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f39bab0..dd0bd4a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -632,7 +632,7 @@ static void update_adv_data(struct hci_request *req)
struct hci_cp_le_set_adv_data cp;
u8 len;
- if (!lmp_le_capable(hdev))
+ if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
return;
memset(&cp, 0, sizeof(cp));
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/9] Bluetooth: Check for flag instead of features in update_scan_rsp_data()
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382215103-6968-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
It's better to check for the device flag instead of device features so
that we avoid unnecessary HCI commands when the feature is supported but
disabled (i.e. the flag is unset).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fb7fc9f..f39bab0 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -568,7 +568,7 @@ static void update_scan_rsp_data(struct hci_request *req)
struct hci_cp_le_set_scan_rsp_data cp;
u8 len;
- if (!lmp_le_capable(hdev))
+ if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
return;
memset(&cp, 0, sizeof(cp));
--
1.8.3.1
^ permalink raw reply related
* [PATCH 0/9] Bluetooth: Add LE support for mgmt_set_discoverable
From: johan.hedberg @ 2013-10-19 20:38 UTC (permalink / raw)
To: linux-bluetooth
Hi,
In addition to a couple if fixes in the existing mgmt code (first 5
patches), this patch set adds support for hooking up the
set_discoverable command to LE, in particular the advertising flags.
Johan
----------------------------------------------------------------
Johan Hedberg (9):
Bluetooth: Check for flag instead of features in update_scan_rsp_data()
Bluetooth: Check for flag instead of features in update_adv_data()
Bluetooth: Add missing check for BREDR_ENABLED flag in update_class()
Bluetooth: Refactor set_connectable settings update to separate function
Bluetooth: Fix updating settings when there are no HCI commands to send
Bluetooth: Move mgmt_pending_find to avoid forward declarations
Bluetooth: Fix sending write_scan_enable when BR/EDR is disabled
Bluetooth: Move HCI_LIMITED_DISCOVERABLE changes to a general place
Bluetooth: Update Set Discoverable to support LE
net/bluetooth/mgmt.c | 147 +++++++++++++++++++++++++++++++++----------------
1 file changed, 100 insertions(+), 47 deletions(-)
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix minor coding style issue in hci_core.c
From: Johan Hedberg @ 2013-10-19 17:52 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382203155-27291-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Oct 19, 2013, Marcel Holtmann wrote:
> A few variable assignments ended up with missing a space between the
> variable and equal sign.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix UUID values in blacklist debugfs file
From: Johan Hedberg @ 2013-10-19 17:51 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382200319-26951-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Oct 19, 2013, Marcel Holtmann wrote:
> The uuid entry struct is used for the UUID byte stream. That is
> actually the wrong value. The correct value is uuid->uuid.
>
> Besides fixing this up, use the %pUb modifier to print the UUID
> string. However since the UUID is stored in big endian with
> reversed byte order, change the byte order before printing.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
Applied (after removing the bogus "blacklist" word from the subject).
Thanks.
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Fix minor coding style issue in hci_core.c
From: Marcel Holtmann @ 2013-10-19 17:19 UTC (permalink / raw)
To: linux-bluetooth
A few variable assignments ended up with missing a space between the
variable and equal sign.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index c5fb3a3..6ccc4eb 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -423,7 +423,7 @@ static int idle_timeout_set(void *data, u64 val)
return -EINVAL;
hci_dev_lock(hdev);
- hdev->idle_timeout= val;
+ hdev->idle_timeout = val;
hci_dev_unlock(hdev);
return 0;
@@ -451,7 +451,7 @@ static int sniff_min_interval_set(void *data, u64 val)
return -EINVAL;
hci_dev_lock(hdev);
- hdev->sniff_min_interval= val;
+ hdev->sniff_min_interval = val;
hci_dev_unlock(hdev);
return 0;
@@ -479,7 +479,7 @@ static int sniff_max_interval_set(void *data, u64 val)
return -EINVAL;
hci_dev_lock(hdev);
- hdev->sniff_max_interval= val;
+ hdev->sniff_max_interval = val;
hci_dev_unlock(hdev);
return 0;
@@ -588,7 +588,7 @@ static int conn_min_interval_set(void *data, u64 val)
return -EINVAL;
hci_dev_lock(hdev);
- hdev->le_conn_min_interval= val;
+ hdev->le_conn_min_interval = val;
hci_dev_unlock(hdev);
return 0;
@@ -616,7 +616,7 @@ static int conn_max_interval_set(void *data, u64 val)
return -EINVAL;
hci_dev_lock(hdev);
- hdev->le_conn_max_interval= val;
+ hdev->le_conn_max_interval = val;
hci_dev_unlock(hdev);
return 0;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v2 3/3] Bluetooth: Expose debugfs settings for LE connection interval
From: Anderson Lizardo @ 2013-10-19 17:07 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ development
In-Reply-To: <1382191753-59287-3-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Oct 19, 2013 at 10:09 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> +static int conn_min_interval_set(void *data, u64 val)
> +{
> + struct hci_dev *hdev = data;
> +
> + if (val < 0x0006 || val > 0x0c80 || val > hdev->le_conn_max_interval)
> + return -EINVAL;
> +
> + hci_dev_lock(hdev);
> + hdev->le_conn_min_interval= val;
Minor style issue: missing space before "=".
> + hci_dev_unlock(hdev);
> +
> + return 0;
> +}
> [snip]
> +static int conn_max_interval_set(void *data, u64 val)
> +{
> + struct hci_dev *hdev = data;
> +
> + if (val < 0x0006 || val > 0x0c80 || val < hdev->le_conn_min_interval)
> + return -EINVAL;
> +
> + hci_dev_lock(hdev);
> + hdev->le_conn_max_interval= val;
Same above.
> + hci_dev_unlock(hdev);
> +
> + return 0;
> +}
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH] Bluetooth: Fix UUID values in blacklist debugfs file
From: Marcel Holtmann @ 2013-10-19 16:31 UTC (permalink / raw)
To: linux-bluetooth
The uuid entry struct is used for the UUID byte stream. That is
actually the wrong value. The correct value is uuid->uuid.
Besides fixing this up, use the %pUb modifier to print the UUID
string. However since the UUID is stored in big endian with
reversed byte order, change the byte order before printing.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b5c8cb3..c5fb3a3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -193,18 +193,16 @@ static int uuids_show(struct seq_file *f, void *p)
hci_dev_lock(hdev);
list_for_each_entry(uuid, &hdev->uuids, list) {
- u32 data0, data5;
- u16 data1, data2, data3, data4;
-
- data5 = get_unaligned_le32(uuid);
- data4 = get_unaligned_le16(uuid + 4);
- data3 = get_unaligned_le16(uuid + 6);
- data2 = get_unaligned_le16(uuid + 8);
- data1 = get_unaligned_le16(uuid + 10);
- data0 = get_unaligned_le32(uuid + 12);
-
- seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
- data0, data1, data2, data3, data4, data5);
+ u8 i, val[16];
+
+ /* The Bluetooth UUID values are stored in big endian,
+ * but with reversed byte order. So convert them into
+ * the right order for the %pUb modifier.
+ */
+ for (i = 0; i < 16; i++)
+ val[i] = uuid->uuid[15 - i];
+
+ seq_printf(f, "%pUb\n", val);
}
hci_dev_unlock(hdev);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v2 1/3] Bluetooth: Add support for setting SSP debug mode
From: Johan Hedberg @ 2013-10-19 16:07 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382191753-59287-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Oct 19, 2013, Marcel Holtmann wrote:
> Enabling and disabling SSP debug mode is useful for development. This
> adds a debugfs entry that allows to configure the SSP debug mode.
>
> On purpose this has been implemented as debugfs entry and not a public
> API since it is really only useful during testing and development.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 2 ++
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_core.c | 54 +++++++++++++++++++++++++++++++++++++++-
> net/bluetooth/hci_event.c | 2 ++
> 4 files changed, 58 insertions(+), 1 deletion(-)
All three patches have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* [PATCH v2 3/3] Bluetooth: Expose debugfs settings for LE connection interval
From: Marcel Holtmann @ 2013-10-19 14:09 UTC (permalink / raw)
To: linux-bluetooth
For testing purposes expose the default LE connection interval values
via debugfs.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 2 ++
net/bluetooth/hci_conn.c | 5 ++--
net/bluetooth/hci_core.c | 62 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d50cc7a..8c0ab3d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -169,6 +169,8 @@ struct hci_dev {
__u8 page_scan_type;
__u16 le_scan_interval;
__u16 le_scan_window;
+ __u16 le_conn_min_interval;
+ __u16 le_conn_max_interval;
__u8 ssp_debug_mode;
__u16 devid_source;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 974d7bc..ba5366c 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -558,11 +558,12 @@ static int hci_create_le_conn(struct hci_conn *conn)
bacpy(&cp.peer_addr, &conn->dst);
cp.peer_addr_type = conn->dst_type;
cp.own_address_type = conn->src_type;
- cp.conn_interval_min = __constant_cpu_to_le16(0x0028);
- cp.conn_interval_max = __constant_cpu_to_le16(0x0038);
+ cp.conn_interval_min = cpu_to_le16(hdev->le_conn_min_interval);
+ cp.conn_interval_max = cpu_to_le16(hdev->le_conn_max_interval);
cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
cp.min_ce_len = __constant_cpu_to_le16(0x0000);
cp.max_ce_len = __constant_cpu_to_le16(0x0000);
+
hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
err = hci_req_run(&req, create_le_conn_complete);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 4a5e567..b5c8cb3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -582,6 +582,62 @@ static const struct file_operations long_term_keys_fops = {
.release = single_release,
};
+static int conn_min_interval_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+
+ if (val < 0x0006 || val > 0x0c80 || val > hdev->le_conn_max_interval)
+ return -EINVAL;
+
+ hci_dev_lock(hdev);
+ hdev->le_conn_min_interval= val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int conn_min_interval_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->le_conn_min_interval;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(conn_min_interval_fops, conn_min_interval_get,
+ conn_min_interval_set, "%llu\n");
+
+static int conn_max_interval_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+
+ if (val < 0x0006 || val > 0x0c80 || val < hdev->le_conn_min_interval)
+ return -EINVAL;
+
+ hci_dev_lock(hdev);
+ hdev->le_conn_max_interval= val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int conn_max_interval_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->le_conn_max_interval;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(conn_max_interval_fops, conn_max_interval_get,
+ conn_max_interval_set, "%llu\n");
+
/* ---- HCI requests ---- */
static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
@@ -1346,6 +1402,10 @@ static int __hci_init(struct hci_dev *hdev)
hdev, &own_address_type_fops);
debugfs_create_file("long_term_keys", 0400, hdev->debugfs,
hdev, &long_term_keys_fops);
+ debugfs_create_file("conn_min_interval", 0644, hdev->debugfs,
+ hdev, &conn_min_interval_fops);
+ debugfs_create_file("conn_max_interval", 0644, hdev->debugfs,
+ hdev, &conn_max_interval_fops);
}
return 0;
@@ -2811,6 +2871,8 @@ struct hci_dev *hci_alloc_dev(void)
hdev->le_scan_interval = 0x0060;
hdev->le_scan_window = 0x0030;
+ hdev->le_conn_min_interval = 0x0028;
+ hdev->le_conn_max_interval = 0x0038;
mutex_init(&hdev->lock);
mutex_init(&hdev->req_lock);
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 2/3] Bluetooth: Add support for setting DUT mode
From: Marcel Holtmann @ 2013-10-19 14:09 UTC (permalink / raw)
To: linux-bluetooth
The Device Under Test (DUT) mode is useful for doing certification
testing and so expose this as debugfs option.
This mode is actually special since you can only enter it. Restoring
normal operation means that a HCI Reset is required. The current mode
value gets tracked as a new device flag and when disabling it, the
correct command to reset the controller is sent.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 3 ++
net/bluetooth/hci_core.c | 73 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ac9c4a7..1784c48 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -115,6 +115,7 @@ enum {
HCI_PAIRABLE,
HCI_SERVICE_CACHE,
HCI_DEBUG_KEYS,
+ HCI_DUT_MODE,
HCI_UNREGISTER,
HCI_USER_CHANNEL,
@@ -1043,6 +1044,8 @@ struct hci_rp_write_remote_amp_assoc {
__u8 phy_handle;
} __packed;
+#define HCI_OP_ENABLE_DUT_MODE 0x1803
+
#define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
#define HCI_OP_LE_SET_EVENT_MASK 0x2001
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2a9e925..4a5e567 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -58,6 +58,71 @@ static void hci_notify(struct hci_dev *hdev, int event)
/* ---- HCI debugfs entries ---- */
+static ssize_t dut_mode_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct hci_dev *hdev = file->private_data;
+ char buf[3];
+
+ buf[0] = test_bit(HCI_DUT_MODE, &hdev->dev_flags) ? 'Y': 'N';
+ buf[1] = '\n';
+ buf[2] = '\0';
+ return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct hci_dev *hdev = file->private_data;
+ struct sk_buff *skb;
+ char buf[32];
+ size_t buf_size = min(count, (sizeof(buf)-1));
+ bool enable;
+ int err;
+
+ if (!test_bit(HCI_UP, &hdev->flags))
+ return -ENETDOWN;
+
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+
+ buf[buf_size] = '\0';
+ if (strtobool(buf, &enable))
+ return -EINVAL;
+
+ if (enable == test_bit(HCI_DUT_MODE, &hdev->dev_flags))
+ return -EALREADY;
+
+ hci_req_lock(hdev);
+ if (enable)
+ skb = __hci_cmd_sync(hdev, HCI_OP_ENABLE_DUT_MODE, 0, NULL,
+ HCI_CMD_TIMEOUT);
+ else
+ skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
+ HCI_CMD_TIMEOUT);
+ hci_req_unlock(hdev);
+
+ if (IS_ERR(skb))
+ return PTR_ERR(skb);
+
+ err = -bt_to_errno(skb->data[0]);
+ kfree_skb(skb);
+
+ if (err < 0)
+ return err;
+
+ change_bit(HCI_DUT_MODE, &hdev->dev_flags);
+
+ return count;
+}
+
+static const struct file_operations dut_mode_fops = {
+ .open = simple_open,
+ .read = dut_mode_read,
+ .write = dut_mode_write,
+ .llseek = default_llseek,
+};
+
static int features_show(struct seq_file *f, void *ptr)
{
struct hci_dev *hdev = f->private;
@@ -1200,6 +1265,14 @@ static int __hci_init(struct hci_dev *hdev)
if (err < 0)
return err;
+ /* The Device Under Test (DUT) mode is special and available for
+ * all controller types. So just create it early on.
+ */
+ if (test_bit(HCI_SETUP, &hdev->dev_flags)) {
+ debugfs_create_file("dut_mode", 0644, hdev->debugfs, hdev,
+ &dut_mode_fops);
+ }
+
/* HCI_BREDR covers both single-mode LE, BR/EDR and dual-mode
* BR/EDR/LE type controllers. AMP controllers only need the
* first stage init.
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 1/3] Bluetooth: Add support for setting SSP debug mode
From: Marcel Holtmann @ 2013-10-19 14:09 UTC (permalink / raw)
To: linux-bluetooth
Enabling and disabling SSP debug mode is useful for development. This
adds a debugfs entry that allows to configure the SSP debug mode.
On purpose this has been implemented as debugfs entry and not a public
API since it is really only useful during testing and development.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 2 ++
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 54 +++++++++++++++++++++++++++++++++++++++-
net/bluetooth/hci_event.c | 2 ++
4 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 77a971a..ac9c4a7 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1043,6 +1043,8 @@ struct hci_rp_write_remote_amp_assoc {
__u8 phy_handle;
} __packed;
+#define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
+
#define HCI_OP_LE_SET_EVENT_MASK 0x2001
struct hci_cp_le_set_event_mask {
__u8 mask[8];
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c689bcf..d50cc7a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -169,6 +169,7 @@ struct hci_dev {
__u8 page_scan_type;
__u16 le_scan_interval;
__u16 le_scan_window;
+ __u8 ssp_debug_mode;
__u16 devid_source;
__u16 devid_vendor;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 384b9db..2a9e925 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -303,6 +303,55 @@ static int auto_accept_delay_get(void *data, u64 *val)
DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
auto_accept_delay_set, "%llu\n");
+static int ssp_debug_mode_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+ struct sk_buff *skb;
+ __u8 mode;
+ int err;
+
+ if (val != 0 && val != 1)
+ return -EINVAL;
+
+ if (!test_bit(HCI_UP, &hdev->flags))
+ return -ENETDOWN;
+
+ hci_req_lock(hdev);
+ mode = val;
+ skb = __hci_cmd_sync(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, sizeof(mode),
+ &mode, HCI_CMD_TIMEOUT);
+ hci_req_unlock(hdev);
+
+ if (IS_ERR(skb))
+ return PTR_ERR(skb);
+
+ err = -bt_to_errno(skb->data[0]);
+ kfree_skb(skb);
+
+ if (err < 0)
+ return err;
+
+ hci_dev_lock(hdev);
+ hdev->ssp_debug_mode = val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int ssp_debug_mode_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->ssp_debug_mode;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(ssp_debug_mode_fops, ssp_debug_mode_get,
+ ssp_debug_mode_set, "%llu\n");
+
static int idle_timeout_set(void *data, u64 val)
{
struct hci_dev *hdev = data;
@@ -1199,9 +1248,12 @@ static int __hci_init(struct hci_dev *hdev)
hdev, &voice_setting_fops);
}
- if (lmp_ssp_capable(hdev))
+ if (lmp_ssp_capable(hdev)) {
debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
hdev, &auto_accept_delay_fops);
+ debugfs_create_file("ssp_debug_mode", 0644, hdev->debugfs,
+ hdev, &ssp_debug_mode_fops);
+ }
if (lmp_sniff_capable(hdev)) {
debugfs_create_file("idle_timeout", 0644, hdev->debugfs,
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1214d4b..5935f74 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -198,6 +198,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data));
hdev->scan_rsp_data_len = 0;
+
+ hdev->ssp_debug_mode = 0;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
--
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