aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-12-05 07:03:35 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-12-05 07:14:28 -0500
commitda25cf6a9869cff52b4fd189fdcd322ad2daf023 (patch)
tree87fa00769125e8ee332b6346f24786bb4d6eb73a
parentefb2513fd6278d97d2114ab87f019f4fed01c037 (diff)
Bluetooth: Report invalid RSSI for service discovery and background scan
When using Start Service Discovery and when background scanning is used to report devices, the RSSI is reported or the value 127 is provided in case RSSI in unavailable. For Start Discovery the value 0 is reported to keep backwards compatibility with the existing users. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--include/net/bluetooth/hci_core.h3
-rw-r--r--net/bluetooth/mgmt.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f07b1450b3c2..3c7827005c25 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -75,6 +75,7 @@ struct discovery_state {
75 u32 last_adv_flags; 75 u32 last_adv_flags;
76 u8 last_adv_data[HCI_MAX_AD_LENGTH]; 76 u8 last_adv_data[HCI_MAX_AD_LENGTH];
77 u8 last_adv_data_len; 77 u8 last_adv_data_len;
78 bool report_invalid_rssi;
78 s8 rssi; 79 s8 rssi;
79 u16 uuid_count; 80 u16 uuid_count;
80 u8 (*uuids)[16]; 81 u8 (*uuids)[16];
@@ -506,11 +507,13 @@ static inline void discovery_init(struct hci_dev *hdev)
506 INIT_LIST_HEAD(&hdev->discovery.all); 507 INIT_LIST_HEAD(&hdev->discovery.all);
507 INIT_LIST_HEAD(&hdev->discovery.unknown); 508 INIT_LIST_HEAD(&hdev->discovery.unknown);
508 INIT_LIST_HEAD(&hdev->discovery.resolve); 509 INIT_LIST_HEAD(&hdev->discovery.resolve);
510 hdev->discovery.report_invalid_rssi = true;
509 hdev->discovery.rssi = HCI_RSSI_INVALID; 511 hdev->discovery.rssi = HCI_RSSI_INVALID;
510} 512}
511 513
512static inline void hci_discovery_filter_clear(struct hci_dev *hdev) 514static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
513{ 515{
516 hdev->discovery.report_invalid_rssi = true;
514 hdev->discovery.rssi = HCI_RSSI_INVALID; 517 hdev->discovery.rssi = HCI_RSSI_INVALID;
515 hdev->discovery.uuid_count = 0; 518 hdev->discovery.uuid_count = 0;
516 kfree(hdev->discovery.uuids); 519 kfree(hdev->discovery.uuids);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 3ca2818d1c8b..a91e484886fe 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3912,6 +3912,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3912 hci_discovery_filter_clear(hdev); 3912 hci_discovery_filter_clear(hdev);
3913 3913
3914 hdev->discovery.type = cp->type; 3914 hdev->discovery.type = cp->type;
3915 hdev->discovery.report_invalid_rssi = false;
3915 3916
3916 hci_req_init(&req, hdev); 3917 hci_req_init(&req, hdev);
3917 3918
@@ -7022,8 +7023,15 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
7022 7023
7023 memset(buf, 0, sizeof(buf)); 7024 memset(buf, 0, sizeof(buf));
7024 7025
7025 /* Reset invalid RSSI to 0 to keep backwards API compliance */ 7026 /* In case of device discovery with BR/EDR devices (pre 1.2), the
7026 if (rssi == HCI_RSSI_INVALID) 7027 * RSSI value was reported as 0 when not available. This behavior
7028 * is kept when using device discovery. This is required for full
7029 * backwards compatibility with the API.
7030 *
7031 * However when using service discovery, the value 127 will be
7032 * returned when the RSSI is not available.
7033 */
7034 if (rssi == HCI_RSSI_INVALID && !hdev->discovery.report_invalid_rssi)
7027 rssi = 0; 7035 rssi = 0;
7028 7036
7029 bacpy(&ev->addr.bdaddr, bdaddr); 7037 bacpy(&ev->addr.bdaddr, bdaddr);