From b353ddc1a44e1d4817e369d4a8b59a98aa3b0e7e Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 10 Oct 2022 16:18:29 +0200 Subject: [PATCH] nimble/ll: Fix enabling extended scan with no configuration Core Specification 5.3, Vol 4, Part E, 7.8.65: "If Enable is set to 0x01 and the Host has not issued the HCI_LE_Set_Extended_Scan_Parameters command, the Controller shall either use vendor-specified parameters or return the error code Command Disallowed (0x0C)" To keep things simple we just reject in such case. This was affecting HCI/DDI/BV-06-C qualification test case. --- nimble/controller/src/ble_ll_scan.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c index a0afbdcc2..587ae6b2d 100644 --- a/nimble/controller/src/ble_ll_scan.c +++ b/nimble/controller/src/ble_ll_scan.c @@ -2314,6 +2314,27 @@ ble_ll_scan_set_enable(uint8_t enable, uint8_t filter_dups, uint16_t period, scansm = &g_ble_ll_scan_sm; #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) + if (ext) { + /* + * If Enable is set to 0x01 and the Host has not issued the + * HCI_LE_Set_Extended_Scan_Parameters command, the Controller shall + * either use vendor-specified parameters or return the error code + * Command Disallowed (0x0C) + * + * To keep things simple for devices without public address we + * reject in such case. + */ + for (i = 0; i < BLE_LL_SCAN_PHY_NUMBER; i++) { + if (g_ble_ll_scan_params.scan_phys[i].configured) { + break; + } + } + + if (i == BLE_LL_SCAN_PHY_NUMBER) { + return BLE_ERR_CMD_DISALLOWED; + } + } + /* we can do that here since value will never change until reset */ scansm->ext_scanning = ext;