diff options
author | Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> | 2014-05-08 09:32:08 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-05-08 11:01:57 -0400 |
commit | 5ae76a94150c86a6e0ee84eb74e7f7e1909b8d39 (patch) | |
tree | 4abcdb2d73127eabb1f6d48af20b37cb7725e69b | |
parent | 38e4a915663f3f3c03b753d90a34fbb6164ea55d (diff) |
Bluetooth: Store RSSI for connection
This patch adds support to store RSSI for connection when reply for
HCI_Read_RSSI is received.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | include/net/bluetooth/hci.h | 10 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 23 |
3 files changed, 34 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4261a67682c0..ad2ecc92380d 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -1064,6 +1064,16 @@ struct hci_rp_read_page_scan_type { | |||
1064 | #define PAGE_SCAN_TYPE_STANDARD 0x00 | 1064 | #define PAGE_SCAN_TYPE_STANDARD 0x00 |
1065 | #define PAGE_SCAN_TYPE_INTERLACED 0x01 | 1065 | #define PAGE_SCAN_TYPE_INTERLACED 0x01 |
1066 | 1066 | ||
1067 | #define HCI_OP_READ_RSSI 0x1405 | ||
1068 | struct hci_cp_read_rssi { | ||
1069 | __le16 handle; | ||
1070 | } __packed; | ||
1071 | struct hci_rp_read_rssi { | ||
1072 | __u8 status; | ||
1073 | __le16 handle; | ||
1074 | __s8 rssi; | ||
1075 | } __packed; | ||
1076 | |||
1067 | #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 | 1077 | #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 |
1068 | struct hci_rp_read_local_amp_info { | 1078 | struct hci_rp_read_local_amp_info { |
1069 | __u8 status; | 1079 | __u8 status; |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d73f41855ada..0318d5263837 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -374,6 +374,7 @@ struct hci_conn { | |||
374 | __u16 setting; | 374 | __u16 setting; |
375 | __u16 le_conn_min_interval; | 375 | __u16 le_conn_min_interval; |
376 | __u16 le_conn_max_interval; | 376 | __u16 le_conn_max_interval; |
377 | __s8 rssi; | ||
377 | unsigned long flags; | 378 | unsigned long flags; |
378 | 379 | ||
379 | __u8 remote_cap; | 380 | __u8 remote_cap; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 07c37d0cecb2..2bb0053d4c45 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1245,6 +1245,25 @@ static void hci_cc_write_remote_amp_assoc(struct hci_dev *hdev, | |||
1245 | amp_write_rem_assoc_continue(hdev, rp->phy_handle); | 1245 | amp_write_rem_assoc_continue(hdev, rp->phy_handle); |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | static void hci_cc_read_rssi(struct hci_dev *hdev, struct sk_buff *skb) | ||
1249 | { | ||
1250 | struct hci_rp_read_rssi *rp = (void *) skb->data; | ||
1251 | struct hci_conn *conn; | ||
1252 | |||
1253 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); | ||
1254 | |||
1255 | if (rp->status) | ||
1256 | return; | ||
1257 | |||
1258 | hci_dev_lock(hdev); | ||
1259 | |||
1260 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); | ||
1261 | if (conn) | ||
1262 | conn->rssi = rp->rssi; | ||
1263 | |||
1264 | hci_dev_unlock(hdev); | ||
1265 | } | ||
1266 | |||
1248 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | 1267 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) |
1249 | { | 1268 | { |
1250 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | 1269 | BT_DBG("%s status 0x%2.2x", hdev->name, status); |
@@ -2637,6 +2656,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2637 | hci_cc_write_remote_amp_assoc(hdev, skb); | 2656 | hci_cc_write_remote_amp_assoc(hdev, skb); |
2638 | break; | 2657 | break; |
2639 | 2658 | ||
2659 | case HCI_OP_READ_RSSI: | ||
2660 | hci_cc_read_rssi(hdev, skb); | ||
2661 | break; | ||
2662 | |||
2640 | default: | 2663 | default: |
2641 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2664 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2642 | break; | 2665 | break; |