【发布时间】:2021-02-17 01:11:39
【问题描述】:
您好,我需要使用 React-native 进行 BLE 集成。
我正在使用这个包:https://polidea.github.io/react-native-ble-plx/
我已经成功搜索了一个 BLE 设备,现在我需要读取它的制造商数据并检查一些值
问题:我正在获取字符串 (Base64) 格式的制造商数据,并使用以下代码转换为字节数组。
convertStringToByteArray(str) {
String.prototype.encodeHex = function () {
var bytes = [];
for (var i = 0; i < this.length; ++i) {
bytes.push(this.charCodeAt(i));
}
return bytes;
};
var byteArray = str.encodeHex();
return byteArray
}
结果如下。
[xx, xx, xx, xx, xx, xx, xx, xx]
我不知道该怎么做。
在 Native iOS 中,我得到 Apple 自己提供的 DATA 格式的输出。这个不知道怎么处理
要求 我需要将该子范围 2..
谁能帮我解析这些数据?
【问题讨论】:
标签: android ios react-native bluetooth bluetooth-lowenergy