Bluetooth: Add le_scan_restart work for LE scan restarting
Subsystems (2)
PATCH v12 1/2 Bluetooth: Add le_scan_restart work for LE scan restarting
Currently there is no way to restart le scan, and it's needed in service scan method. The way it work: it disable, and then enable le scan on controller.
During the restart, we must remember when the scan was started, and it's duration, to later re-schedule the le_scan_disable work, that was stopped during the stop scan phase.
--- include/net/bluetooth/hci_core.h | 5 +++ net/bluetooth/hci_core.c | 74 ++++++++++++++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 18 +++++++++- 3 files changed, 96 insertions(+), 1 deletion(-)
include/net/bluetooth/hci_core.h +5 -0
@@ -79,6 +79,8 @@ struct discovery_state {s8 rssi;u16 uuid_count;u8 (*uuids)[16 ]; +unsigned long scan_start; +unsigned long scan_duration; };struct hci_conn_hash {
@@ -354,6 +356,7 @@ struct hci_dev {unsigned long dev_flags;struct delayed_work le_scan_disable; +struct delayed_work le_scan_restart;__s8 adv_tx_power;__u8 adv_data[HCI_MAX_AD_LENGTH ];
@@ -531,6 +534,8 @@ static inline void hci_discovery_filter_clear(struct hci_dev *hdev) hdev->discovery.uuid_count =0 ;kfree (hdev->discovery.uuids); hdev->discovery.uuids =NULL ; + hdev->discovery.scan_start =0 ; + hdev->discovery.scan_duration =0 ; }bool hci_discovery_active (struct hci_dev *hdev);
net/bluetooth/hci_core.c +74 -0
104 lines not on this page · raw message
net/bluetooth/mgmt.c +17 -1
@@ -3896,6 +3896,9 @@ static void start_discovery_complete(struct hci_dev *hdev, u8 status,hci_discovery_set_state (hdev,DISCOVERY_FINDING ); +/* If the scan involves LE scan, pick proper timeout to shedule +* hdev->le_scan_disable that will stop it. +*/ switch (hdev->discovery.type) {case DISCOV_TYPE_LE : timeout =msecs_to_jiffies (DISCOV_LE_TIMEOUT );
@@ -3912,9 +3915,22 @@ static void start_discovery_complete(struct hci_dev *hdev, u8 status,break ; } -if (timeout) +if (timeout) { +if (test_bit (HCI_QUIRK_STRICT_DUPLICATE_FILTER , + &hdev->quirks) && + (hdev->discovery.uuid_count >0 || + hdev->discovery.rssi !=HCI_RSSI_INVALID )) { +/* We mignt need to restart filtered scan. Remember when +* it was started and it's duration, so we might queue +* hdev->le_scan_disable again after the restart. +*/ + hdev->discovery.scan_start = jiffies; + hdev->discovery.scan_duration = timeout; + } +queue_delayed_work (hdev->workqueue, &hdev->le_scan_disable, timeout); + } unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v12 2/2 Bluetooth: Add restarting to service discovery
When using LE_SCAN_FILTER_DUP_ENABLE, some controllers would send advertising report from each LE device only once. That means that we don't get any updates on RSSI value, and makes Service Discovery very slow. This patch adds restarting scan when in Service Discovery, and device with filtered uuid is found, but it's not in RSSI range to send event yet. This way if device moves into range, we will quickly get RSSI update.
--- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 5 deletions(-)
include/net/bluetooth/hci_core.h +1 -0
@@ -1334,6 +1334,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);#define DISCOV_INTERLEAVED_TIMEOUT 5120/* msec */ #define DISCOV_INTERLEAVED_INQUIRY_LEN 0x04#define DISCOV_BREDR_INQUIRY_LEN 0x08 +#define DISCOV_LE_RESTART_DELAY msecs_to_jiffies(200)/* msec */ int mgmt_control (struct sock *sk,struct msghdr *msg,size_t len);int mgmt_new_settings (struct hci_dev *hdev);
net/bluetooth/mgmt.c +48 -5
92 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Marcel Holtmann
maintainerRe: [PATCH v12 2/2] Bluetooth: Add restarting to service discovery
Hi Jakub,
Quoted 8 lines
When using
LE_SCAN_FILTER_DUP_ENABLE, some controllers would send advertising report from each LE device only once. That means that we don't get any updates on RSSI value, and makes Service Discovery very slow. This patch adds restarting scan when in Service Discovery, and device with filtered uuid is found, but it's not in RSSI range to send event yet. This way if device moves into range, we will quickly get RSSI update.
Quoted 5 lines
Signed-off-by Jakub Pawlowski <[email protected]>---
include/net/bluetooth/hci_core.h| 1 +net/bluetooth/mgmt.c| 53 ++++++++++++++++++++++++++++++++++++----2 files changed, 49 insertions(+), 5 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerHi Jakub,
Quoted 8 lines
Currently there is no way to restart le scan, and it's needed in service scan method. The way it work: it disable, and then enable le scan on controller.
During the restart, we must remember when the scan was started, and it's duration, to later re-schedule the
le_scan_disablework, that was stopped during the stop scan phase.
Quoted 6 lines
Signed-off-by Jakub Pawlowski <[email protected]>---
include/net/bluetooth/hci_core.h | 5 +++ net/bluetooth/hci_core.c | 74 ++++++++++++++++++++++++++++++++++++++++ net/bluetooth/mgmt.c | 18 +++++++++- 3 files changed, 96 insertions(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
However I did a few spelling fixes in the comments and enforced the line breaks a bit harder to make it more readable.
Regards
Marcel