2014-01-24 14:15:36

by Adam Warski

[permalink] [raw]
Subject: Discovering LE advertisements programatically

Hello,

I?m trying to find a good way to discover and retrieve LE advertisements programatically.

My first shot was to try to use DBus. I was trying to extend what the test/test-discovery script is doing, but it seems using DBus I can only get notified of new devices being discovered. Is there a way to get the actual LE advertisement via DBus? The device properties seem not to contain the info from the advertisement PDU.

If that?s not possible using DBus, is the way to go just using C?

I also tried using command line, a combination of ?hcitool lescan? and ?hcidump?/?hcidump -R" gives what I need more or less (plain hcidump gives me the RSSI, hcidump -R gives me the raw packet that I need). Still, I guess there must be a better way.

Thanks,
Adam

--
Adam Warski

http://twitter.com/#!/adamwarski
http://www.softwaremill.com
http://www.warski.org


2014-01-26 11:20:21

by Adam Warski

[permalink] [raw]
Subject: Re: Discovering LE advertisements programatically


>>> I?m trying to find a good way to discover and retrieve LE advertisements programatically.
>>>
>>> My first shot was to try to use DBus. I was trying to extend what the test/test-discovery script is doing, but it seems using DBus I can only get notified of new devices being discovered. Is there a way to get the actual LE advertisement via DBus? The device properties seem not to contain the info from the advertisement PDU.
>>>
>>> If that?s not possible using DBus, is the way to go just using C?
>>>
>>> I also tried using command line, a combination of ?hcitool lescan? and ?hcidump?/?hcidump -R" gives what I need more or less (plain hcidump gives me the RSSI, hcidump -R gives me the raw packet that I need). Still, I guess there must be a better way.
>>
>> My suggestion would be to take a look at "hcitool lescan" for how it
>> is done using C sockets. Or you can modify hcitool lescan to dump the
>> full advertising report instead of just the name.
>
> Indeed by modifying the source of the hcitool, lescan method (print_advertising_devices), I am able to get the advertisement content. However, I?d also like to get the RSSI - is it possible from that method? I have access to the open device (dd), and the evt_le_meta_event and le_advertising_info structures - but that doesn?t seem to be enough. There is a hci_read_rssi in lib/hci.c, but it requires a ?handle? - I think it?s only useable if a conneciton is open.

Actually, looking at the whole data received from the socket, I think the last byte - and the only byte remaining after the advertisement packet - is the RSSI.

So I guess writing to the group worked as a rubber duck :)

Adam

--
Adam Warski

http://twitter.com/#!/adamwarski
http://www.softwaremill.com
http://www.warski.org


2014-01-26 11:03:04

by Adam Warski

[permalink] [raw]
Subject: Re: Discovering LE advertisements programatically


>> I?m trying to find a good way to discover and retrieve LE advertisements programatically.
>>
>> My first shot was to try to use DBus. I was trying to extend what the test/test-discovery script is doing, but it seems using DBus I can only get notified of new devices being discovered. Is there a way to get the actual LE advertisement via DBus? The device properties seem not to contain the info from the advertisement PDU.
>>
>> If that?s not possible using DBus, is the way to go just using C?
>>
>> I also tried using command line, a combination of ?hcitool lescan? and ?hcidump?/?hcidump -R" gives what I need more or less (plain hcidump gives me the RSSI, hcidump -R gives me the raw packet that I need). Still, I guess there must be a better way.
>
> My suggestion would be to take a look at "hcitool lescan" for how it
> is done using C sockets. Or you can modify hcitool lescan to dump the
> full advertising report instead of just the name.

Indeed by modifying the source of the hcitool, lescan method (print_advertising_devices), I am able to get the advertisement content. However, I?d also like to get the RSSI - is it possible from that method? I have access to the open device (dd), and the evt_le_meta_event and le_advertising_info structures - but that doesn?t seem to be enough. There is a hci_read_rssi in lib/hci.c, but it requires a ?handle? - I think it?s only useable if a conneciton is open.

An alternative route that I see is to extract some part of hcidump, where I can get access to the raw packet and the RSSI, having the whole frame at my disposal. But that seems a bit ?hackish? :)

Thanks,
Adam

--
Adam Warski

http://twitter.com/#!/adamwarski
http://www.softwaremill.com
http://www.warski.org


2014-01-24 14:38:58

by Anderson Lizardo

[permalink] [raw]
Subject: Re: Discovering LE advertisements programatically

Hi Adam,

On Fri, Jan 24, 2014 at 10:15 AM, Adam Warski <[email protected]> wrote:
> I?m trying to find a good way to discover and retrieve LE advertisements programatically.
>
> My first shot was to try to use DBus. I was trying to extend what the test/test-discovery script is doing, but it seems using DBus I can only get notified of new devices being discovered. Is there a way to get the actual LE advertisement via DBus? The device properties seem not to contain the info from the advertisement PDU.
>
> If that?s not possible using DBus, is the way to go just using C?
>
> I also tried using command line, a combination of ?hcitool lescan? and ?hcidump?/?hcidump -R" gives what I need more or less (plain hcidump gives me the RSSI, hcidump -R gives me the raw packet that I need). Still, I guess there must be a better way.

My suggestion would be to take a look at "hcitool lescan" for how it
is done using C sockets. Or you can modify hcitool lescan to dump the
full advertising report instead of just the name.

Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
Manaus - Brazil