From 1afbe0770c3280ac8f4514896666ad4dd50e1792 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Fri, 22 Jan 2021 18:25:48 +0530 Subject: [PATCH] Bluetooth: controller: Fix accept scan en/disable if already en/disabled Conform to Bluetooth Specification, if the LE_Scan_Enable parameter is set to 0x01 and scanning is already enabled, any change to the Filter_Duplicates setting shall take effect. Disabling scanning when it is disabled has no effect. Fixes #31019. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/Kconfig.ll_sw_split | 7 +++++++ subsys/bluetooth/controller/hci/hci.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index 0a1aad05d82..27f26ac64de 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -201,6 +201,13 @@ config BT_CTLR_SCAN_SYNC_ISO_SET help Maximum supported broadcast isochronous groups (BIGs) sync sets. +config BT_CTLR_SCAN_ENABLE_STRICT + bool "Enforce Strict Scan Enable/Disable" + depends on BT_OBSERVER + help + Enforce returning HCI Error Command Disallowed on enabling/disabling + already enabled/disabled scanning. + config BT_CTLR_ZLI bool "Use Zero Latency IRQs" depends on ZERO_LATENCY_IRQS diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 66a3534bf24..a82bb877ab9 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -1502,6 +1502,11 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt) status = ll_scan_enable(cmd->enable); #endif /* !CONFIG_BT_CTLR_ADV_EXT */ + if (!IS_ENABLED(CONFIG_BT_CTLR_SCAN_ENABLE_STRICT) && + (status == BT_HCI_ERR_CMD_DISALLOWED)) { + status = BT_HCI_ERR_SUCCESS; + } + *evt = cmd_complete_status(status); } @@ -2973,6 +2978,11 @@ static void le_set_ext_scan_enable(struct net_buf *buf, struct net_buf **evt) status = ll_scan_enable(cmd->enable, cmd->duration, cmd->period); + if (!IS_ENABLED(CONFIG_BT_CTLR_SCAN_ENABLE_STRICT) && + (status == BT_HCI_ERR_CMD_DISALLOWED)) { + status = BT_HCI_ERR_SUCCESS; + } + *evt = cmd_complete_status(status); }