GATTTool无法读取/写入特征 [英] GATTTool fails to read/write characteristics
问题描述
我正在尝试使用bluez的gatttool在BLE定制板上编写一些演示特性.具体来说,我希望写入特征并读出该值.这就是我正在做的事情(其中0x25是特征的句柄):
I'm trying to use bluez's gatttool to write to some demo characteristics on a BLE custom board. Specifically I'm hoping to write to a characteristic and read the value back out. Here's what I'm doing (where 0x25 is the handle for the characteristic):
bluepy$ gatttool -b EC:24:B8:23:1C:39 -I
[ ][EC:24:B8:23:1C:39][LE]> connect
[CON][EC:24:B8:23:1C:39][LE]> char-read-hnd 0x0025
[CON][EC:24:B8:23:1C:39][LE]> Characteristic value/descriptor: 01
[CON][EC:24:B8:23:1C:39][LE]> char-write-cmd 0x25 0x02
[CON][EC:24:B8:23:1C:39][LE]> char-read-hnd 0x0025
[CON][EC:24:B8:23:1C:39][LE]> Characteristic value/descriptor: 00
有人知道为什么读取的特征值是00而不是02(char-write-cmd
的第二个参数)吗?
Does anyone know why the characteristic value read is 00 rather than 02 (second argument of char-write-cmd
)?
任何帮助将不胜感激.
推荐答案
尽管存在BLE的规则和标准,但底层设备可以简单地忽略它们并自己做.因此,它可能会将属性列为可读写状态,并似乎接受新值,但随后会删除这些值.它不应该这样做,但是没有理由不能这样做.
While there are rules and standards for BLE, the underlying device can simply ignore those and do their own thing. So, it's possible that it's listing the attribute as read-write and appearing to accept new values, but then just dropping the values. It shouldn't be doing that, but there's no reason it can't.
但是,您应该确保它实际上发送的是正确的数据,并且问题出在设备上...如注释中所述,gatttool
可能与解释输入有些混乱(新版本比旧版本更好) ),因此请尝试使用02
或2
而不是0x02
.您也可以尝试使用btmon
来检查gatttool
是否确实在发送您想要的值.
However, you should make sure that it's actually sending the right data and the issue is with the device... As mentioned in the comments gatttool
can be a little messed up with interpreting inputs (newer versions are better than older ones), so try 02
or 2
instead of 0x02
. You could also try using btmon
to check that gatttool
is actually sending the value you're intending.
这篇关于GATTTool无法读取/写入特征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!