OSDN Git Service

set HID major in class of device of inquiry result for HID over LE
authorZhihai Xu <zhihaixu@google.com>
Wed, 27 Nov 2013 02:18:29 +0000 (18:18 -0800)
committerZhihai Xu <zhihaixu@google.com>
Wed, 11 Dec 2013 19:10:09 +0000 (11:10 -0800)
need to set HID major in class of device of inquiry result for HID over LE,
if HID over LE service UUID is found in BLE advertisement data.
so we can show the HID icon in device list for HID over LE device.
16 bit UUID list in BLE advertisement data can contain multiple UUID,
need to go through the 16bit UUID list to find HID over LE service UUID.

bug:11450485
Change-Id: I7b2ee4c88485b287609eac34c35ce5e714e48280

stack/btm/btm_ble_gap.c

index 47ee8cf..bfe5fda 100644 (file)
@@ -1518,6 +1518,7 @@ BOOLEAN btm_ble_update_inq_result(tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_t
     UINT8                data_len, rssi;
     tBTM_BLE_INQ_CB     *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
     UINT8 *p1;
+    UINT8               *p_uuid16;
 
     STREAM_TO_UINT8    (data_len, p);
 
@@ -1562,6 +1563,26 @@ BOOLEAN btm_ble_update_inq_result(tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_t
             p_cur->flag = * p_flag;
     }
 
+    if (p_le_inq_cb->adv_len != 0)
+    {
+        if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
+                                         BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL)
+        {
+            UINT8 i;
+            for (i = 0; i + 2 <= len; i = i + 2)
+            {
+                /* if this BLE device support HID over LE, set HID Major in class of device */
+                if ((p_uuid16[i] | (p_uuid16[i+1] << 8)) == UUID_SERVCLASS_LE_HID)
+                {
+                    p_cur->dev_class[0] = 0;
+                    p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL;
+                    p_cur->dev_class[2] = 0;
+                    break;
+                }
+            }
+        }
+    }
+
     /* if BR/EDR not supported is not set, assume is a DUMO device */
     if ((p_cur->flag & BTM_BLE_BREDR_NOT_SPT) == 0 &&
          evt_type != BTM_BLE_CONNECT_DIR_EVT)