From f886fd6851474d9cfc5f0bdf679d2463bc87111f Mon Sep 17 00:00:00 2001 From: Sudha Bheemanna Date: Thu, 8 Sep 2016 10:31:17 +0530 Subject: [PATCH] Bluetooth: Add multiple LE advertise state change event This patch adds code for providing multiple LE advertisement state changed event to upper layer. Change-Id: I58fb8044e74402376ec30b121081edce7c8709d1 Signed-off-by: Sudha Bheemanna [divide hci_vendor_mutli_adv_state_change_evt and remove hci event structure from mgmt] Signed-off-by: Seung-Woo Kim --- include/net/bluetooth/hci.h | 7 +++++++ include/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt_tizen.h | 9 +++++++++ net/bluetooth/hci_event.c | 16 ++++++++++++++++ net/bluetooth/mgmt.c | 17 +++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 3f69599..9bc429e 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1910,6 +1910,13 @@ struct hci_ev_vendor_specific_rssi_alert { __s8 alert_type; __s8 rssi_dbm; } __packed; + +#define LE_MULTI_ADV_STATE_CHANGE_SUB_EVENT 0x55 +struct hci_ev_vendor_specific_multi_adv_state { + __u8 adv_instance; + __u8 state_change_reason; + __le16 connection_handle; +} __packed; #endif #define HCI_EV_LE_CONN_COMPLETE 0x01 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c6425b5..dfb2d91 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1521,6 +1521,8 @@ void mgmt_tx_timeout_error(struct hci_dev *hdev); 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); +void mgmt_multi_adv_state_change_evt(struct hci_dev *hdev, u8 adv_instance, + u8 state_change_reason, u16 connection_handle); #endif u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, diff --git a/include/net/bluetooth/mgmt_tizen.h b/include/net/bluetooth/mgmt_tizen.h index a46003f..e1eb50f 100644 --- a/include/net/bluetooth/mgmt_tizen.h +++ b/include/net/bluetooth/mgmt_tizen.h @@ -223,4 +223,13 @@ struct mgmt_ev_le_device_found { } __packed; /* LE device found event */ +/* For LE advertisement state changed event */ +#define MGMT_EV_MULTI_ADV_STATE_CHANGED (TIZEN_EV_BASE + 0x0b) +struct mgmt_ev_vendor_specific_multi_adv_state_changed { + __u8 adv_instance; + __u8 state_change_reason; + __le16 connection_handle; +} __packed; +/* LE advertisement state changed event */ + #endif /* __MGMT_TIZEN_H */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 76c762d..c2a4451 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1485,6 +1485,18 @@ static void hci_vendor_specific_group_ext_evt(struct hci_dev *hdev, } } +static void hci_vendor_multi_adv_state_change_evt(struct hci_dev *hdev, + struct sk_buff *skb) +{ + struct hci_ev_vendor_specific_multi_adv_state *ev = (void *)skb->data; + + BT_DBG("LE_MULTI_ADV_STATE_CHANGE_SUB_EVENT"); + + mgmt_multi_adv_state_change_evt(hdev, ev->adv_instance, + ev->state_change_reason, + ev->connection_handle); +} + static void hci_vendor_specific_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_vendor_specific *ev = (void *)skb->data; @@ -1500,6 +1512,10 @@ static void hci_vendor_specific_evt(struct hci_dev *hdev, struct sk_buff *skb) hci_vendor_specific_group_ext_evt(hdev, skb); break; + case LE_MULTI_ADV_STATE_CHANGE_SUB_EVENT: + hci_vendor_multi_adv_state_change_evt(hdev, skb); + break; + default: break; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a275fbd..37b5c4a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7176,6 +7176,23 @@ void mgmt_tx_timeout_error(struct hci_dev *hdev) { mgmt_event(MGMT_EV_TX_TIMEOUT_ERROR, hdev, NULL, 0, NULL); } + +void mgmt_multi_adv_state_change_evt(struct hci_dev *hdev, u8 adv_instance, + u8 state_change_reason, u16 connection_handle) +{ + struct mgmt_ev_vendor_specific_multi_adv_state_changed mgmt_ev; + + BT_DBG("Multi adv state changed [%2.2X %2.2X %2.2X]", + adv_instance, state_change_reason, connection_handle); + + mgmt_ev.adv_instance = adv_instance; + mgmt_ev.state_change_reason = state_change_reason; + mgmt_ev.connection_handle = connection_handle; + + mgmt_event(MGMT_EV_MULTI_ADV_STATE_CHANGED, hdev, &mgmt_ev, + sizeof(struct mgmt_ev_vendor_specific_multi_adv_state_changed), + NULL); +} #endif /* TIZEN_BT */ static bool ltk_is_valid(struct mgmt_ltk_info *key) -- 2.7.4