【问题标题】:Linux BlueZ custom Manufacturing Scan Response DataLinux BlueZ 定制制造扫描响应数据
【发布时间】:2017-09-26 16:44:58
【问题描述】:

我有一个在 Linux 上使用 BlueZ 4.101 作为插件的自定义 GATT 服务器。我现在正在尝试设置自定义扫描响应广告数据。我在 iOS 上使用 LightBlue 来调试我的 GATT 服务器和广告参数。我尝试了以下代码,LightBlue 可以看到广告负载和设备名称,但看不到扫描响应数据。如何使用 BlueZ 设置自定义扫描响应数据?谢谢。

# 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

【问题讨论】:

  • 您想在扫描数据中包含什么?您当前的扫描响应数据对我没有任何意义。
  • 真的只是一些我可以设计扫描响应接口的自定义字节。问题是,当我使用带有内部堆栈的 BLE112 Bluegiga 加密狗时,LightBlue 会看到广告数据和扫描响应自定义数据(因为该加密狗有自己的内部堆栈)和一个命令 - 但是当我尝试执行相同的扫描响应时BlueZ 中的数据如上图,LightBlue 什么都看不到
  • 你有设置扫描响应数据的例子吗?谢谢。
  • iOS 会解析它,因此需要您将其设置为有效的值。如果您将其设置为 02 09 41(如果您使用原始 hcitool,则将该 03 作为长度添加),这意味着您将名称设置为“A”。 02=以下项目的长度,包括类型,09=完整名称,41='A'。

标签: linux bluetooth bluez


【解决方案1】:

您设置发现响应的命令没有任何意义。这是一个例子:

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"

请注意,如果您的设备无法连接,这将不起作用。

【讨论】:

    猜你喜欢
    • 2020-06-04
    • 2021-09-02
    • 1970-01-01
    • 2018-04-17
    • 1970-01-01
    • 2021-06-02
    • 2016-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多