【发布时间】:2023-01-31 00:41:10
【问题描述】:
我正在尝试与蓝牙 LE 设备通信,但被告知我需要先“验证”才能读取/写入数据。硬件开发人员告诉我设备向接收者发送了一个密钥,我需要回复 12000000000000000000000000。他已经使用 NRF Connect 桌面应用程序成功测试了这一点(但我需要在本机反应中复制它)。
我尝试使用以下代码在连接到设备后立即将 12000000000000000000000000(转换为 base64)发送到设备的通知特征:
const Buffer = require("buffer").Buffer;
const loginString = "12000000000000000000000000";
const hexToBase64 = Buffer.from(loginString).toString("base64");
characteristics[0].writeWithResponse(hexToBase64).then(()=>...)
但是,即使代码正确执行(没有捕获错误),我仍然收到 "GATT exception from MAC address C7:7A:16:6B:1F:56, with type BleGattOperation{description='CHARACTERISTIC_WRITE'}"。
我查看了 react-native-ble-plx 文档,但仍然没有找到解决我的问题的方法,我们将不胜感激!
【问题讨论】:
标签: react-native bluetooth-lowenergy react-native-ble-plx