uni.createBLEConnection({
deviceId,
success: (res) => {
uni.hideLoading();
uni.showToast({
title: that.i18n.t('connectSuccess'),
icon: 'none'
});
that.getServices(deviceId)
// if (res.errMsg == 'createBLEConnection:ok') {
// } else if (res.errCode == 10012) {
// uni.showToast({
// title: that.i18n.t('connectFail'),
// icon: 'none'
// });
// }
},
fail(error) {
uni.hideLoading();
console.log(error, '连接失败,请重新搜索设备');
uni.navigateBack({
delta: getCurrentPages().length-1 // 返回的页面数
})
if(!error.errMsg.indexOf('already connect')){
that.reConnect(deviceId);
uni.showToast({
title: that.i18n.t('connectFail'),
icon: 'none'
});
}
}
});