All of lore.kernel.org
 help / color / mirror / Atom feed
* Re-connect to BLE device in response to ADV_DIRECT_IND
@ 2017-04-04 13:29 sudeepta bhuyan
  2017-04-05  1:14 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: sudeepta bhuyan @ 2017-04-04 13:29 UTC (permalink / raw)
  To: linux-bluetooth

Hello all,

I'm a BlueZ newbie and wanted your help regarding a problem that I'm
facing with a BLE project.

I'm running BlueZ 5.42 in my linux machine and have written a
bluetooth application which communicates with a BLE device.
The application uses bluez dbus APIs for pairing and connecting to the
BLE device (device-api.txt and adapter-api.txt).
The BLE device is programmed to disconnect if left idle and send
ADV_DIRECT_IND if woken up.

Using hcidump tool, I see that bluetoothd on my machine indeed
receives the ADV_DIRECT_IND message from the BLE device. However I'm
not able to figure out how my application can be made aware that such
an advertisement has been received and it should now reconnect to the
BLE device.

I do not see any dbus API or signal using which the application can be
made aware of this event.

Could you suggest me a solution to this? Are there any low level
settings/configuration which would make bluetoothd automatically
reconnect to the BLE device if it receives an ADV_DIRECT_IND?

Appreciate your help.

Thanks,
Sudeepta

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

* Re: Re-connect to BLE device in response to ADV_DIRECT_IND
  2017-04-04 13:29 Re-connect to BLE device in response to ADV_DIRECT_IND sudeepta bhuyan
@ 2017-04-05  1:14 ` Marcel Holtmann
  2017-04-05 11:16   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2017-04-05  1:14 UTC (permalink / raw)
  To: sudeepta bhuyan; +Cc: linux-bluetooth

Hi Sudeepta,

> I'm a BlueZ newbie and wanted your help regarding a problem that I'm
> facing with a BLE project.
> 
> I'm running BlueZ 5.42 in my linux machine and have written a
> bluetooth application which communicates with a BLE device.
> The application uses bluez dbus APIs for pairing and connecting to the
> BLE device (device-api.txt and adapter-api.txt).
> The BLE device is programmed to disconnect if left idle and send
> ADV_DIRECT_IND if woken up.
> 
> Using hcidump tool, I see that bluetoothd on my machine indeed
> receives the ADV_DIRECT_IND message from the BLE device. However I'm
> not able to figure out how my application can be made aware that such
> an advertisement has been received and it should now reconnect to the
> BLE device.
> 
> I do not see any dbus API or signal using which the application can be
> made aware of this event.
> 
> Could you suggest me a solution to this? Are there any low level
> settings/configuration which would make bluetoothd automatically
> reconnect to the BLE device if it receives an ADV_DIRECT_IND?

the kernel will auto-connect that device if it is in its auto-connect list. I think there are options via D-Bus to enable the auto-connect feature for certain devices.

Regards

Marcel


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

* Re: Re-connect to BLE device in response to ADV_DIRECT_IND
  2017-04-05  1:14 ` Marcel Holtmann
@ 2017-04-05 11:16   ` Luiz Augusto von Dentz
  2017-04-05 11:25     ` sudeepta bhuyan
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2017-04-05 11:16 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: sudeepta bhuyan, linux-bluetooth

Hi Sudeepta,

On Wed, Apr 5, 2017 at 4:14 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Sudeepta,
>
>> I'm a BlueZ newbie and wanted your help regarding a problem that I'm
>> facing with a BLE project.
>>
>> I'm running BlueZ 5.42 in my linux machine and have written a
>> bluetooth application which communicates with a BLE device.
>> The application uses bluez dbus APIs for pairing and connecting to the
>> BLE device (device-api.txt and adapter-api.txt).
>> The BLE device is programmed to disconnect if left idle and send
>> ADV_DIRECT_IND if woken up.
>>
>> Using hcidump tool, I see that bluetoothd on my machine indeed
>> receives the ADV_DIRECT_IND message from the BLE device. However I'm
>> not able to figure out how my application can be made aware that such
>> an advertisement has been received and it should now reconnect to the
>> BLE device.
>>
>> I do not see any dbus API or signal using which the application can be
>> made aware of this event.
>>
>> Could you suggest me a solution to this? Are there any low level
>> settings/configuration which would make bluetoothd automatically
>> reconnect to the BLE device if it receives an ADV_DIRECT_IND?
>
> the kernel will auto-connect that device if it is in its auto-connect list. I think there are options via D-Bus to enable the auto-connect feature for certain devices.

The applications needs to register itself with RegisterApplication and
have a matching GattProfile in order for bluetoothd to add a device to
the auto-connect list:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt

Note, if device.Disconnect is called it will remove the device from
the auto-connect list, in that case device.Connect has to be called
manually in order to add the device back.



-- 
Luiz Augusto von Dentz

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

* Re: Re-connect to BLE device in response to ADV_DIRECT_IND
  2017-04-05 11:16   ` Luiz Augusto von Dentz
@ 2017-04-05 11:25     ` sudeepta bhuyan
  0 siblings, 0 replies; 4+ messages in thread
From: sudeepta bhuyan @ 2017-04-05 11:25 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Marcel Holtmann, linux-bluetooth

Thanks Marcel and  Luiz
My application was always in active discovery mode. After disabling
active discovery, auto connect started to work. I have read that this
is an issue with linux kernel version < 3.17.


Sudeepta

On Wed, Apr 5, 2017 at 4:46 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Sudeepta,
>
> On Wed, Apr 5, 2017 at 4:14 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
>> Hi Sudeepta,
>>
>>> I'm a BlueZ newbie and wanted your help regarding a problem that I'm
>>> facing with a BLE project.
>>>
>>> I'm running BlueZ 5.42 in my linux machine and have written a
>>> bluetooth application which communicates with a BLE device.
>>> The application uses bluez dbus APIs for pairing and connecting to the
>>> BLE device (device-api.txt and adapter-api.txt).
>>> The BLE device is programmed to disconnect if left idle and send
>>> ADV_DIRECT_IND if woken up.
>>>
>>> Using hcidump tool, I see that bluetoothd on my machine indeed
>>> receives the ADV_DIRECT_IND message from the BLE device. However I'm
>>> not able to figure out how my application can be made aware that such
>>> an advertisement has been received and it should now reconnect to the
>>> BLE device.
>>>
>>> I do not see any dbus API or signal using which the application can be
>>> made aware of this event.
>>>
>>> Could you suggest me a solution to this? Are there any low level
>>> settings/configuration which would make bluetoothd automatically
>>> reconnect to the BLE device if it receives an ADV_DIRECT_IND?
>>
>> the kernel will auto-connect that device if it is in its auto-connect list. I think there are options via D-Bus to enable the auto-connect feature for certain devices.
>
> The applications needs to register itself with RegisterApplication and
> have a matching GattProfile in order for bluetoothd to add a device to
> the auto-connect list:
>
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt
>
> Note, if device.Disconnect is called it will remove the device from
> the auto-connect list, in that case device.Connect has to be called
> manually in order to add the device back.
>
>
>
> --
> Luiz Augusto von Dentz

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

end of thread, other threads:[~2017-04-05 11:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 13:29 Re-connect to BLE device in response to ADV_DIRECT_IND sudeepta bhuyan
2017-04-05  1:14 ` Marcel Holtmann
2017-04-05 11:16   ` Luiz Augusto von Dentz
2017-04-05 11:25     ` sudeepta bhuyan

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.