简体   繁体   English

无法在 Bluetoothctl 中为读/写特性工作获取写入

[英]Not working acquire-write for Read/Write characteristic in Bluetoothctl

I connected to smart watch via bluetoothctl.我通过 bluetoothctl 连接到智能手表。 I listed all attribute.我列出了所有属性。 Then got info for target UUID (6e400002-b5a3-f393-e0a9-e50e24dcca9e).然后获取目标 UUID 的信息(6e400002-b5a3-f393-e0a9-e50e24dcca9e)。 I saw it has both read and write capability (Read/Write).我看到它具有读写能力(读/写)。 I selected attribute with "select-attribute" command.我用“select-attribute”命令选择了属性。 But I got failed to acquire write: org.bluez.Error.NotSupported.但我未能获得写入:org.bluez.Error.NotSupported。

Why cannot I do it?为什么我不能这样做?

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                                      ....            
      

Your log looks a little strange.你的日志看起来有点奇怪。 According to the UART/Serial Port Emulation over BLE specification the characteristic ./service0020/char0024 aka UUID 6e400002-b5a3-f393-e0a9-e50e24dcca9e is the RX Characteristic which is write only .根据UART/Serial Port Emulation over BLE 规范,特性./service0020/char0024 aka UUID 6e400002-b5a3-f393-e0a9-e50e24dcca9e是 RX 特性,它是只写的。

In any case, the data from your log does not match the information documented in Nordics specification.无论如何,您日志中的数据与北欧规范中记录的信息不匹配。

It doesn't work with a 'write' flag, only 'write-without-response' is supported.它不适用于 'write' 标志,仅支持 'write-without-response'。

From documentation: For client it only works with characteristic that has WriteAcquired property which relies on write-without-response Flag.来自文档:对于客户端,它仅适用于具有 WriteAcquired 属性的特征,该属性依赖于 write-without-response 标志。

I am solved the problem,我解决了问题,

Firstly, I thought the write command wasn't working because I couldn't get a response (raw datas), but it was working.首先,我认为 write 命令不起作用,因为我无法得到响应(原始数据),但它正在工作。

Because when the other UUID (6e400001-b5a3-f393-e0a9-e50e24dcca9e) is set to 'notify' (acquire-notify), the raw data started to come from the smart watch.因为当另一个UUID(6e400001-b5a3-f393-e0a9-e50e24dcca9e)设置为'notify'(获取-通知)时,原始数据开始来自智能手表。

Thank you everyone for your answer.谢谢大家的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM