问题描述
我有一个自定义的GATT服务器,在Linux上使用BlueZ 4.101作为插件工作.我现在正在尝试设置自定义扫描响应广告数据.我在iOS上使用LightBlue调试我的GATT服务器和广告参数.我尝试了以下代码,LightBlue可以看到广告有效负载和设备名称,但看不到扫描响应"数据.如何使用BlueZ设置自定义扫描响应数据?谢谢.
I have a custom GATT Server working as a plugin using BlueZ 4.101 on Linux. I am now trying to set custom Scan Response advertising data. I am using LightBlue on iOS to debug my GATT Server and advertising parameters. I tried the following code, and LightBlue can see the Advertising Payload and Device Name, but not the Scan Response data. How do I set custom Scan Response data with BlueZ? Thanks.
# BLE Name
echo "<GATT SERVER> Setting BLE Advertising Name..."
btmgmt -i $BLUETOOTH_DEVICE name "My-Test-Device"
echo "<GATT SERVER> Starting BLE Advertising..."
hciconfig $BLUETOOTH_DEVICE leadv
# Adv Packet
echo "<GATT SERVER> Setting BLE Advertising Packets..."
hcitool -i hci0 cmd 0x08 0x0008 15 02 01 06 11 06 fa d8 43 31 14 09 0c ba e1 14 82 25 11 48 96 16
# | | | | | | -----------------------------------------------
# | | | | | | |
# | | | | | | +---- device state service UUID
# | | | | | |
# | | | | | +- Incomplete List of 128-bit Service Class UUIDs
# | | | | |
# | | | | +- Num bytes in -----------------------------------+
# | | | |
# | | | +- LE General Discoverable Mode, BR/EDR
# | | |
# | | +- Flags AD type
# | |
# | +nBytes+
# |
# +- Num bytes in -----------------------------------------------+
# Scan Response
echo "<GATT SERVER> Setting BLE Scan Response..."
hcitool -i hci0 cmd 0x08 0x0009 02 01 06 1A FF 02 5E 03 02 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
推荐答案
您用于设置发现响应的命令没有任何意义.这是一个例子:
Your command to set discovery response does not make any sense. Here is an exemple :
hcitool -i hci0 cmd 0x08 0x0009 14 13 09 74 68 65 20 70 69
hcitool -i hci0 cmd 0x08 0x0009 : set discovery response
14 : total payload length
13 : info payload length
09 : info type == name
74 68 65 20 70 69 : info payload => the name in ascii. here "the pi"
请注意,如果您的设备不可连接,则此操作将无效.
Please note that this won't work if you device is not connectable.
这篇关于Linux BlueZ自定义制造扫描响应数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!