Bluetooth: controller: Fix enable and disable of scan state
Updated controller implementation to disallow disabling initiator state using scan disable. But allow disabling an already disabled scan state. Also, disallow enabling scan state while in initiator state. Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl> Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
3fdedde967
commit
aa5bbd5dfe
3 changed files with 21 additions and 7 deletions
|
@ -10540,10 +10540,14 @@ u32_t radio_scan_enable(u8_t type, u8_t init_addr_type, u8_t *init_addr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
u32_t radio_scan_disable(void)
|
||||
u32_t radio_scan_disable(bool scanner)
|
||||
{
|
||||
u32_t status;
|
||||
|
||||
if (scanner && _radio.scanner.conn) {
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
status = role_disable(RADIO_TICKER_ID_SCAN,
|
||||
RADIO_TICKER_ID_SCAN_STOP);
|
||||
if (!status && !_radio.scanner.conn) {
|
||||
|
@ -10554,7 +10558,7 @@ u32_t radio_scan_disable(void)
|
|||
}
|
||||
}
|
||||
|
||||
return status ? BT_HCI_ERR_CMD_DISALLOWED : 0;
|
||||
return _radio.scanner.is_enabled ? BT_HCI_ERR_CMD_DISALLOWED : 0;
|
||||
}
|
||||
|
||||
u32_t ll_scan_is_enabled(void)
|
||||
|
@ -10745,7 +10749,7 @@ u32_t ll_connect_disable(void **node_rx)
|
|||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
status = radio_scan_disable();
|
||||
status = radio_scan_disable(false);
|
||||
if (!status) {
|
||||
struct connection *conn = _radio.scanner.conn;
|
||||
struct radio_pdu_node_rx *rx;
|
||||
|
|
|
@ -356,7 +356,7 @@ u32_t radio_adv_filter_pol_get(void);
|
|||
u32_t radio_scan_enable(u8_t type, u8_t init_addr_type, u8_t *init_addr,
|
||||
u16_t interval, u16_t window, u8_t filter_policy,
|
||||
u8_t rpa_gen, u8_t rl_idx);
|
||||
u32_t radio_scan_disable(void);
|
||||
u32_t radio_scan_disable(bool scanner);
|
||||
u32_t ll_scan_is_enabled(void);
|
||||
u32_t radio_scan_filter_pol_get(void);
|
||||
|
||||
|
|
|
@ -59,12 +59,22 @@ u32_t ll_scan_params_set(u8_t type, u16_t interval, u16_t window,
|
|||
|
||||
u32_t ll_scan_enable(u8_t enable)
|
||||
{
|
||||
u8_t rpa_gen = 0;
|
||||
u32_t status;
|
||||
u8_t rpa_gen = 0;
|
||||
u32_t scan;
|
||||
|
||||
if (!enable) {
|
||||
return radio_scan_disable();
|
||||
} else if (ll_scan_is_enabled()) {
|
||||
return radio_scan_disable(true);
|
||||
}
|
||||
|
||||
scan = ll_scan_is_enabled();
|
||||
|
||||
/* Initiator and scanning are not supported */
|
||||
if (scan & BIT(2)) {
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
if (scan) {
|
||||
/* Duplicate filtering is processed in the HCI layer */
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue