Re: BLE ad discoverability flags - missing when ads are generated, but needed when scanning

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

 



Hi Luiz,

Thanks for the prompt reply.

On 03/05/18 18:58, Luiz Augusto von Dentz wrote:
> Hi David,
> 
> On Thu, May 3, 2018 at 7:42 PM David Llewellyn-Jones <david@xxxxxxxxxxxx>
> wrote:
> 
>> Hi,
> 
>> I've been using bluez on a combination of an Ubuntu laptop running bluez
>> 5.49 compiled from source and a Sailfish OS phone running the default
>> install bluez 5.47. On the laptop I'm using DBUS to interact with bluez;
>> on the phone I'm going via the QTBluetoothDiscoveryAgent interface,
>> running QT 5.6.
> 
>> The difficulty I've been experiencing is that BLE advertisements sent
>> from the laptop in peripheral mode aren't being discovered by the phone.
> 
>> I can see the advertisements being picked up by btmon on the phone, but
>> it doesn't filter up to the QT wrapper. Looking through the bluez source
>> code, it appears that the reason is because in the case of unfiltered
>> discovery, bluez ignores adverts that don't have either EIR_LIM_DISC or
>> EIR_GEN_DISC flags set, as in the following code:
> 
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/adapter.c?h=5.47#n5658
> 
>> However, as far as I can tell (I could easily be wrong), bluez never
>> adds these flags into the advertising data. I was expecting to see them
>> added in the following bit of code:
> 
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/shared/ad.c#n423
> 
>> As a result, I can't figure out a way to produce advertisements from my
>> laptop that can be picked up by my phone.
> 
>> Adding the flags by calling the following function within
>> bt_ad_generate() with a value of 0x06 fixed the issue (i.e. allowed my
>> phone to discover my laptop).
> 
>> static void serialize_flags(uint8_t value, uint8_t *buf, uint8_t *pos)
>> {
>>          if (value == 0)
>>                  return;
> 
>>          buf[(*pos)++] = sizeof(value) + 1;
>>          buf[(*pos)++] = EIR_FLAGS;
>>          buf[(*pos)++] = value;
>> }
> 
>> My question is therefore whether there's a way for bluez to produce BLE
>> advertisements (on my laptop) that can be picked up by a non-filtered
>> scan using bluez (on my phone). I searched the Web and the list archives
>> but didn't find anything that seemed to help answer.
> 
> It is actually added if you have marked the adapter as Discoverable:
> 
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/advertising.c#n740

>From what I can make out, the flag is registered, but never actually
added to the advert payload data. At least, this is what I could make
out from the 5.49 code, and running experiments matched this behaviour
(i.e. marking the adapter discoverable and running the scan still
yielded no results).

I also noticed that making the adapter discoverable turns on visibility
for Bluetooth Classic, which I was hoping to avoid. There would be
definite value for me in separating the two (e.g. being able to
explicitly set the flags in the advert).

> There has been some debate if we should have this per instance but that
> would probably require some changes in the way we deal with whitelist
> devices since currently we only allow unknown devices to connect when
> discoverable.

I'm afraid I don't understand the issue as I'm not sure what you mean by
whitelist devices, and I must have missed this discussing when searching
the archives. I'll dig a bit further to try to understand better.

David
-- 
Website: http://www.flypig.co.uk
--
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