createBLEConnection() {
//设备deviceId
let deviceId = this.deviceId;
let self = this;
uni.showLoading({
mask: true,
title: '设别连接中,请稍候...'
})
console.log(this.deviceId);
return new Promise((resolve, reject) => {
uni.createBLEConnection({
deviceId,
success: (res) => {
console.log("res:createBLEConnection " + JSON.stringify(res));
uni.hideLoading();
resolve(res)
},
fail: err => {
uni.hideLoading();
self.showToast(`停止搜索蓝牙设备失败` + JSON.stringify(err));
reject(err);
},
complete: () => {
console.log(11111)
uni.onBLEConnectionStateChange(function (res) {
// 该方法回调中可以用于处理连接意外断开等异常情况
console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
})
uni.hideLoading();
}
})
});
}
一直没有回调 也没报错
huanHUAN111 (作者)
要安卓版本有关,安卓4.4不行,安卓10可以
2021-11-10 12:05