Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v4 13/14] Bluetooth: Support LE-Only discovery procedure
Date: Tue, 20 Sep 2011 15:00:15 +0200	[thread overview]
Message-ID: <1316523616.1937.97.camel@aeonflux> (raw)
In-Reply-To: <1316468136-12472-14-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch adds support for LE-Only discovery procedure through
> management interface.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
>  net/bluetooth/hci_event.c |   16 +++++++++++++---
>  net/bluetooth/mgmt.c      |   13 ++++++++++++-
>  2 files changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 5bbba54..0408c50 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -889,14 +889,16 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
>  
>  	BT_DBG("%s status 0x%x", hdev->name, status);
>  
> -	if (status)
> -		return;
> -
>  	cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE);
>  	if (!cp)
>  		return;
>  
>  	if (cp->enable == 0x01) {
> +		if (status) {
> +			mgmt_discovery_complete(hdev->id, status);
> +			return;
> +		}
> +
>  		set_bit(HCI_LE_SCAN, &hdev->flags);
>  
>  		mgmt_discovering(hdev->id, 1);
> @@ -906,7 +908,15 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
>  		hci_dev_lock(hdev);
>  		hci_adv_entries_clear(hdev);
>  		hci_dev_unlock(hdev);
> +
> +		if (mgmt_has_pending_stop_discov(hdev->id))
> +			hci_cancel_le_scan(hdev);
>  	} else if (cp->enable == 0x00) {
> +		mgmt_discovery_complete(hdev->id, status);
> +
> +		if (status)
> +			return;
> +
>  		clear_bit(HCI_LE_SCAN, &hdev->flags);
>  
>  		mgmt_discovering(hdev->id, 0);
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 1eee5cc..e869422 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -32,6 +32,14 @@
>  #define MGMT_VERSION	0
>  #define MGMT_REVISION	1
>  
> +/*
> + * These LE scan and inquiry parameters were chosen according to LE General
> + * Discovery Procedure specification.
> + */
> +#define LE_SCAN_TYPE 0x01
> +#define LE_SCAN_WIN 0x12
> +#define LE_SCAN_INT 0x12
> +#define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */

And an extra empty line here to make clear these a independent values.

>  #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */
>  
>  struct pending_cmd {
> @@ -1637,7 +1645,8 @@ static int start_discovery(struct sock *sk, u16 index)
>  	if (lmp_host_le_capable(hdev) && lmp_bredr_capable(hdev))
>  		err = -ENOSYS;
>  	else if (lmp_host_le_capable(hdev))
> -		err = -ENOSYS;
> +		err = hci_do_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
> +					LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
>  	else
>  		err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
>  
> @@ -1684,6 +1693,8 @@ static int stop_discovery(struct sock *sk, u16 index)
>  
>  	if (test_bit(HCI_INQUIRY, &hdev->flags))
>  		err = hci_cancel_inquiry(hdev);
> +	else if (test_bit(HCI_LE_SCAN, &hdev->flags))
> +		err = hci_cancel_le_scan(hdev);
>  	else
>  		err = 0;
>  

I see where you wanna go with this now. I am a bit afraid of the code
complexity with the discovery stop/start/complete etc. messages.

This is all too much done differently for 3 different possible use
cases. And I just think we need more general handling. For example:

	inquiry_started()
	inquiry_result()
	inquiry_completed()
	le_scan_started()
	le_scan_result()
	le_scan_completed()

And based on the controller capabilities, the current states etc. a
central place decides to send out which events at which time and to
allow certain commands or not.

If we do not centralize this, then I am afraid we duplicate this logic
three times.

Regards

Marcel



  reply	other threads:[~2011-09-20 13:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 21:35 [PATCH v4 00/14] Discovery support Andre Guedes
2011-09-19 21:35 ` [PATCH v4 01/14] Bluetooth: Periodic Inquiry and mgmt discovering event Andre Guedes
2011-09-20 12:23   ` Marcel Holtmann
2011-09-23 19:12     ` Andre Guedes
2012-03-19 12:40     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 02/14] Bluetooth: Add mgmt_discovery_complete() Andre Guedes
2011-09-20 12:29   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 03/14] Bluetooth: Check pending command in start_discovery() Andre Guedes
2011-09-20 12:26   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 04/14] Bluetooth: Check pending commands in stop_discovery() Andre Guedes
2011-09-19 21:35 ` [PATCH v4 05/14] Bluetooth: Create hci_do_inquiry() Andre Guedes
2011-09-20 12:31   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 06/14] Bluetooth: Create hci_cancel_inquiry() Andre Guedes
2011-09-20 12:33   ` Marcel Holtmann
2011-09-19 21:35 ` [PATCH v4 07/14] Bluetooth: Handle race condition in Discovery Andre Guedes
2011-09-20 12:37   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 08/14] Bluetooth: Prepare for full support discovery procedures Andre Guedes
2011-09-20 12:43   ` Marcel Holtmann
2011-09-23 19:14     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 09/14] Bluetooth: Send mgmt_discovering events Andre Guedes
2011-09-20 12:45   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 10/14] Bluetooth: Add 'eir_len' param to mgmt_device_found() Andre Guedes
2011-09-20 12:47   ` Marcel Holtmann
2011-09-19 21:35 ` [PATCH v4 11/14] Bluetooth: Report LE devices Andre Guedes
2011-09-20 12:49   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 12/14] Bluetooth: LE scan infra-structure Andre Guedes
2011-09-20 12:53   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 13/14] Bluetooth: Support LE-Only discovery procedure Andre Guedes
2011-09-20 13:00   ` Marcel Holtmann [this message]
2011-09-23 19:16     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 14/14] Bluetooth: Support BR/EDR/LE " Andre Guedes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316523616.1937.97.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=andre.guedes@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox