蓝牙ctl中读写特性acquire-write操作失败问题排查
为什么bluetoothctl执行acquire-write提示org.bluez.Error.NotSupported?
问题描述
通过bluetoothctl连接智能手表后,确认UUID为6e400002-b5a3-f393-e0a9-e50e24dcca9e的特征具备读写能力,但选中该属性执行acquire-write时,提示:
Failed to acquire write: org.bluez.Error.NotSupported
命令行操作日志
linaro@linaro-alip:~$ bluetoothctl Agent registered [bluetooth]# pair 00:18:80:81:FE:81 Attempting to pair with 00:18:80:81:FE:81 [CHG] Device 00:18:80:81:FE:81 Connected: yes [CHG] Device 00:18:80:81:FE:81 Paired: yes Pairing successful [CHG] Device 00:18:80:81:FE:81 ServicesResolved: yes [Cordio]# menu gatt [Cordio]# list-attributes Primary Service /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020 6e400000-b5a3-f393-e0a9-e50e24dcca9e Vendor specific Characteristic /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0024 6e400002-b5a3-f393-e0a9-e50e24dcca9e Nordic UART TX Characteristic /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0021 6e400001-b5a3-f393-e0a9-e50e24dcca9e Nordic UART Service Descriptor /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0021/desc0023 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration Primary Service /org/bluez/hci0/dev_00_18_80_81_FE_81/service0010 00001801-0000-1000-8000-00805f9b34fb Generic Attribute Profile Characteristic /org/bluez/hci0/dev_00_18_80_81_FE_81/service0010/char0011 00002a05-0000-1000-8000-00805f9b34fb Service Changed Descriptor /org/bluez/hci0/dev_00_18_80_81_FE_81/service0010/char0011/desc0013 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [Cordio]# attribute-info 6e400002-b5a3-f393-e0a9-e50e24dcca9e Characteristic - Nordic UART TX UUID: 6e400002-b5a3-f393-e0a9-e50e24dcca9e Service: /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020 Value: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 .... Flags: read Flags: write [Cordio]# select-attribute 6e400002-b5a3-f393-e0a9-e50e24dcca9e [Cordio:/service0020/char0024]# write 0x55 Attempting to write /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0024 [Cordio:/service0020/char0024]# acquire-write Failed to acquire write: org.bluez.Error.NotSupported [Cordio:/service0020/char0024]# read Attempting to read /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0024 [CHG] Attribute /org/bluez/hci0/dev_00_18_80_81_FE_81/service0020/char0024 Value: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 .... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 ....
原因解析
1. acquire-write的适用条件不满足
acquire-write是BlueZ中用于获取流式写入句柄的命令,仅支持两种场景:
- 特征带有
write-with-responseflag(带响应写入) - 特征支持**可靠写入(Reliable Write)**机制
但从attribute-info的输出可以看到,目标特征仅标注了write flag,这个flag对应无响应写入(Write Without Response),不满足acquire-write的使用要求,因此返回不支持的错误。
2. Nordic UART服务的设计特性
你操作的是Nordic UART服务的TX特征,该服务的设计逻辑是:
- TX特征(
6e400002-...)用于主机向设备发送数据,默认使用无响应写入来提升传输效率,不需要设备返回确认 - 从日志也能验证:直接执行
write 0x55是成功的,说明普通无响应写入功能正常,只是acquire-write对应的机制不被该特征支持
3. 特征flag的明确区分
BLE特征的写入相关flag有明确差异:
write:无响应写入,发送后无需设备确认,适合低延迟批量传输write-with-response:带响应写入,每次写入需设备确认,支持acquire-write的流式操作
你的目标特征只有write flag,没有write-with-response,所以不支持acquire-write命令。
内容的提问来源于stack exchange,提问作者Utku Gökçe
相关产品推荐
相关产品推荐

