uub
This commit is contained in:
parent
39a47d3a76
commit
ba0625f368
@ -301,10 +301,15 @@ var blueToothTool = {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
invoke(btSocket, "connect");
|
||||
this.readData(); //读数据
|
||||
this.shortToast("连接成功");
|
||||
callback(true)
|
||||
if(!btSocket.isConnected()) {
|
||||
console.log("检测到设备未连接,尝试连接======")
|
||||
invoke(btSocket, "connect");
|
||||
this.readData(); //读数据
|
||||
}
|
||||
let bl = btSocket.isConnected()
|
||||
console.log("btSocket.isConnected =======", bl)
|
||||
bl && this.shortToast("连接成功")
|
||||
callback(bl)
|
||||
} catch(e) {
|
||||
console.error("connDevice error:========!", e);
|
||||
this.shortToast("连接失败");
|
||||
@ -400,7 +405,7 @@ var blueToothTool = {
|
||||
try {
|
||||
btOutStream.write([0b00]);
|
||||
} catch(e) {
|
||||
console.log("===connExceptionCallback===", e)
|
||||
console.log("===蓝牙连接异常 connExceptionCallback===", e)
|
||||
this.state.readThreadState = false;
|
||||
this.options.connExceptionCallback && this.options.connExceptionCallback(e);
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ export default {
|
||||
},
|
||||
discoveryDeviceCallback: _this.onDiscoverDevice.bind(_this),
|
||||
discoveryFinishedCallback: function() {
|
||||
_this.msg = "搜索完成";
|
||||
// 搜索完成
|
||||
},
|
||||
readDataCallback: function(dataByteArr) {
|
||||
// 读取蓝牙返回的数据
|
||||
@ -150,7 +150,8 @@ export default {
|
||||
_this.receiveDataArr.push.apply(_this.receiveDataArr, dataByteArr); */
|
||||
},
|
||||
connExceptionCallback: function(e) {
|
||||
_this.msg = "设备连接失败";
|
||||
_this.showToast("蓝牙设备连接中断,请检查")
|
||||
// 设备连接失败
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user