Linux 如何写入Bluez 5.48之后的特性

Linux 如何写入Bluez 5.48之后的特性,linux,bluetooth-lowenergy,bluez,Linux,Bluetooth Lowenergy,Bluez,我使用的是Bluez5.50;5.48是否正式(非实验性)支持acquire write版本。我是否正确使用acquire写入/写入功能 在我的树莓皮零W上: pi@raspberrypi:~ $ bluetoothctl [bluetooth]# power on Changing power on succeeded [bluetooth]# scan on Discovery started [bluetooth]# connect B8:27:E8:72:33:7A Attempting

我使用的是Bluez5.50;5.48是否正式(非实验性)支持acquire write版本。我是否正确使用acquire写入/写入功能

在我的树莓皮零W上:

pi@raspberrypi:~ $ bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[bluetooth]# connect B8:27:E8:72:33:7A
Attempting to connect to B8:27:E8:72:33:7A
Connection successful
[DSD TECH]# menu gatt
[DSD TECH]# select-attribute 0000ffe1-0000-1000-8000-00805f9b34fb
[DSD TECH:/service0010/char0011]# acquire-write
[CHG] Attribute /org/bluez/hci0/dev_B8_27_E8_72_33_7A/service0010/char0011 WriteAcquired: yes
AcquireWrite success: fd 7 MTU 23
[DSD TECH:/service0010/char0011]# write("h")
[DSD TECH:/service0010/char0011]# write('h')
[DSD TECH:/service0010/char0011]# write(h)
[DSD TECH:/service0010/char0011]# write(0x68)
在连接HM-10的Arduino Nano上:

void setup() 
{
  Serial.begin(9600);
}

void loop() {
  delay(10);
  if (Serial.available())
  {
    char c = Serial.read();
    Serial.println("Read value");
  }
}
我使用名为“Serial”的iOS应用程序连接到我的HM-10。我将字母h发送过来,并在arduino串行监视器上读取“读取值”。我在使用raspberry pi之前和之后,在同一个arduino串行监视器上直接执行此操作。覆盆子派的通知从来没有通过。是的,我确信它和HM-10是一样的。这是我在BLE范围内唯一通电的HM-10,当我的手机连接时,我无法连接到UUID。(实际上,我提交了
将B8:27:E8:72:33:7A连接到raspberry pi,并不断尝试,然后断开与手机的连接,rpi自动连接)


提前谢谢

将gatt服务与bluetoothctl一起使用时,请不要使用括号,只需使用:

write 0x68

获取写入返回可用于写入GATT特性的文件描述符,写入的使用将被锁定。因此,要么使用acquire write(需要一个没有响应标志的写入),要么使用write

            void WriteValue(array{byte} value, dict options)

                    Issues a request to write the value of the
                    characteristic.

                    Possible options: "offset": Start offset
                                      "device": Device path (Server only)
                                      "link": Link type (Server only)
                                      "prepare-authorize": boolean Is prepare
                                                           authorization
                                                           request

                    Possible Errors: org.bluez.Error.Failed
                                     org.bluez.Error.InProgress
                                     org.bluez.Error.NotPermitted
                                     org.bluez.Error.InvalidValueLength
                                     org.bluez.Error.NotAuthorized
                                     org.bluez.Error.NotSupported

            fd, uint16 AcquireWrite(dict options) [optional]

                    Acquire file descriptor and MTU for writing. Usage of
                    WriteValue will be locked causing it to return
                    NotPermitted error.

                    For server the MTU returned shall be equal or smaller
                    than the negotiated MTU.

                    For client it only works with characteristic that has
                    WriteAcquired property which relies on
                    write-without-response Flag.

                    To release the lock the client shall close the file
                    descriptor, a HUP is generated in case the device
                    is disconnected.

                    Note: the MTU can only be negotiated once and is
                    symmetric therefore this method may be delayed in
                    order to have the exchange MTU completed, because of
                    that the file descriptor is closed during
                    reconnections as the MTU has to be renegotiated.

                    Possible options: "device": Object Device (Server only)
                                      "MTU": Exchanged MTU (Server only)
                                      "link": Link type (Server only)

                    Possible Errors: org.bluez.Error.Failed
                                     org.bluez.Error.NotSupported

谢谢我将在几个月内回到这个项目,看看这是否有帮助(或者如果我遇到更多问题),如果你想写更多的字节,那么使用引号。例如,写入“0x68 0xab 0x01”