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)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 12 Nov 2024 04:03:10 +0000 (13:03 +0900)
This patch updates the device name on receiving the HCI event
remote_name_event during connection establishment.

Change-Id: I9e95b53e882744c205adc86b1d00c064691fbc48
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>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt_tizen.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 8c61a2e2de1414a5a0d70e5617d04898d212b3d3..324b1386bbd03bb51a1281b7ddf35940872ca291 100644 (file)
@@ -2371,6 +2371,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);
index 46f652b069d3cac5723b4dcca4544bba0ae09335..102faf0f54789663b537d4188d44eba76f7e5af3 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 aa514ea92ae71c78a0ba5344e762e5ea2baa93a2..7a18a8755f72c9d75053b4ff71173ab3b845649e 100644 (file)
@@ -2483,13 +2483,22 @@ 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))
                mgmt_device_connected(hdev, conn, name, name_len);
+#endif
 
        if (discov->state == DISCOVERY_STOPPED)
                return;
index bbb6ab45d47eac1721d4a229373b204832359b7f..c3772ca85ff53b5442d22b08a5f809fb1c369320 100644 (file)
@@ -9157,6 +9157,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)
 {