Fix : LE connection interval is not updated 76/215876/1
authorinjun.yang <injun.yang@samsung.com>
Thu, 17 Oct 2019 05:23:40 +0000 (14:23 +0900)
committerinjun.yang <injun.yang@samsung.com>
Thu, 17 Oct 2019 05:23:40 +0000 (14:23 +0900)
[Problem] Unable to update LE connection interval with iPhone
[Cause & Measure] When LE connection updated callback invoked,
 bluez handle it as IDA object instead of first RPA object.
 so change the comparison logic to get RPA object
[Checking Method] Both BLE and BREDR connectd with iPhone > Repeat interval configuration

Change-Id: I87578681fc35041801e28a251a914e9bb52ff49d

src/adapter.c
src/device.c
src/device.h

index 8e9da5f..20f2eb1 100644 (file)
@@ -11977,7 +11977,7 @@ static void le_conn_update_completed_callback(uint16_t index, uint16_t length,
        struct btd_adapter *adapter = user_data;
        struct btd_device *device;
        char addr[18];
-       GSList *list;
+       GSList *list = NULL;
 
        if (length < sizeof(*ev)) {
                error("Too small le conn update completed event");
@@ -11985,10 +11985,20 @@ static void le_conn_update_completed_callback(uint16_t index, uint16_t length,
        }
 
        ba2str(&ev->addr.bdaddr, addr);
-       list = g_slist_find_custom(adapter->devices, addr,
+       if (ev->addr.type == BDADDR_LE_PUBLIC) {
+               /* LE Public or Private Random Address */
+               list = g_slist_find_custom(adapter->devices, addr,
+                                               device_rpa_ida_cmp);
+       } else if (ev->addr.type == BDADDR_LE_RANDOM) {
+               /* Static Random address */
+               list = g_slist_find_custom(adapter->devices, addr,
                                                        device_address_cmp);
+       }
+
        if (list) {
                device = list->data;
+               device_print_addr(device);
+
                if (device_get_conn_update_state(device))
                        device_set_conn_update_state(device, false);
        }
index adc2710..7705f57 100644 (file)
@@ -6227,6 +6227,19 @@ int device_addr_cmp(gconstpointer a, gconstpointer b)
 
        return bacmp(&device->bdaddr, bdaddr);
 }
+
+int device_rpa_ida_cmp(gconstpointer a, gconstpointer b)
+{
+       const struct btd_device *device = a;
+       const char *address = b;
+       char addr[18];
+
+       if (!device->rpa || device->le == false)
+               return -1;
+
+       ba2str(&device->bdaddr, addr);
+       return strcasecmp(addr, address);
+}
 #endif
 
 int device_address_cmp(gconstpointer a, gconstpointer b)
index e642e6d..5cd7148 100644 (file)
@@ -113,6 +113,7 @@ const bdaddr_t *device_get_rpa(struct btd_device *device);
 bool device_get_rpa_exist(struct btd_device *device);
 int device_rpa_cmp(gconstpointer a, gconstpointer b);
 int device_addr_cmp(gconstpointer a, gconstpointer b);
+int device_rpa_ida_cmp(gconstpointer a, gconstpointer b);
 void device_remove_stored_folder(struct btd_device *device);
 const uint8_t *device_get_irk_value(struct btd_device *device);
 void device_set_irk_value(struct btd_device *device, const uint8_t *val);