提交 efb2513f 编写于 作者: M Marcel Holtmann 提交者: Johan Hedberg

Bluetooth: Fix discovery filter when no RSSI is available

When no RSSI value is available then make sure that the result is
filtered out when the RSSI threshold filter is active.

This means that all Bluetooth 1.1 or earlier devices will not
report any results when using a RSSI threshold filter.
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
上级 189f6ad2
...@@ -2043,13 +2043,14 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2043,13 +2043,14 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
data.pscan_mode = info->pscan_mode; data.pscan_mode = info->pscan_mode;
memcpy(data.dev_class, info->dev_class, 3); memcpy(data.dev_class, info->dev_class, 3);
data.clock_offset = info->clock_offset; data.clock_offset = info->clock_offset;
data.rssi = 0x00; data.rssi = HCI_RSSI_INVALID;
data.ssp_mode = 0x00; data.ssp_mode = 0x00;
flags = hci_inquiry_cache_update(hdev, &data, false); flags = hci_inquiry_cache_update(hdev, &data, false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, 0, flags, NULL, 0, NULL, 0); info->dev_class, HCI_RSSI_INVALID,
flags, NULL, 0, NULL, 0);
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
......
...@@ -7006,9 +7006,12 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ...@@ -7006,9 +7006,12 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
* if such a RSSI threshold is specified. If a RSSI threshold has * if such a RSSI threshold is specified. If a RSSI threshold has
* been specified, then all results with a RSSI smaller than the * been specified, then all results with a RSSI smaller than the
* RSSI threshold will be dropped. * RSSI threshold will be dropped.
*
* For BR/EDR devices (pre 1.2) providing no RSSI during inquiry,
* the results are also dropped.
*/ */
if (hdev->discovery.rssi != HCI_RSSI_INVALID && if (hdev->discovery.rssi != HCI_RSSI_INVALID &&
rssi < hdev->discovery.rssi) (rssi < hdev->discovery.rssi || rssi == HCI_RSSI_INVALID))
return; return;
/* Make sure that the buffer is big enough. The 5 extra bytes /* Make sure that the buffer is big enough. The 5 extra bytes
...@@ -7019,6 +7022,10 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ...@@ -7019,6 +7022,10 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
/* Reset invalid RSSI to 0 to keep backwards API compliance */
if (rssi == HCI_RSSI_INVALID)
rssi = 0;
bacpy(&ev->addr.bdaddr, bdaddr); bacpy(&ev->addr.bdaddr, bdaddr);
ev->addr.type = link_to_bdaddr(link_type, addr_type); ev->addr.type = link_to_bdaddr(link_type, addr_type);
ev->rssi = rssi; ev->rssi = rssi;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册