低功耗蓝牙第一次连接执行readBLECharacteristicValue后onBLECharacteristicValueChange有数据回调
断开蓝牙再次连接。重新发送readBLECharacteristicValue后onBLECharacteristicValueChange不回调
wx.onBLECharacteristicValueChange(function (res) {
console.log(arrayBufferToString(res.value));
if (res.serviceId === "00660088-0001-0005-0010-F5FB94486B8D") {
if (
res.characteristicId === "00660088-0001-0005-0011-21BAC7B037C4"
) {
deviceInfo.device_name = arrayBufferToString(res.value);
} else if (
res.characteristicId === "00660088-0001-0005-0012-BCECDCCE9A15"
) {
deviceInfo.vendor_code = arrayBufferToString(res.value);
} else if (
res.characteristicId === "00660088-0001-0005-0013-5E6582E384F3"
) {
deviceInfo.serial_code = arrayBufferToString(res.value);
} else if (
res.characteristicId === "00660088-0001-0005-0014-31BD010F80D3"
) {
deviceInfo.hardware_version = arrayBufferToString(res.value);
}
bus.emit("deviceInfo", deviceInfo);
}
});
readCharatorValue(deviceId, serviceId, characteristicId) {
wx.readBLECharacteristicValue({
deviceId,
serviceId,
characteristicId,
success(res) {
console.log(res, "读特征");
},
fail: (e) => {
console.log(e);
},
});
},