2015-05-08 14:31:05

by Tom Harada

[permalink] [raw]
Subject: LE device automatic pairing

Hi all,

On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
BlueZ seems to be automatically pairing with LE devices as soon as it
detects their advertisements. Is this an intended feature? If so, how
can I prevent it from happening?

Thanks,
Tom


2015-05-11 15:46:15

by Tom Harada

[permalink] [raw]
Subject: Re: LE device automatic pairing

Hi Luiz,

On 05/11/15 11:16, Luiz Augusto von Dentz wrote:
> Hi Tom,
>
> On Mon, May 11, 2015 at 4:26 PM, Tom Harada <[email protected]> wrote:
>> Hi Luiz,
>>
>>
>> On 05/11/15 04:04, Luiz Augusto von Dentz wrote:
>>> Hi Tom,
>>>
>>> On Mon, May 11, 2015 at 11:03 AM, Luiz Augusto von Dentz
>>> <[email protected]> wrote:
>>>> Hi Tom,
>>>>
>>>> On Fri, May 8, 2015 at 5:31 PM, Tom Harada <[email protected]>
>>>> wrote:
>>>>> Hi all,
>>>>>
>>>>> On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
>>>>> BlueZ seems to be automatically pairing with LE devices as soon as it
>>>>> detects their advertisements. Is this an intended feature? If so, how
>>>>> can I
>>>>> prevent it from happening?
>>>> It should be pairing, bluetoothd will create objects for devices found
>>> I meant it should not be pairing...
>>>
>>>> during the scan but they are considered temporary as long as you don't
>>>> request to connect or pair, if you connect to it will still not be
>>>> paired but it will be stored persistently in the storage so you can
>>>> access after restarting bluetoothd.
>>>>
>>>> With this in mind, what had made you believe we were performing
>>>> pairing during scanning?
>> bluetoothctl prints a line like "[CHG] Device 90:59:AF:1D:F4:66 Paired: yes"
>> and reports the device as paired. In other words, it behaves exactly as if I
>> had explicitly requested to pair with the device, except I did no such
>> thing. In btmon, I can see the pairing request taking place, followed by a
>> GATT service discovery. I've attached an example to show what I mean.
> This sounds like the device was programmed for auto connect, did you
> connected to it before? It would explain why it is connecting but not
> why it is paring but perhaps it is because the service connecting does
> require encryption e.g. HoG. Try removing the device, it should stop
> reconnecting every time the device advertises.
>
>
To clarify, BlueZ does not automatically connect to the device when it
is already paired; it only connects (and pairs) when the device is not
already paired. So it is only after removing the device that this
behavior occurs.

Thanks,
Tom Harada

2015-05-11 15:16:11

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: LE device automatic pairing

Hi Tom,

On Mon, May 11, 2015 at 4:26 PM, Tom Harada <[email protected]> wrote:
> Hi Luiz,
>
>
> On 05/11/15 04:04, Luiz Augusto von Dentz wrote:
>>
>> Hi Tom,
>>
>> On Mon, May 11, 2015 at 11:03 AM, Luiz Augusto von Dentz
>> <[email protected]> wrote:
>>>
>>> Hi Tom,
>>>
>>> On Fri, May 8, 2015 at 5:31 PM, Tom Harada <[email protected]>
>>> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
>>>> BlueZ seems to be automatically pairing with LE devices as soon as it
>>>> detects their advertisements. Is this an intended feature? If so, how
>>>> can I
>>>> prevent it from happening?
>>>
>>> It should be pairing, bluetoothd will create objects for devices found
>>
>> I meant it should not be pairing...
>>
>>> during the scan but they are considered temporary as long as you don't
>>> request to connect or pair, if you connect to it will still not be
>>> paired but it will be stored persistently in the storage so you can
>>> access after restarting bluetoothd.
>>>
>>> With this in mind, what had made you believe we were performing
>>> pairing during scanning?
>
> bluetoothctl prints a line like "[CHG] Device 90:59:AF:1D:F4:66 Paired: yes"
> and reports the device as paired. In other words, it behaves exactly as if I
> had explicitly requested to pair with the device, except I did no such
> thing. In btmon, I can see the pairing request taking place, followed by a
> GATT service discovery. I've attached an example to show what I mean.

