Advertise Bluetooth LE Service using HCITool

时光总嘲笑我的痴心妄想 提交于 2019-12-05 11:45:04

The length of the the HCI_LE_Set_Advertising_Data payload should be exactly 32 bytes. Try zero padding the command to reach 32 bytes:

hcitool -i hci0 cmd 0x08 0x0008 15 02 01 1a 11 07 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 00 00 00 00 00 00 00 00 00 00

You can gain some more insight using hcidump --raw. Compare the output of the original command:

$hcidump --raw
HCI sniffer - Bluetooth packet analyzer ver 5.30
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< 01 08 20 16 15 02 01 1A 11 07 41 42 43 44 45 46 47 48 49 4A 
  4B 4C 4D 4E 4F 50 
> 04 0E 04 01 08 2

With the zero padded one:

HCI sniffer - Bluetooth packet analyzer ver 5.30
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< 01 08 20 20 15 02 01 1A 11 07 41 42 43 44 45 46 47 48 49 4A 
  4B 4C 4D 4E 4F 50 00 00 00 00 00 00 00 00 00 00 
> 04 0E 04 01 08 20 00 

Another way to gain more insight is to run hciconfig hci0 leadv and use hcidump --raw to examine the payload of the SET_ADVERTISING_PARAMETERS command send by hciconfig.

By the way, I've noticed that sometimes a non zero padded command also works, it might depend on the bluez version you are using.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!