Bluetooth: Update device name on remote_name_event
authorSudha Bheemanna <b.sudha@samsung.com>
Thu, 25 Aug 2016 04:47:19 +0000 (10:17 +0530)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 3 Aug 2023 08:43:13 +0000 (17:43 +0900)
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 <b.sudha@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt_tizen.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 008b609..6afb511 100644 (file)
@@ -1945,6 +1945,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
 
 u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
index 46f652b..102faf0 100644 (file)
@@ -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 {
index f47ecc0..7659a6d 100644 (file)
@@ -2141,15 +2141,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, 0, 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;
index 299233d..6c3a0b8 100644 (file)
@@ -8312,6 +8312,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, u8 status,
                                             u16 opcode, struct sk_buff *skb)
 {