Return-Path: MIME-Version: 1.0 In-Reply-To: References: <024AE186-38B1-4A58-B889-02AF6D776F8D@starleaf.com> <87lh0fytdb.fsf@intel.com> From: Luiz Augusto von Dentz Date: Wed, 3 Aug 2016 14:17:34 +0300 Message-ID: Subject: Re: Possible bug: D-Bus Advertising API does not generate first section of advertising payload To: Alex Coplan Cc: Vinicius Costa Gomes , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Alex, On Wed, Aug 3, 2016 at 1:32 PM, Alex Coplan wrote: > Hi both, > >> On 3 Aug 2016, at 11:19, Luiz Augusto von Dentz wrote: >> >> Hi Alex, Vinicius, >> >> On Tue, Aug 2, 2016 at 8:26 PM, Vinicius Costa Gomes >> wrote: >>> Hi Alex, >>> >>> Alex Coplan writes: >>> >>>> Hi all, >>>> >>>> I’m experiencing a bit of trouble using the BlueZ D-Bus API for broadcast advertising. In particular, I’m trying to generate iBeacon advertisements using the API. >>>> >>>> So far, I have successfully used the D-Bus API to implement LE peripheral advertising (Type = ‘peripheral’). However, getting BlueZ to generate well-formed iBeacon packets is proving problematic. >>>> >>>> In the process of debugging, I used hcidump to obtain the advertising payload produced by my code. I have a reference implementation using the HCI socket API to generate iBeacon advertisements, and this works well. Here is the advertising payload generated by the HCI code (which I obtained from here: https://github.com/carsonmcdonald/bluez-ibeacon/blob/master/bluez-beacon/ibeacon.c). >>>> >>>> ============================================================== >>>> Working advertising payload generated by HCI code >>>> ============================================================== >>>> >>>> Total AD 0 Ad AD 1 Ad Apple Inc >>>> Length Len Type Flags Len Type --------- >>>> | | | | | | | | >>>> 1e 02 01 1a 1a ff 4c 00 >>>> >>>> iBeacon >>>> Prefix . . . . . . . U U I D . . . . >>>> --------- ------------------------------------- >>>> | | | >>>> 02 15 56 5c a5 be 7a df >>>> >>>> . . . . . . U U I D . . . . . . . . . . . . >>>> --------------------------------------------------- >>>> 4f 7b b2 68 91 f4 08 d7 >>>> >>>> . . . . . Major=10 Minor=10 Tx >>>> --------- --------- --------- Power Padding >>>> | | | | | | | >>>> 70 cd 00 0a 00 0a cf 00 >>>> >>>> ============================================================ >>>> >>>> I am using the terminology from this packet diagram (http://www.argenox.com/wp-content/uploads/ibeacon-packet-format.png). Packets containing this advertising payload are correctly recognised by iOS devices as iBeacon packets. >> >> Not sure where you got this from but 1a is not formatted according to >> the CSS, bits 5-7 are reserved also a broadcast shall not set LE >> General Discoverable Mode so this is very odd. > > This packet was generated by the code that I linked to on GitHub. That > code is also broken because it sets the packets to be connectable (ADV_IND) > instead of ADV_NONCONN_IND as it should be for a Beacon advertisement. Actually this is upstream and indeed is is not using the correct packet type as you said, but then the flags don't many any sense anymore, perhaps you can try changing it there to see how it would work with ADV_NONCONN_IND. >> But Im not sure if it is referring to the octet 0 as in the table >> bellow it or we should just send the setting the size to 1 and >> followed by type and no fields, if the intention is to save space, >> which I think it is, the omitting the flag makes a lot more sense >> specially since none of the flags fields applies to a broadcaster. > > Thanks for this. I also wonder whether setting the size to 1 in the case of zero > flags would fix the issue here. Clearly, omitting this part of the payload > altogether is breaking this case. Try that with ibeacon.c and let us know. -- Luiz Augusto von Dentz