summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSudha Bheemanna <b.sudha@samsung.com>2016-09-08 10:10:03 +0530
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:53:13 +0900
commita8e0957dc0167bd23dac581f44d91d4ed62c4b0b (patch)
tree045c843b3b8c7308ff56c64909199ed2dc2bc0c3 /net
parented07651f659a019040780870fbe3ddf08e9f97bd (diff)
Bluetooth: Add LE device found MGMT event
This patch adds new MGMT event for LE device discovery and allows the handling of all advertisement packets in platform. Change-Id: I1927acb75eff0b60a5899898c6d7a000e1a108ef Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c20
-rw-r--r--net/bluetooth/mgmt.c42
2 files changed, 62 insertions, 0 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e9e832b799a3..76c762d2e296 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1147,6 +1147,7 @@ static void clear_pending_adv_report(struct hci_dev *hdev)
d->last_adv_data_len = 0;
}
+#ifndef TIZEN_BT
static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 bdaddr_type, s8 rssi, u32 flags,
u8 *data, u8 len)
@@ -1160,6 +1161,7 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
memcpy(d->last_adv_data, data, len);
d->last_adv_data_len = len;
}
+#endif
static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
struct sk_buff *skb)
@@ -4825,10 +4827,14 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
u8 bdaddr_type, bdaddr_t *direct_addr,
u8 direct_addr_type, s8 rssi, u8 *data, u8 len)
{
+#ifndef TIZEN_BT
struct discovery_state *d = &hdev->discovery;
+#endif
struct smp_irk *irk;
struct hci_conn *conn;
+#ifndef TIZEN_BT
bool match;
+#endif
u32 flags;
/* If the direct address is present, then this report is from
@@ -4882,16 +4888,24 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
if (type == LE_ADV_DIRECT_IND)
return;
+#ifndef TIZEN_BT
+ /* Handle all adv packet in platform */
if (!hci_pend_le_action_lookup(&hdev->pend_le_reports,
bdaddr, bdaddr_type))
return;
+#endif
if (type == LE_ADV_NONCONN_IND || type == LE_ADV_SCAN_IND)
flags = MGMT_DEV_FOUND_NOT_CONNECTABLE;
else
flags = 0;
+#ifdef TIZEN_BT
+ mgmt_le_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
+ rssi, flags, data, len, NULL, 0, type);
+#else
mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
rssi, flags, data, len, NULL, 0);
+#endif
return;
}
@@ -4916,6 +4930,11 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
else
flags = 0;
+#ifdef TIZEN_BT
+ /* Disable adv ind and scan rsp merging */
+ mgmt_le_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
+ rssi, flags, data, len, NULL, 0, type);
+#else
/* If there's nothing pending either store the data from this
* event or send an immediate device found event if the data
* should not be stored for later.
@@ -4978,6 +4997,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
d->last_adv_addr_type, NULL, rssi, d->last_adv_flags,
d->last_adv_data, d->last_adv_data_len, data, len);
clear_pending_adv_report(hdev);
+#endif
}
static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a14a00ce7b9b..a275fbdce670 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -8230,6 +8230,48 @@ int mgmt_le_conn_updated(struct hci_dev *hdev, bdaddr_t *bdaddr,
return mgmt_event(MGMT_EV_CONN_UPDATED, hdev,
&ev, sizeof(ev), NULL);
}
+
+/* le device found event - Pass adv type */
+void mgmt_le_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+ u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, u8 *eir,
+ u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len, u8 adv_type)
+{
+ char buf[512];
+ struct mgmt_ev_le_device_found *ev = (void *)buf;
+ size_t ev_size;
+
+ if (!hci_discovery_active(hdev) && !hci_le_discovery_active(hdev))
+ return;
+
+ /* Make sure that the buffer is big enough. The 5 extra bytes
+ * are for the potential CoD field.
+ */
+ if (sizeof(*ev) + eir_len + scan_rsp_len + 5 > sizeof(buf))
+ return;
+
+ memset(buf, 0, sizeof(buf));
+
+ bacpy(&ev->addr.bdaddr, bdaddr);
+ ev->addr.type = link_to_bdaddr(link_type, addr_type);
+ ev->rssi = rssi;
+ ev->flags = cpu_to_le32(flags);
+ ev->adv_type = adv_type;
+
+ if (eir_len > 0)
+ memcpy(ev->eir, eir, eir_len);
+
+ if (dev_class && !eir_has_data_type(ev->eir, eir_len, EIR_CLASS_OF_DEV))
+ eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
+ dev_class, 3);
+
+ if (scan_rsp_len > 0)
+ memcpy(ev->eir + eir_len, scan_rsp, scan_rsp_len);
+
+ ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
+ ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
+
+ mgmt_event(MGMT_EV_LE_DEVICE_FOUND, hdev, ev, ev_size, NULL);
+}
#endif
static void read_local_oob_ext_data_complete(struct hci_dev *hdev, u8 status,