diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2011-03-30 16:57:16 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-04 17:47:06 -0400 |
commit | e17acd40f6006d0a0e0b1b3f7359ba4d543011c6 (patch) | |
tree | b46e79738c7d54d2e05d14ca81305526d3828eb3 /net/bluetooth | |
parent | 1e429f3842b5c9b5967a250f4daf78f92436268c (diff) |
Bluetooth: Add mgmt_device_found event
This patch adds a device_found event to the Management interface. For
now the event only maps to BR/EDR inquiry result HCI events, but in the
future the plan is to also use it for the LE device discovery process.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_event.c | 22 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 17 |
2 files changed, 31 insertions, 8 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 833797e9654b..d04011c06be0 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1228,7 +1228,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * | |||
1228 | 1228 | ||
1229 | hci_dev_lock(hdev); | 1229 | hci_dev_lock(hdev); |
1230 | 1230 | ||
1231 | for (; num_rsp; num_rsp--) { | 1231 | for (; num_rsp; num_rsp--, info++) { |
1232 | bacpy(&data.bdaddr, &info->bdaddr); | 1232 | bacpy(&data.bdaddr, &info->bdaddr); |
1233 | data.pscan_rep_mode = info->pscan_rep_mode; | 1233 | data.pscan_rep_mode = info->pscan_rep_mode; |
1234 | data.pscan_period_mode = info->pscan_period_mode; | 1234 | data.pscan_period_mode = info->pscan_period_mode; |
@@ -1237,8 +1237,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * | |||
1237 | data.clock_offset = info->clock_offset; | 1237 | data.clock_offset = info->clock_offset; |
1238 | data.rssi = 0x00; | 1238 | data.rssi = 0x00; |
1239 | data.ssp_mode = 0x00; | 1239 | data.ssp_mode = 0x00; |
1240 | info++; | ||
1241 | hci_inquiry_cache_update(hdev, &data); | 1240 | hci_inquiry_cache_update(hdev, &data); |
1241 | mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 0, | ||
1242 | NULL); | ||
1242 | } | 1243 | } |
1243 | 1244 | ||
1244 | hci_dev_unlock(hdev); | 1245 | hci_dev_unlock(hdev); |
@@ -2158,7 +2159,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2158 | struct inquiry_info_with_rssi_and_pscan_mode *info; | 2159 | struct inquiry_info_with_rssi_and_pscan_mode *info; |
2159 | info = (void *) (skb->data + 1); | 2160 | info = (void *) (skb->data + 1); |
2160 | 2161 | ||
2161 | for (; num_rsp; num_rsp--) { | 2162 | for (; num_rsp; num_rsp--, info++) { |
2162 | bacpy(&data.bdaddr, &info->bdaddr); | 2163 | bacpy(&data.bdaddr, &info->bdaddr); |
2163 | data.pscan_rep_mode = info->pscan_rep_mode; | 2164 | data.pscan_rep_mode = info->pscan_rep_mode; |
2164 | data.pscan_period_mode = info->pscan_period_mode; | 2165 | data.pscan_period_mode = info->pscan_period_mode; |
@@ -2167,13 +2168,15 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2167 | data.clock_offset = info->clock_offset; | 2168 | data.clock_offset = info->clock_offset; |
2168 | data.rssi = info->rssi; | 2169 | data.rssi = info->rssi; |
2169 | data.ssp_mode = 0x00; | 2170 | data.ssp_mode = 0x00; |
2170 | info++; | ||
2171 | hci_inquiry_cache_update(hdev, &data); | 2171 | hci_inquiry_cache_update(hdev, &data); |
2172 | mgmt_device_found(hdev->id, &info->bdaddr, | ||
2173 | info->dev_class, info->rssi, | ||
2174 | NULL); | ||
2172 | } | 2175 | } |
2173 | } else { | 2176 | } else { |
2174 | struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); | 2177 | struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); |
2175 | 2178 | ||
2176 | for (; num_rsp; num_rsp--) { | 2179 | for (; num_rsp; num_rsp--, info++) { |
2177 | bacpy(&data.bdaddr, &info->bdaddr); | 2180 | bacpy(&data.bdaddr, &info->bdaddr); |
2178 | data.pscan_rep_mode = info->pscan_rep_mode; | 2181 | data.pscan_rep_mode = info->pscan_rep_mode; |
2179 | data.pscan_period_mode = info->pscan_period_mode; | 2182 | data.pscan_period_mode = info->pscan_period_mode; |
@@ -2182,8 +2185,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2182 | data.clock_offset = info->clock_offset; | 2185 | data.clock_offset = info->clock_offset; |
2183 | data.rssi = info->rssi; | 2186 | data.rssi = info->rssi; |
2184 | data.ssp_mode = 0x00; | 2187 | data.ssp_mode = 0x00; |
2185 | info++; | ||
2186 | hci_inquiry_cache_update(hdev, &data); | 2188 | hci_inquiry_cache_update(hdev, &data); |
2189 | mgmt_device_found(hdev->id, &info->bdaddr, | ||
2190 | info->dev_class, info->rssi, | ||
2191 | NULL); | ||
2187 | } | 2192 | } |
2188 | } | 2193 | } |
2189 | 2194 | ||
@@ -2314,7 +2319,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct | |||
2314 | 2319 | ||
2315 | hci_dev_lock(hdev); | 2320 | hci_dev_lock(hdev); |
2316 | 2321 | ||
2317 | for (; num_rsp; num_rsp--) { | 2322 | for (; num_rsp; num_rsp--, info++) { |
2318 | bacpy(&data.bdaddr, &info->bdaddr); | 2323 | bacpy(&data.bdaddr, &info->bdaddr); |
2319 | data.pscan_rep_mode = info->pscan_rep_mode; | 2324 | data.pscan_rep_mode = info->pscan_rep_mode; |
2320 | data.pscan_period_mode = info->pscan_period_mode; | 2325 | data.pscan_period_mode = info->pscan_period_mode; |
@@ -2323,8 +2328,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct | |||
2323 | data.clock_offset = info->clock_offset; | 2328 | data.clock_offset = info->clock_offset; |
2324 | data.rssi = info->rssi; | 2329 | data.rssi = info->rssi; |
2325 | data.ssp_mode = 0x01; | 2330 | data.ssp_mode = 0x01; |
2326 | info++; | ||
2327 | hci_inquiry_cache_update(hdev, &data); | 2331 | hci_inquiry_cache_update(hdev, &data); |
2332 | mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, | ||
2333 | info->rssi, info->data); | ||
2328 | } | 2334 | } |
2329 | 2335 | ||
2330 | hci_dev_unlock(hdev); | 2336 | hci_dev_unlock(hdev); |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f87691e04dca..86fb50215485 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2046,3 +2046,20 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, | |||
2046 | 2046 | ||
2047 | return err; | 2047 | return err; |
2048 | } | 2048 | } |
2049 | |||
2050 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, | ||
2051 | u8 *eir) | ||
2052 | { | ||
2053 | struct mgmt_ev_device_found ev; | ||
2054 | |||
2055 | memset(&ev, 0, sizeof(ev)); | ||
2056 | |||
2057 | bacpy(&ev.bdaddr, bdaddr); | ||
2058 | memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); | ||
2059 | ev.rssi = rssi; | ||
2060 | |||
2061 | if (eir) | ||
2062 | memcpy(ev.eir, eir, sizeof(ev.eir)); | ||
2063 | |||
2064 | return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL); | ||
2065 | } | ||