Bluetooth 非交互模式下的gatttool特性写入

Bluetooth 非交互模式下的gatttool特性写入,bluetooth,bluetooth-lowenergy,gatttool,Bluetooth,Bluetooth Lowenergy,Gatttool,我想在shell脚本中使用gatttool 我想要达到的目标与以下类似: 在交互模式下,我可以执行以下操作: # gatttool -b xx:xx:xx:xx:xx:xx -I [xx:xx:xx:xx:xx:xx][LE]> connect Attempting to connect to xx:xx:xx:xx:xx:xx Connection successful [xx:xx:xx:xx:xx:xx][LE]> char-write-cmd 0x0025 aabbcc No

我想在shell脚本中使用gatttool

我想要达到的目标与以下类似:

在交互模式下,我可以执行以下操作:

# gatttool -b xx:xx:xx:xx:xx:xx -I
[xx:xx:xx:xx:xx:xx][LE]> connect
Attempting to connect to xx:xx:xx:xx:xx:xx
Connection successful
[xx:xx:xx:xx:xx:xx][LE]> char-write-cmd 0x0025 aabbcc
Notification handle = 0x0025 value: aa bb cc
现在,如果我以非交互方式运行:

# gatttool -b xx:xx:xx:xx:xx:xx --char-write --handle=0x0025 --value=aabbcc
它只是挂起,我需要用CTRL+C将其断开,并且不向设备发送任何内容

现在,以上所有问题都建议使用-char write req而不是-char write

但这是误导,因为请求和命令意味着不同的东西

我的设备不接受请求,即使在交互模式下也只接受命令!。因此,尝试通过请求发送相同的数据将失败:

# gatttool -b xx:xx:xx:xx:xx:xx -I
[xx:xx:xx:xx:xx:xx][LE]> connect
Attempting to connect to xx:xx:xx:xx:xx:xx
Connection successful
[xx:xx:xx:xx:xx:xx][LE]> char-write-req 0x0025 aabbcc
Error: Characteristic Write Request failed: Attribute can't be written
# gatttool -b xx:xx:xx:xx:xx:xx --char-write-req --handle=0x0025 --value=aabbcc
Characteristic Write Request failed: Attribute can't be written
当然,现在使用上述问题的建议-char write req将失败:

# gatttool -b xx:xx:xx:xx:xx:xx -I
[xx:xx:xx:xx:xx:xx][LE]> connect
Attempting to connect to xx:xx:xx:xx:xx:xx
Connection successful
[xx:xx:xx:xx:xx:xx][LE]> char-write-req 0x0025 aabbcc
Error: Characteristic Write Request failed: Attribute can't be written
# gatttool -b xx:xx:xx:xx:xx:xx --char-write-req --handle=0x0025 --value=aabbcc
Characteristic Write Request failed: Attribute can't be written
那么,编写一个特征命令的非交互式替代方案是什么,
如果我不想为此使用任何Python或类似的技巧?

当然,一种方法是使用expect。当然,一种方法是使用expect。