-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
macOS sends a bunch of custom (vendor defined) HCI commands to the Broadcom bluetooth chip. Some of them appear to affect things like audio latency, some appear to be setting up AWDL/continuity things.
The commands are from a 2020 M1 Macbook Pro, would be interesting to see if they are the same on other models. They can be snooped on macOS using "PacketLogger" from the XCode Development tools.
Here's a list of the vendor specific commands (listed as hcitool cmd to quickly try them):
commands during controller init sequence
# these vendor specific commands get sent as part of the init sequence after turning on bluetooth on macOS
sudo hcitool cmd 0x3f 0x0e2 0x2a 0x00 0x00 0x00 0x01
> HCI Event: 0x0e plen 13
01 E2 FC 00 00 00 00 00 00 00 00 00 00
sudo hcitool cmd 0x3f 0x11c 0x51 0x00
> HCI Event: 0x0e plen 7
01 1C FD 00 51 00 00
sudo hcitool cmd 0x3f 0x0e9 0x02 0x1e 0xae 0x7f 0xc4 0xa2 0xaf 0x01 0x3b 0xfc 0x12 0x96 0x7e 0xfe 0x7f 0x21 0x8d 0x00 0xef 0x4e 0xf3 0x9f 0x10 0x14
> HCI Event: 0x0e plen 6
01 E9 FC 00 02 7F
sudo hcitool cmd 0x3f 0x0e9 0x02 0x79 0x26 0x77 0xcb 0xa1 0x71 0x50 0x6e 0xcd 0x7d 0x6e 0xc8 0x73 0xe7 0x26 0x8e 0x00 0x90 0xe5 0x58 0x4e 0xe9 0xf8
> HCI Event: 0x0e plen 6
01 E9 FC 00 02 7E
sudo hcitool cmd 0x3f 0x0e9 0x02 0x3b 0xb0 0x3f 0x90 0x75 0xb1 0x6c 0x4b 0x4e 0x32 0x19 0x88 0x2b 0x95 0x6d 0xb3 0x00 0x7e 0xa5 0x06 0x6e 0x6b 0x88
> HCI Event: 0x0e plen 6
01 E9 FC 00 02 7D
sudo hcitool cmd 0x3f 0x0e9 0x01 0xab 0x10 0x84 0x00
> HCI Event: 0x0e plen 5
01 E9 FC 00 01
sudo hcitool cmd 0x3f 0x0e2 0x1c 0x00 0x00 0x00 0x0a
> HCI Event: 0x0e plen 13
01 E2 FC 00 00 00 00 00 00 00 00 00 00
# this one seems to set how many packets to buffer before transmitting (set to 1 here with 0x01)
sudo hcitool cmd 0x3f 0x0e2 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00
> HCI Event: 0x0e plen 13
01 E2 FC 00 00 00 00 00 00 00 00 00 00
sudo hcitool cmd 0x3f 0x148 0x01 0xa5 0x90 0x72 0xdd 0x8a 0x52
> HCI Event: 0x0e plen 5
01 48 FD 00 02
sudo hcitool cmd 0x3f 0x147 0x00 0x00 0x01
> HCI Event: 0x0e plen 4
01 47 FD 00
sudo hcitool cmd 0x3f 0x148 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 5
01 48 FD 00 03
sudo hcitool cmd 0x3f 0x1f2 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x01
> HCI Event: 0x0e plen 36
01 F2 FD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hcitool cmd 0x3f 0x148 0x01 0x83 0x6f 0xb3 0x8a 0xf4 0x28
> HCI Event: 0x0e plen 5
01 48 FD 00 04
sudo hcitool cmd 0x3f 0x0e2 0x26 0x00 0x00 0x00 0x01 0x00
> HCI Event: 0x0e plen 13
01 E2 FC 00 00 00 00 00 00 00 00 00 00
sudo hcitool cmd 0x3f 0x148 0x01 0x7d 0xec 0xfc 0xd1 0x98 0x1c
> HCI Event: 0x0e plen 5
01 48 FD 00 05
# this one returns "Unsupported Feature or Parameter Value"
sudo hcitool cmd 0x3f 0x0e9 0x32 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa6 0x09
> HCI Event: 0x0e plen 5
01 E9 FC 11 32
sudo hcitool cmd 0x3f 0x148 0x01 0xbb 0x94 0xb8 0x34 0x86 0x27
> HCI Event: 0x0e plen 5
01 48 FD 00 06
sudo hcitool cmd 0x3f 0x0e9 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x04 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 6
01 E9 FC 00 05 00
sudo hcitool cmd 0x3f 0x14e 0x01 0x01 0xa5 0x90 0x72 0xdd 0x8a 0x52
> HCI Event: 0x0e plen 4
01 4E FD 12
sudo hcitool cmd 0x3f 0x14e 0x06 0x01 0xa5 0x90 0x72 0xdd 0x8a 0x52
> HCI Event: 0x0e plen 4
01 4E FD 12
sudo hcitool cmd 0x3f 0x14e 0x03 0x01 0x65 0x09 0xb9 0x27 0x21 0x74
> HCI Event: 0x0e plen 4
01 4E FD 00
sudo hcitool cmd 0x3f 0x14e 0x05 0x01 0x66 0x20 0x29 0xf4 0x27 0x47
> HCI Event: 0x0e plen 4
01 4E FD 00
sudo hcitool cmd 0x3f 0x0e9 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x12 0x18
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14a 0x01 0xb0 0x01 0xb0 0x01 0x00 0x07 0x00
> HCI Event: 0x0e plen 4
01 4A FD 00
sudo hcitool cmd 0x3f 0x0e9 0x05 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x02
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14b 0x01 0x11 0x02 0x01 0x1a 0x02 0x0a 0x05 0x0a 0xff 0x4c 0x00 0x10 0x05 0x45 0x1c 0x83 0xd7 0x7f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4B FD 00
sudo hcitool cmd 0x3f 0x0e9 0x07 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x02
> HCI Event: 0x0e plen 7
01 E9 FC 00 07 02 08
sudo hcitool cmd 0x3f 0x14d 0x01 0x01 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4D FD 00
sudo hcitool cmd 0x3f 0x0e9 0x1e
> HCI Event: 0x0e plen 7
01 E9 FC 00 1E 64 64
sudo hcitool cmd 0x3f 0x14a 0x05 0xb0 0x01 0xb0 0x01 0x00 0x07 0x00
> HCI Event: 0x0e plen 4
01 4A FD 00
sudo hcitool cmd 0x3f 0x0e9 0x35 0x02
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14b 0x05 0x11 0x02 0x01 0x1a 0x02 0x0a 0x05 0x0a 0xff 0x4c 0x00 0x10 0x05 0x45 0x1c 0x83 0xd7 0x7f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x0e9 0x32 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x9c 0x12
> HCI Event: 0x0e plen 5
01 E9 FC 11 32
# this one makes the device appear in AirDrop
sudo hcitool cmd 0x3f 0x14d 0x05 0x01 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4D FD 00
sudo hcitool cmd 0x3f 0x0e9 0x01 0xab 0x10 0x84 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x0e9 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x04 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 6
01 E9 FC 00 05 00
sudo hcitool cmd 0x3f 0x0e9 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x12 0x18
> HCI Event: 0x0e plen 7
01 E9 FC 00 07 00 07
sudo hcitool cmd 0x3f 0x14d 0x01 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14d 0x05 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14a 0x01 0xb0 0x01 0xb0 0x01 0x00 0x07 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14b 0x01 0x11 0x02 0x01 0x1a 0x02 0x0a 0x05 0x0a 0xff 0x4c 0x00 0x10 0x05 0x45 0x1c 0x83 0xd7 0x7f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4B FD 00
sudo hcitool cmd 0x3f 0x14d 0x01 0x01 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x14a 0x05 0xb0 0x01 0xb0 0x01 0x00 0x07 0x00
> HCI Event: 0x0e plen 4
01 4A FD 00
sudo hcitool cmd 0x3f 0x14b 0x05 0x11 0x02 0x01 0x1a 0x02 0x0a 0x05 0x0a 0xff 0x4c 0x00 0x10 0x05 0x45 0x1c 0x83 0xd7 0x7f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4B FD 00
sudo hcitool cmd 0x3f 0x14d 0x05 0x01 0x00 0x00 0x00 0x00 0x00
> HCI Event: 0x0e plen 4
01 4D FD 00
# from now on only similar series of 0x0e9 commands get executed periodically (something that seems to be related to LE stuff: LE scanning gets disabled, command sequence is executed, LE scanning enabled again)
commands after connecting an a2dp sink
sudo hcitool cmd 0x3f 0x0e2 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00
commands after starting to play on a2dp sink
# broadcom set ACL priority (0x0b 0x00 is the connection handle)
sudo hcitool cmd 0x3f 0x057 0x0b 0x00 0x01
> HCI Event: 0x13 plen 5
01 0B 00 01 00
sudo hcitool cmd 0x3f 0x0e2 0x04 0x00 0x00 0x00 0x2d 0x00 0x00 0x00
# here the 0x0c 0x00 is a connection handle
# after sending this command we get a vendor defined event (len 180, starts with seq 0x88 0x1d 0x01 0x15 0x00, the last two bytes is the connection handle) every second, they stop again when disconnecting the device
sudo hcitool cmd 0x3f 0x1dd 0x0c 0x00 0x1d 0x01
# here 0x0c 0x00 is a connection handle
# after this we start getting a few vendor defined events (len 224, starting with 0xb5 0x00 0x00 0x01)
sudo hcitool cmd 0x3f 0x205 0x01 0x02 0x02 0x00 0x02 0x00 0x0c 0x00
# here 0x0c 0x00 is a connection handle
sudo hcitool cmd 0x3f 0x0e2 0x15 0x00 0x00 0x00 0x0c 0x00 0x01 0x06 0x00 0x83
# here 0x0c 0x00 is a connection handle
sudo hcitool cmd 0x3f 0x22d 0x00 0x0c 0x00 0x07 0xc2 0x81 0x00 0x00 0x00 0x00 0x00
commands after ending audio stream a2dp sink
# here the 0x0d 0x00 is a connection handle
sudo hcitool cmd 0x3f 0x1dd 0x0d 0x00 0x00 0x00
# here 0x0d 0x00 is a connection handle
sudo hcitool cmd 0x3f 0x22d 0x00 0x0d 0x00 0x00 0xbb 0xb0 0x00 0x00 0x00 0x00 0x00
# broadcom set ACL priority (0x0d 0x00 is the connection handle)
sudo hcitool cmd 0x3f 0x057 0x0d 0x00 0x00
sudo hcitool cmd 0x3f 0x0e2 0x04 0x00 0x00 0x00 0x2d 0x00 0x00 0x00
commands after disconnecting an a2dp sink
sudo hcitool cmd 0x3f 0x0e2 0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00
commands after connecting magic keyboard or mouse
sudo hcitool cmd 0x3f 0x0e2 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00
# here 0x10 0x00 is a connection handle
# sent every time after moving the connection to sniff mode, sometimes card returns "Command Disallowed"
sudo hcitool cmd 0x3f 0x206 0x10 0x00 0x01 0x01 0x64 0x00 0x00 0x00
Nothing special seems to happen on disconnecting magic keyboard or mouse.
The different kinds of OCFs seen are
- 0x057: Fairly standard and documented "broadcom set ACL priority" command
- 0x0e2: Seems to be a "generic" hardware/radio configuration thing with sub-commands
- first byte is the sub-command
- then 3 0x00 bytes
- then args
- return value is usually "E2 FC 00 00 00 00 00 00 00 00 00 00" on success
- 0x0e9: Might be another generic thing to set some state, possibly also LE specific thing
- 0x147, 0x148, 0x14a, 0x14b, 0x14d, 0x14e: Lots of these, I wonder if these are Apple specific commands added to the firmware
- 0x11c, 0x1f2: No clue
- 0x1dd, 0x205, 0x22d: These seem to trigger some kind of connection-specific, periodic feedback events from the card
- 0x206: HID related thing?
Mostly relevant to us is the 0x057 "set ACL priority" command, as that fixes audio choppiness during BT scans or connection requests. Also the 0x0e2 command that sets the num of buffers to queue before transmitting seems interesting from a latency standpoint.