我很难弄清楚如何将我的蓝牙命令(从Gatttool)转换为Bluez c代码。
你能帮我把下面的Gatttool命令(蓝牙请求)翻译成c吗?
CONLE> char写-req 0x00c0100
所以我的句柄是0x00c0,我的数据是0100 (on)。我不知道我需要填充哪些hci_request结构属性(除了句柄)。
... I've successfully connected to the device (LE connection)
struct hci_request rq = {0};
rq.ogf = ??; // should the handle go here?
rq.ocf = ??; // should the data go here
rq.cparam = ??;
rq.clen = ??;
rq.rparam = ??;
rq.rlen = ??;
rq.event = ??; // what would the event be?
hci_send_req(dd, &rq, 1000);发布于 2016-07-25 06:01:28
为什么不使用标准的bluez gatt命令呢?
void WriteValue(array{byte} value, dict options) 但是把HCI命令自己结合起来?
但是,如果您确实希望组合HCI命令(这意味着您跳过GATT/ATT/L2CAP级别),格式是“hci.h数据包”,在hci.h at BlueZ:连接句柄中定义为“hci.h数据包”。包_边界_标志:00/01/10或11取决于您的L2cap包类型。Broadcast_Flag:基本上是0x00,即没有广播的Data_Total_Length:包的长度。然后包需要包括L2CAP PDU长度和通道ID(作为ATT协议应该是0x0004 ),然后附加ATT类型、操作码(写命令) att句柄和数据。
https://stackoverflow.com/questions/38537867
复制相似问题