From a2ee111aa0b92885137aaa37181f3f9060da6016 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 15 Nov 2016 13:55:31 +0100 Subject: [PATCH] Bluetooth: Fix address type use for passive scanning This fix using incorrect address type for passive scanning with privacy enabled. Controller was not reporting directed advertising to RPA address due to public type being used for passive scan. This was affecting TC_CONN_GCEP_BV_01_C, TC_CONN_ACEP_BV_01_C and TC_CONN_DCEP_BV_01_C qualification test cases. Jira: ZEP-1200 Change-Id: Icc316441fcac1a72d75f9ade27a99030efc846b9 Signed-off-by: Szymon Janc --- subsys/bluetooth/host/hci_core.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index ed445ae25ca..bb1e329f6f8 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -2466,14 +2466,18 @@ static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window, set_param->window = sys_cpu_to_le16(window); set_param->filter_policy = 0x00; - if (scan_type == BT_HCI_LE_SCAN_ACTIVE) { #if defined(CONFIG_BLUETOOTH_PRIVACY) - err = le_set_rpa(); - if (err) { - net_buf_unref(buf); - return err; - } + err = le_set_rpa(); + if (err) { + net_buf_unref(buf); + return err; + } + + set_param->addr_type = BT_ADDR_LE_RANDOM; #else + set_param->addr_type = bt_dev.id_addr.type; + + if (scan_type == BT_HCI_LE_SCAN_ACTIVE) { /* only set NRPA if there is no advertising ongoing */ if (!atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) { err = le_set_nrpa(); @@ -2481,13 +2485,11 @@ static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window, net_buf_unref(buf); return err; } - } -#endif - set_param->addr_type = BT_ADDR_LE_RANDOM; - } else { - set_param->addr_type = BT_ADDR_LE_PUBLIC; + set_param->addr_type = BT_ADDR_LE_RANDOM; + } } +#endif bt_hci_cmd_send(BT_HCI_OP_LE_SET_SCAN_PARAMS, buf); buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_SCAN_ENABLE,