Help understanding BLE Advertising and Scan Response packets...

From: Patrick Doyle <hidden>
Date: 2021-05-12 01:40:17

I'm confused by how Bluez assigns data the to BLE and Scan Response
packets.  In src/advertising.c, in the refresh_legacy_adv() function,
I see the following:


adv_data = generate_adv_data(client, &flags, &adv_data_len);
..
scan_rsp = generate_scan_rsp(client, &flags, &scan_rsp_len);

Looking in generate_adv_data() and generate_scan_rsp(), I see that
they both end with:

return bt_ad_generate(client->data, len);

So, then I look at bt_ad_generate() in src/shared/ad.c and I see code
much like the following:

serialize_service_uuids(ad->service_uuids, adv_data, &pos);
serialize_solicit_uuids(ad->solicit_uuids, adv_data, &pos);
serialize_manuf_data(ad->manufacturer_data, adv_data, &pos);
serialize_service_data(ad->service_data, adv_data, &pos);
serialize_name(ad->name, adv_data, &pos);
serialize_appearance(ad->appearance, adv_data, &pos);
serialize_data(ad->data, adv_data, &pos);

return adv_data;

From inspecting the code, it seems to me that Bluez stuffs the same
data in both the advertising_data packet, and in the scan_repsonse
packet.  This is especially confusing to me because, examining the
packets on the air with a BLE sniffer, that is NOT what I see... but I
can't figure why not.

On a somewhat related note, I have constructed my D-Bus object with
its org.bluez.LEAdvertisement1 interface to specify the data I want in
my BLE peripheral advertising packet, and I overflowed the size of the
advertising_data packet.  I would like to figure out how to indicate
to Bluez that I would like the "service_data" portion of my
advertisement to go into the scan_response packet instead of the
advertising_data packet.  Any tips on how to do that?

Thanks

--wpd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help