|
@@ -160,18 +160,22 @@ Page({
|
|
|
BtHelper.getInstance().startScan(null, null, function (res) {});
|
|
|
var isFirst = true;
|
|
|
console.log("开始监听蓝牙设备");
|
|
|
- that.startBleTimer(isFirst);
|
|
|
+ that.startBleTimer(isFirst, true);
|
|
|
that.addNotification()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- startBleTimer(isFirst) {
|
|
|
+ startBleTimer(isFirst, openTimer) {
|
|
|
let that = this;
|
|
|
let deviceList = that.getDeviceList()
|
|
|
+ let findBle = deviceList.find(item => {
|
|
|
+ return (item.connectType === 1 && item.state === "online")
|
|
|
+ })
|
|
|
let findWifi = deviceList.find(item => {
|
|
|
- return item.connectType != 1
|
|
|
+ return (item.connectType === 3 && item.state === "online")
|
|
|
})
|
|
|
- if (findWifi) {
|
|
|
+ if (!openTimer && (findBle || findWifi)) {
|
|
|
+ // 强制开启监听 && (有蓝牙在线 || 有wifi在线)就return
|
|
|
return;
|
|
|
}
|
|
|
///再秒再对比一次
|
|
@@ -185,7 +189,7 @@ Page({
|
|
|
if (isFirst) {
|
|
|
that.stopIntervalId1();
|
|
|
var newIsFirst = false
|
|
|
- that.startBleTimer(newIsFirst);
|
|
|
+ that.startBleTimer(newIsFirst, true);
|
|
|
}
|
|
|
// } else {
|
|
|
// count++;
|
|
@@ -199,6 +203,7 @@ Page({
|
|
|
let that = this;
|
|
|
constant.lexinScan.compareList2(that.data.deviceList, function (device) {
|
|
|
if (device) {
|
|
|
+ console.log("找到蓝牙了");
|
|
|
that.data._willConnectBle = device;
|
|
|
getApp().getBluetoothStatus();
|
|
|
}
|
|
@@ -788,7 +793,7 @@ Page({
|
|
|
constant.eventBus.removeNotification(CmdEvent.eventName, that);
|
|
|
constant.eventBus.addNotification(CmdEvent.eventName, function (event) {
|
|
|
let deviceList = that.getDeviceList()
|
|
|
-
|
|
|
+ // console.log("收到监听:", JSON.stringify(event))
|
|
|
if (event.cmdEvent == EnumCmdEvent.btMac) {
|
|
|
let disDevice = deviceList.find(item => {
|
|
|
return item.state == "online" && item.connectType === 1
|
|
@@ -809,7 +814,8 @@ Page({
|
|
|
return item.state == "online" && item.connectType === 3
|
|
|
})
|
|
|
if (!wifiDevice) {
|
|
|
- that.startBleTimer(isFirst);
|
|
|
+ console.log("开启蓝牙监听:", event.deviceId, event.commonValue)
|
|
|
+ that.startBleTimer(isFirst, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -827,7 +833,8 @@ Page({
|
|
|
// }
|
|
|
// });
|
|
|
if (!disDevice) {
|
|
|
- console.log("没有找到在线的对应的蓝牙设备")
|
|
|
+ // console.log("")
|
|
|
+ console.log("没有找到在线的对应的蓝牙设备", JSON.stringify(deviceList))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -918,6 +925,7 @@ Page({
|
|
|
var param = "?param=" + item.forwardUrl;
|
|
|
console.log("gadfeqreqrqr==111==" + param);
|
|
|
constant.routeUtil.jumpParam(constant.routePath.webview, param);
|
|
|
+ //
|
|
|
}
|
|
|
// 外链
|
|
|
else if (item.forwardType == 1) {
|