All of lore.kernel.org
 help / color / mirror / Atom feed
* Disabling passive scanning for LE connections
@ 2016-05-19 22:06 mike mike
  2016-05-20  7:14 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: mike mike @ 2016-05-19 22:06 UTC (permalink / raw)
  To: linux-bluetooth

> All LE connections are now triggered through a preceding passive scan
> and waiting for a connectable advertising report. This means we've got
> the best possible guarantee that the device is within range and should
> be able to request the controller to perform continuous scanning. This
> way we minimize the risk that we miss out on any advertising packets.

My code manages 100's of BLE devices with long advertising periods.
I need to connect to devices (sometime multiples devices at the same
time) as quickly as possible.  My current implementation usually catches
and connects to the first advertising event (average connect time is < 7
seconds)

I have my own code using the HCI interface for doing this.  This code
has worked well for a while, but since the passive LE scanning was
added as part of the kernel connection processes (kernel 4.4.4?) I
have a problems with the process:

- occasionally conflicting with my access to the whitelist
- occasionally deleting all entries in my whitelist.

Is it possible to disable passive scanning, or will I need a kludge to
catch and work around these events?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Disabling passive scanning for LE connections
  2016-05-19 22:06 Disabling passive scanning for LE connections mike mike
@ 2016-05-20  7:14 ` Marcel Holtmann
  2016-05-23 17:49   ` mike mike
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2016-05-20  7:14 UTC (permalink / raw)
  To: mike mike; +Cc: linux-bluetooth

Hi Mike,

>> All LE connections are now triggered through a preceding passive scan
>> and waiting for a connectable advertising report. This means we've got
>> the best possible guarantee that the device is within range and should
>> be able to request the controller to perform continuous scanning. This
>> way we minimize the risk that we miss out on any advertising packets.
> 
> My code manages 100's of BLE devices with long advertising periods.
> I need to connect to devices (sometime multiples devices at the same
> time) as quickly as possible.  My current implementation usually catches
> and connects to the first advertising event (average connect time is < 7
> seconds)
> 
> I have my own code using the HCI interface for doing this.  This code
> has worked well for a while, but since the passive LE scanning was
> added as part of the kernel connection processes (kernel 4.4.4?) I
> have a problems with the process:
> 
> - occasionally conflicting with my access to the whitelist
> - occasionally deleting all entries in my whitelist.
> 
> Is it possible to disable passive scanning, or will I need a kludge to
> catch and work around these events?

use HCI User Channel to gain exclusive HCI access. Otherwise the kernel owns the HCI control and not you. You would be injecting commands from user space with no guarantee that the kernel will overwrite it.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Disabling passive scanning for LE connections
  2016-05-20  7:14 ` Marcel Holtmann
@ 2016-05-23 17:49   ` mike mike
  2016-05-24  7:43     ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: mike mike @ 2016-05-23 17:49 UTC (permalink / raw)
  To: linux-bluetooth

Thank you, Marcel.

I was not aware of the HCI User Channel.  It looks like it may be the
way I have to eventually go.  The code currently uses L2CAP sockets
for BLE GATT data and it looks like this would mean I need to write my
own replacement.  I have not looked into writing and L2CAP socket
replacement, but assume this will be a major task.  Any other
suggestions or recommendations on where to start for the L2CAP socket
replacement?

On Fri, May 20, 2016 at 12:14 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Mike,
>
>>> All LE connections are now triggered through a preceding passive scan
>>> and waiting for a connectable advertising report. This means we've got
>>> the best possible guarantee that the device is within range and should
>>> be able to request the controller to perform continuous scanning. This
>>> way we minimize the risk that we miss out on any advertising packets.
>>
>> My code manages 100's of BLE devices with long advertising periods.
>> I need to connect to devices (sometime multiples devices at the same
>> time) as quickly as possible.  My current implementation usually catches
>> and connects to the first advertising event (average connect time is < 7
>> seconds)
>>
>> I have my own code using the HCI interface for doing this.  This code
>> has worked well for a while, but since the passive LE scanning was
>> added as part of the kernel connection processes (kernel 4.4.4?) I
>> have a problems with the process:
>>
>> - occasionally conflicting with my access to the whitelist
>> - occasionally deleting all entries in my whitelist.
>>
>> Is it possible to disable passive scanning, or will I need a kludge to
>> catch and work around these events?
>
> use HCI User Channel to gain exclusive HCI access. Otherwise the kernel owns the HCI control and not you. You would be injecting commands from user space with no guarantee that the kernel will overwrite it.
>
> Regards
>
> Marcel
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Disabling passive scanning for LE connections
  2016-05-23 17:49   ` mike mike
@ 2016-05-24  7:43     ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2016-05-24  7:43 UTC (permalink / raw)
  To: mike mike; +Cc: linux-bluetooth

Hi Mike,

> I was not aware of the HCI User Channel.  It looks like it may be the
> way I have to eventually go.  The code currently uses L2CAP sockets
> for BLE GATT data and it looks like this would mean I need to write my
> own replacement.  I have not looked into writing and L2CAP socket
> replacement, but assume this will be a major task.  Any other
> suggestions or recommendations on where to start for the L2CAP socket
> replacement?

I think there are some examples in the code. However LE L2CAP (especially for GATT) is dead simple. It used a fixed channel and the only thing you need to deal with is the basic fragmentation.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-24  7:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-19 22:06 Disabling passive scanning for LE connections mike mike
2016-05-20  7:14 ` Marcel Holtmann
2016-05-23 17:49   ` mike mike
2016-05-24  7:43     ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.