我正在尝试反向工程一个蓝牙设备,这样我就可以创建我自己的应用程序,可以与它通信。
我已经设法从我的Android手机上获取了蓝牙日志,并且还能够通过网络连接到蓝牙设备。
不幸的是,每当我尝试向特征写入值时,都会得到一个错误:bluetooth.html:1 Uncaught (in promise) DOMException: GATT operation failed for unknown reason.
在Wireshark中,我在写请求中找到的值是:0120030000000000
如何在Javascript中发送此消息?我尝试过以下几种方法,但都不起作用:
characteristic.writeValue(0x0120030000000000)
characteristic.writeValue(new Uint16Array([0x0120030000000000]));
characteristic.writeValue(new Uint8Array([0x0120030000000000]));
characteristic.writeValue(new Uint16Array([0x0120030000000000]));
characteristic.writeValue(new TextEncoder("utf-16").encode(0x0120030000000000));我知道原始值是0120030000000000,如何通过ArrayBuffer发送?
发布于 2020-06-30 12:12:51
假设Wireshark已经将数据编码为十六进制,那么您应该像这样创建一个Uint8Array,
new Uint8Array([0x01, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00])如果在程序中将这些数据表示为字符串比较方便,那么可以编写一个函数,通过一次解析两个字符来构建Uint8Array。
https://stackoverflow.com/questions/62641901
复制相似问题