I think I figured it out.
Instead of:
sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hciconfig hci0 leadv 3
Do this:
sudo hciconfig hci0 up
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00
sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 03 00 00 00 00 00 00 00 00 07 00
sudo hcitool -i hci0 cmd 0x08 0x000a 01
The second hcitool command (0x08 0x0006) is "LE Set Advertising Parameters. The first two bytes A0 00 are the "min interval". The second two bytes A0 00 are the "max interval". In this example, it sets the time between advertisements to 100ms. The granularity of this setting is 0.625ms, so setting the interval to 01 00 sets the advertisement to go every 0.625ms. Setting it to A0 00 sets the advertisement to go every 0xA0*0.625ms = 100ms. Setting it to 40 06 sets the advertisement to go every 0x0640*0.625ms = 1000ms. The fifth byte, 03, sets the advertising mode to non-connectable. With a non-connectable advertisement, the fastest you can advertise is 100ms, with a connectable advertisment (0x00) you can advertise much faster.
The third hcitool command (0x08 0x000a) is "LE Set Advertise Enable". It is necessary to issue this command with hcitool instead of hciconfig, because "hciconfig hci0 leadv 3" will automatically set the advertising rate to the slower default of 1280ms.
I figured this out by running hcidump at the same time as running the original commands you posted in the question. This shows you a bunch of raw hcitool commands (nicely annotated for what they do) that get executed by bluez. I just happened to notice from the hcidump output that "hciconfig hci0 leadv 3" issues its a slower set advertising interval command.
Note that all of this is based on the IOGear GBU521, so this may not work with other Bluetooth LE chipsets.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…