Re: [RFC 11/15] Bluetooth: Temporarily stop background scanning on connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andre,

> Some LE controllers don't support scanning and initiating a connection
> at the same time. So, for those controllers, we should temporarily
> stop the background scanning and start it again once the connection
> attempt is finished (successfully or not).
> 
> So this patch introduces the hci_check_background_scan() which checks
> if the background scanning should be started.
> 
> Signed-off-by: Andre Guedes <andre.guedes@xxxxxxxxxxxxx>
> ---
> include/net/bluetooth/hci_core.h |  1 +
> net/bluetooth/hci_conn.c         | 25 +++++++++++++++++++++++++
> net/bluetooth/hci_core.c         | 18 ++++++++++++++++++
> net/bluetooth/hci_event.c        |  6 ++++++
> 4 files changed, 50 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index db39eca..017decc 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1201,5 +1201,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
> 
> int hci_trigger_background_scan(struct hci_dev *hdev);
> int hci_untrigger_background_scan(struct hci_dev *hdev);
> +void hci_check_background_scan(struct hci_dev *hdev);
> 
> #endif /* __HCI_CORE_H */
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index d64000e..6ae42c2 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -541,6 +541,18 @@ static void create_le_conn_complete(struct hci_dev *hdev, u8 status)
> 
> done:
> 	hci_dev_unlock(hdev);
> +
> +	/* Check the background scanning since it may have been temporarily
> +	 * stopped if the controller doesn't support scanning and initiate
> +	 * state combination.
> +	 */
> +	hci_check_background_scan(hdev);
> +}

so what I would do first is assume the controller can not scan while being in initiating state or being connected. Make the dead simple only a single connection at a time work perfectly. Get the basic infrastructure in place.

> +
> +/* Check if controller supports scanning and initiating states combination */
> +static bool is_state_combination_supported(struct hci_dev *hdev)
> +{
> +        return (hdev->le_states[2] & BIT(6)) ? true : false;
> }
> 

Worst function name ever. Also this should use !!(hdev->le_states & x) style.

Also we need this more generic anyway. So get the simple part working for dumb controllers and we deal with the rest when that part works.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux