Re: [PATCH 4/4] android/gatt: Use proper identity address for auto connect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jakub,

On Thu, Nov 6, 2014 at 11:30 AM, Jakub Tyszkowski
<jakub.tyszkowski@xxxxxxxxx> wrote:
> We should behave the same as whe nwe connect using active scan.
> ---
>  android/gatt.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 47dadc2..8cc7536 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -583,8 +583,24 @@ static void device_set_state(struct gatt_device *dev, uint32_t state)
>  static bool auto_connect_le(struct gatt_device *dev)
>  {
>         /*  For LE devices use auto connect feature if possible */
> -       if (bt_kernel_conn_control())
> -               return  bt_auto_connect_add(&dev->bdaddr);
> +       if (bt_kernel_conn_control()) {
> +               const bdaddr_t *bdaddr;
> +
> +               /*
> +                * If address type is random it might be that IRK was received
> +                * and random is just for faking Android Framework. ID address
> +                * should be used for connection if present.
> +                */
> +               if (dev->bdaddr_type == BDADDR_LE_RANDOM) {
> +                       bdaddr = bt_get_id_addr(&dev->bdaddr, NULL);
> +                       if (!bdaddr)
> +                               return -EINVAL;
> +               } else {
> +                       bdaddr = &dev->bdaddr;
> +               }
> +
> +               return bt_auto_connect_add(bdaddr);
> +       }
>
>         /* Trigger discovery if not already started */
>         if (!scanning) {
> --
> 1.9.1

Perhaps this would be better done inside bt_auto_connect_add since
anyway bt_get_id_addr is in bluetooth.c, actually perhaps
auto_connect_le is not really necessary since bt_auto_connect_add
should be able to do the checks done here.



-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux