Linux BlueZ 自定义制造扫描响应数据

标签 linux bluetooth bluez

我有一个自定义 GATT 服务器,作为插件在 Linux 上使用 BlueZ 4.101。我现在正在尝试设置自定义扫描响应广告数据。我在 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

最佳答案

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

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"

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

关于Linux BlueZ 自定义制造扫描响应数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46431843/

相关文章:

python - 通过 Cron 作业的音频

c - 无法使用 C 中 API 库 header 中定义的结构

linux - 将 awk,sed 输出设置为 Bash 中的变量

linux - Git 检索在分支中修改的所有文件的列表

linux - 为什么 ARP 请求非本地地址?

java - 没有输入流数据到达事件?

linux - 基于虚拟盒的嵌入式 Linux 开发

android - 如何使用蓝牙找到范围内的设备?

security - 低功耗蓝牙 GATT 安全级别

audio - ofono的DBUS无法与PulseAudio通信