From 5eebc3b15e2d750c41550753572b82b37cd9a894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Wed, 7 Mar 2018 11:44:28 +0100 Subject: [PATCH] nimble/ll: Fix extended connect when using both PHYs for scanning When host is using extended connect, scan parameters is a recomendation for the controller. Nimble usually follow it but in case host requests both CODED and UNCODED PHY for primary scan PHY and choose parameters which saying "continous scan" on both PHYs, controller will split time between both PHYs. X-Original-Commit: fc457f1c0791bbc1493a01b9170b5d04d69e354a --- nimble/controller/src/ble_ll_scan.c | 35 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c index 5f7fe5929..76559ef85 100644 --- a/nimble/controller/src/ble_ll_scan.c +++ b/nimble/controller/src/ble_ll_scan.c @@ -2874,7 +2874,8 @@ ble_ll_scan_ext_initiator_start(struct hci_ext_create_conn *hcc, struct ble_ll_scan_sm **sm) { struct ble_ll_scan_sm *scansm; - struct ble_ll_scan_params *scanphy; + struct ble_ll_scan_params *uncoded; + struct ble_ll_scan_params *coded; struct hci_ext_conn_params *params; int rc; @@ -2886,23 +2887,23 @@ ble_ll_scan_ext_initiator_start(struct hci_ext_create_conn *hcc, if (hcc->init_phy_mask & BLE_PHY_MASK_1M) { params = &hcc->params[0]; - scanphy = &scansm->phy_data[PHY_UNCODED]; + uncoded = &scansm->phy_data[PHY_UNCODED]; - scanphy->scan_itvl = params->scan_itvl; - scanphy->scan_window = params->scan_window; - scanphy->scan_type = BLE_SCAN_TYPE_INITIATE; - scanphy->scan_filt_policy = hcc->filter_policy; + uncoded->scan_itvl = params->scan_itvl; + uncoded->scan_window = params->scan_window; + uncoded->scan_type = BLE_SCAN_TYPE_INITIATE; + uncoded->scan_filt_policy = hcc->filter_policy; scansm->cur_phy = PHY_UNCODED; } if (hcc->init_phy_mask & BLE_PHY_MASK_CODED) { params = &hcc->params[2]; - scanphy = &scansm->phy_data[PHY_CODED]; + coded = &scansm->phy_data[PHY_CODED]; - scanphy->scan_itvl = params->scan_itvl; - scanphy->scan_window = params->scan_window; - scanphy->scan_type = BLE_SCAN_TYPE_INITIATE; - scanphy->scan_filt_policy = hcc->filter_policy; + coded->scan_itvl = params->scan_itvl; + coded->scan_window = params->scan_window; + coded->scan_type = BLE_SCAN_TYPE_INITIATE; + coded->scan_filt_policy = hcc->filter_policy; if (scansm->cur_phy == PHY_NOT_CONFIGURED) { scansm->cur_phy = PHY_CODED; } else { @@ -2910,6 +2911,18 @@ ble_ll_scan_ext_initiator_start(struct hci_ext_create_conn *hcc, } } + /* If host request for continuous scan if 2 PHYs are requested, we split + * time on two + */ + if ((scansm->next_phy != PHY_NOT_CONFIGURED) && + ((uncoded->scan_itvl == uncoded->scan_window) || + (coded->scan_itvl == coded-> scan_window))) { + + uncoded->scan_itvl *= 2; + coded-> scan_itvl = uncoded->scan_itvl; + coded->scan_window = uncoded->scan_window; + } + rc = ble_ll_scan_sm_start(scansm); if (sm == NULL) { return rc;