ble蓝牙
1. 蓝牙发送指令,有的指令能拿到返回,有的指令发出后不能收到仪器返回的数据
解决办法: 使用notify时添加500ms延时
setTimeout(() => {
uni.onBLECharacteristicValueChange(function (res) {
// 结果里有个value值,该值为 ArrayBuffer 类型,所以在控制台无法用肉眼观察到,必须将该值转换为16进制
const resHex = ab2hex(res.value);
// 最后将16进制转换为ascii码,就能看到对应的结果
const result = hexCharCodeToStr(resHex);
});
}, 500);
2.使用安卓指令获取已配对设备是拿不到的
经典蓝牙
1.经典蓝牙uniapp不支持,可以用H5+实现
2.代码之后贴上
开发问题
1.# scroll-view 上下滑动卡顿
解决办法: 设置高度 100%
<scroll-view scroll-y="true" class="scroll-view-item">
.scroll-view-item{
height: 100%;
width: 100%;
}