Search code examples
cbluez

BlueZ Mgmt API: "Add Extended Advertising Parameters Command" doesn't change advertising interval


I am wondering can anyone help me with a problem I am having using BlueZ management API?

I am running latest release, v5.64

Theres a command in the mgmt API, 0x0054: Add Extended Advertising Parameters Command with parameters as outlined below:

Command Code:       0x0054
    Controller Index:   <controller id>
    Command Parameters: Instance (1 Octet)
                Flags (4 Octets)
                Params (2 Octets)
                Duration (2 Octets)
                Timeout (2 Octets)
                MinInterval (4 Octets)
                MaxInterval (4 Octets)
                TxPower (1 Octet)
    Return Parameters:  Instance (1 Octet)
                TxPower (1 Octet)
                MaxAdvDataLen (1 Octet)
                MaxScanRspLen (1 Octet)

(Now, one problem is that this documentation seems to be incorrect, but setting that aside for a second as I have managed to work out what it actually wants...)

I send it a command, as seen in btmon trace below:

@ MGMT Command: Add Extended Advertising Parameters (0x0054) plen 20
        Instance: 1
        Flags: 0x00000002
          Advertise as Discoverable
        Duration: 0
        Timeout: 0
        Min advertising interval: 200.000 msec (0x0140)
        Max advertising interval: 200.000 msec (0x0140)
        TX power: 0 dbm (0x00)

Next in btmon I see it do the following:

< HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25                                           
        Handle: 0x01
        Properties: 0x0013
          Connectable
          Scannable
          Use legacy advertising PDUs: ADV_IND
        Min advertising interval: 1280.000 msec (0x0800)
        Max advertising interval: 1280.000 msec (0x0800)

As you can see it is setting the interval to 1280msec.

Then I send the command 0x0055: Add Extended Advertising Data Command and I get an advert as expected, except it does not have a 200msec interval, it has a 1280msec interval.

This 1280msec value comes from /sys/kernel/debug/bluetooth/hci0/adv_min_interval and /sys/kernel/debug/bluetooth/hci0/adv_max_interval which both read 2048.

2048 * 0.625ms slots = 1280ms

Typically before, I would have echoed values into this file to change the advertising interval, but in my current application I want to change the interval on the fly and echo'ing new values only works if the advert is stopped and started again.

Does anyone know how to get BlueZ to ignore the values in adv_max_interval and adv_min_interval and instead use the value sent in command 0x0054?

Thanks!


Solution

  • Sorry, was being an idiot - posting in case someone finds this!

    I needed to set an additional flag shown further down in the docs:

    enter image description here