加入6107设备页面、蓝牙配对模式修复首次进入找不到设备的问题
This commit is contained in:
@ -46,7 +46,7 @@
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
|
||||
var inteval=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -118,7 +118,7 @@
|
||||
|
||||
onUnload() {
|
||||
console.log("返回取消订阅");
|
||||
|
||||
clearInterval(inteval);
|
||||
ble.removeAllCallback(pagePath);
|
||||
},
|
||||
onLoad(option) {
|
||||
@ -226,7 +226,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
let inteval = setInterval(this.initDevice, 10000);
|
||||
inteval = setInterval(this.initDevice, 10000);
|
||||
}
|
||||
|
||||
|
||||
@ -291,6 +291,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
clearInterval(inteval);
|
||||
} else {
|
||||
deviceInvalid();
|
||||
}
|
||||
|
||||
@ -120,6 +120,7 @@
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var searchTime=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -334,7 +335,7 @@
|
||||
|
||||
//搜索到新设备的回调 (Always active)
|
||||
ble.addDeviceFound((arr) => {
|
||||
console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
|
||||
// console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
@ -343,7 +344,7 @@
|
||||
}
|
||||
arr = arr.devices;
|
||||
|
||||
console.log(`本次扫描批次发现 ${arr.length} 个设备`);
|
||||
// console.log(`本次扫描批次发现 ${arr.length} 个设备`);
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let device = arr[i];
|
||||
@ -351,9 +352,9 @@
|
||||
|
||||
let f = these.EquipMents.find((v, index) => {
|
||||
if (v.deviceId == device.deviceId) {
|
||||
console.log(
|
||||
`更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
|
||||
);
|
||||
// console.log(
|
||||
// `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
|
||||
// );
|
||||
these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
|
||||
return true;
|
||||
}
|
||||
@ -361,7 +362,7 @@
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
|
||||
// console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
|
||||
|
||||
if (these.device && these.device.bluetoothName && device.name) {
|
||||
if (these.device.bluetoothName === device.name || (device.name && device.name
|
||||
@ -417,27 +418,29 @@
|
||||
|
||||
//收到设备的消息回调
|
||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||
console.log("000000");
|
||||
console.log("000000",receivData);
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
console.log("1111111");
|
||||
if (f.macAddress && these.device) {
|
||||
console.log("222222");
|
||||
clearInterval(this.Status.intval);
|
||||
this.Status.intval = null;
|
||||
this.Status.time = null;
|
||||
if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
|
||||
|| (receivData.hexs[0]===0xFC && receivData.hexs.length>=7))
|
||||
{
|
||||
console.log("1111111");
|
||||
if (f.macAddress && these.device) {
|
||||
console.log("222222");
|
||||
clearInterval(this.Status.intval);
|
||||
this.Status.intval = null;
|
||||
this.Status.time = null;
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在验证设备'
|
||||
});
|
||||
showLoading(these, {
|
||||
text: '正在验证设备'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
these.DeviceVerdict(f.deviceId);
|
||||
}, 0);
|
||||
setTimeout(() => {
|
||||
these.DeviceVerdict(f.deviceId);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, pagePath);
|
||||
}
|
||||
}
|
||||
@ -452,7 +455,7 @@
|
||||
}
|
||||
|
||||
startValidDevice();
|
||||
these.refreshBleList();
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
@ -502,6 +505,8 @@
|
||||
});
|
||||
},
|
||||
async refreshBleList() {
|
||||
|
||||
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.uniPlatform == 'web') {
|
||||
return;
|
||||
@ -520,37 +525,42 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ble.StopSearch().finally(() => {
|
||||
|
||||
let disconnectPromises = [];
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
ble.data.LinkedList.forEach(device => {
|
||||
console.log(`Requesting disconnect for ${device.deviceId}`);
|
||||
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
|
||||
});
|
||||
}
|
||||
|
||||
Promise.allSettled(disconnectPromises).finally(() => {
|
||||
|
||||
these.EquipMents = [];
|
||||
these.PairEquip = [];
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
console.log("Fresh scan started successfully.");
|
||||
}).catch(err => {
|
||||
console.error("Failed to start fresh scan:", err);
|
||||
if (err.code === 10001) {
|
||||
these.showOpenSetting();
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '开始搜索失败:' + err.msg
|
||||
});
|
||||
}
|
||||
clearTimeout(searchTime);
|
||||
searchTime=setTimeout(()=>{
|
||||
|
||||
ble.StopSearch().finally(() => {
|
||||
|
||||
let disconnectPromises = [];
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
ble.data.LinkedList.forEach(device => {
|
||||
console.log(`Requesting disconnect for ${device.deviceId}`);
|
||||
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
|
||||
});
|
||||
}
|
||||
|
||||
Promise.allSettled(disconnectPromises).finally(() => {
|
||||
|
||||
these.EquipMents = [];
|
||||
these.PairEquip = [];
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
console.log("Fresh scan started successfully.");
|
||||
}).catch(err => {
|
||||
console.error("Failed to start fresh scan:", err);
|
||||
if (err.code === 10001) {
|
||||
these.showOpenSetting();
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '开始搜索失败:' + err.msg
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
},800);
|
||||
|
||||
},
|
||||
isItemLink: function(item, index) {
|
||||
let src = '/static/images/BLEAdd/noLink.png';
|
||||
@ -599,8 +609,6 @@
|
||||
if (index > -1) {
|
||||
this.PairEquip.splice(index, 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log("f=", f);
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<view class="vehicle-list" v-if="vehicles.length>0">
|
||||
<view v-for="(item, index) in vehicles" :key="index">
|
||||
<view class="vehicle-item" @click="alltypeInfo(item)">
|
||||
<image src="/static/images/common/bip.6.png" mode="" class="IMG"></image>
|
||||
<image :src="item.img" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="plate-number">{{ item.typeName }}</view>
|
||||
</view>
|
||||
@ -25,13 +25,88 @@
|
||||
data() {
|
||||
return {
|
||||
vehicles: [],
|
||||
typeImgs: [{
|
||||
"Name": "HBY018A",
|
||||
"sigName": "018A",
|
||||
"url": "/static/images/common/018A.png"
|
||||
},
|
||||
{
|
||||
"Name": "HBY102",
|
||||
"sigName": "102",
|
||||
"url": "/static/images/common/HBY102.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ6075",
|
||||
"sigName": "6075",
|
||||
"url": "/static/images/common/BJQ6075.png"
|
||||
},
|
||||
{
|
||||
"Name": "HBY100",
|
||||
"sigName": "100",
|
||||
"url": "/static/images/common/HBY100J.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ4877",
|
||||
"sigName": "4877",
|
||||
"url": "/static/images/common/BJQ4877.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ7307",
|
||||
"sigName": "7307",
|
||||
"url": "/static/images/common/7307.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ7305",
|
||||
"sigName": "7305",
|
||||
"url": "/static/images/common/7305.png"
|
||||
},
|
||||
{
|
||||
"Name": "HBY650",
|
||||
"sigName": "650",
|
||||
"url": "/static/images/common/HBY650.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ6155",
|
||||
"sigName": "6155",
|
||||
"url": "/static/images/common/HBY6155.png"
|
||||
},
|
||||
{
|
||||
"Name": "HBY670",
|
||||
"sigName": "670",
|
||||
"url": "/static/images/common/HBY670.png"
|
||||
},
|
||||
{
|
||||
"Name": "HBY210",
|
||||
"sigName": "210",
|
||||
"url": "/static/images/common/210.png"
|
||||
},
|
||||
{
|
||||
"Name": "BJQ6170",
|
||||
"sigName": "6170",
|
||||
"url": "/static/images/common/bip.6.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.vehicles = res.data
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
var item = res.data[i];
|
||||
|
||||
item.img="/static/images/common/bip.6.png";
|
||||
let f=this.typeImgs.find(v=>{
|
||||
if(item.typeName.toLowerCase()===v.Name.toLowerCase()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if(f){
|
||||
item.img=f.url;
|
||||
}
|
||||
}
|
||||
this.vehicles = res.data;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user