This sounds like the device was programmed for auto connect, did you
connected to it before? It would explain why it is connecting but not
why it is paring but perhaps it is because the service connecting does
require encryption e.g. HoG. Try removing the device, it should stop
reconnecting every time the device advertises.


--
Luiz Augusto von Dentz

2015-05-11 13:26:44

by Tom Harada

[permalink] [raw]
Subject: Re: LE device automatic pairing

Hi Luiz,

On 05/11/15 04:04, Luiz Augusto von Dentz wrote:
> Hi Tom,
>
> On Mon, May 11, 2015 at 11:03 AM, Luiz Augusto von Dentz
> <[email protected]> wrote:
>> Hi Tom,
>>
>> On Fri, May 8, 2015 at 5:31 PM, Tom Harada <[email protected]> wrote:
>>> Hi all,
>>>
>>> On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
>>> BlueZ seems to be automatically pairing with LE devices as soon as it
>>> detects their advertisements. Is this an intended feature? If so, how can I
>>> prevent it from happening?
>> It should be pairing, bluetoothd will create objects for devices found
> I meant it should not be pairing...
>
>> during the scan but they are considered temporary as long as you don't
>> request to connect or pair, if you connect to it will still not be
>> paired but it will be stored persistently in the storage so you can
>> access after restarting bluetoothd.
>>
>> With this in mind, what had made you believe we were performing
>> pairing during scanning?
bluetoothctl prints a line like "[CHG] Device 90:59:AF:1D:F4:66 Paired:
yes" and reports the device as paired. In other words, it behaves
exactly as if I had explicitly requested to pair with the device, except
I did no such thing. In btmon, I can see the pairing request taking
place, followed by a GATT service discovery. I've attached an example to
show what I mean.

Thanks,
Tom


Attachments:
btmon.txt (38.67 kB)

2015-05-11 08:04:32

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: LE device automatic pairing

Hi Tom,

On Mon, May 11, 2015 at 11:03 AM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi Tom,
>
> On Fri, May 8, 2015 at 5:31 PM, Tom Harada <[email protected]> wrote:
>> Hi all,
>>
>> On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
>> BlueZ seems to be automatically pairing with LE devices as soon as it
>> detects their advertisements. Is this an intended feature? If so, how can I
>> prevent it from happening?
>
> It should be pairing, bluetoothd will create objects for devices found

I meant it should not be pairing...

> during the scan but they are considered temporary as long as you don't
> request to connect or pair, if you connect to it will still not be
> paired but it will be stored persistently in the storage so you can
> access after restarting bluetoothd.
>
> With this in mind, what had made you believe we were performing
> pairing during scanning?
>
>
> --
> Luiz Augusto von Dentz



--
Luiz Augusto von Dentz

2015-05-11 08:03:59

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: LE device automatic pairing

Hi Tom,

On Fri, May 8, 2015 at 5:31 PM, Tom Harada <[email protected]> wrote:
> Hi all,
>
> On a system with kernel 4.0.1 and BlueZ 5.22 or newer, I've noticed that
> BlueZ seems to be automatically pairing with LE devices as soon as it
> detects their advertisements. Is this an intended feature? If so, how can I
> prevent it from happening?

It should be pairing, bluetoothd will create objects for devices found
during the scan but they are considered temporary as long as you don't
request to connect or pair, if you connect to it will still not be
paired but it will be stored persistently in the storage so you can
access after restarting bluetoothd.

With this in mind, what had made you believe we were performing
pairing during scanning?


--
Luiz Augusto von Dentz