From: Sudha Bheemanna Date: Thu, 25 Aug 2016 04:47:19 +0000 (+0530) Subject: Bluetooth: Update device name on remote_name_event X-Git-Tag: accepted/tizen/unified/toolchain/20240311.065846~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7880623f3a01faad46fbfa28c7cfffec3daf857e;p=platform%2Fkernel%2Flinux-starfive.git Bluetooth: Update device name on remote_name_event This patch updates the device name on receiving the HCI event remote_name_event during connection establishment. Change-Id: I9a217e6760b1803a70af201a3f6903e722079749 Signed-off-by: Sudha Bheemanna Signed-off-by: Seung-Woo Kim Signed-off-by: Amit Purwar Signed-off-by: Wootak Jung --- diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 71cea84..b65780d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -2368,6 +2368,8 @@ void mgmt_rssi_alert_evt(struct hci_dev *hdev, struct sk_buff *skb); void mgmt_raw_rssi_response(struct hci_dev *hdev, struct hci_cc_rp_get_raw_rssi *rp, int success); void mgmt_enable_rssi_cc(struct hci_dev *hdev, void *response, u8 status); +int mgmt_device_name_update(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name, + u8 name_len); #endif int hci_abort_conn(struct hci_conn *conn, u8 reason); diff --git a/include/net/bluetooth/mgmt_tizen.h b/include/net/bluetooth/mgmt_tizen.h index 46f652b..102faf0 100644 --- a/include/net/bluetooth/mgmt_tizen.h +++ b/include/net/bluetooth/mgmt_tizen.h @@ -104,6 +104,17 @@ struct mgmt_cc_rp_disable_rssi { } __packed; /* RSSI monitoring */ +/* EVENTS */ + +/* For device name update changes */ +#define MGMT_EV_DEVICE_NAME_UPDATE (TIZEN_EV_BASE + 0x01) +struct mgmt_ev_device_name_update { + struct mgmt_addr_info addr; + __le16 eir_len; + __u8 eir[0]; +} __packed; +/* Device name update changes */ + /* For handling of RSSI Events */ #define MGMT_EV_RSSI_ALERT (TIZEN_EV_BASE + 0x04) struct mgmt_ev_vendor_specific_rssi_alert { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6cd672c..6f2f46b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2549,15 +2549,25 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, struct discovery_state *discov = &hdev->discovery; struct inquiry_entry *e; +#ifdef TIZEN_BT /* Update the mgmt connected state if necessary. Be careful with * conn objects that exist but are not (yet) connected however. * Only those in BT_CONFIG or BT_CONNECTED states can be * considered connected. */ if (conn && + (conn->state == BT_CONFIG || conn->state == BT_CONNECTED)) { + if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) + mgmt_device_connected(hdev, conn, name, name_len); + else + mgmt_device_name_update(hdev, bdaddr, name, name_len); + } +#else + if (conn && (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, conn, name, name_len); +#endif if (discov->state == DISCOVERY_STOPPED) return; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a6c547a..65e6c0a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -9211,6 +9211,30 @@ unlock: return err; } +#ifdef TIZEN_BT +int mgmt_device_name_update(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name, + u8 name_len) +{ + char buf[512]; + struct mgmt_ev_device_name_update *ev = (void *)buf; + u16 eir_len = 0; + + if (name_len <= 0) + return -EINVAL; + + bacpy(&ev->addr.bdaddr, bdaddr); + ev->addr.type = BDADDR_BREDR; + + eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name, + name_len); + + ev->eir_len = cpu_to_le16(eir_len); + + return mgmt_event(MGMT_EV_DEVICE_NAME_UPDATE, hdev, buf, + sizeof(*ev) + eir_len, NULL); +} +#endif + static void read_local_oob_ext_data_complete(struct hci_dev *hdev, void *data, int err) {