Compare commits
7 Commits
b20a93dd28
...
0909d9f023
| Author | SHA1 | Date | |
|---|---|---|---|
| 0909d9f023 | |||
| 1d8b3b4a9a | |||
| a5c6faa9da | |||
| 15ba241317 | |||
| fa64e7f1fc | |||
| 45328120c1 | |||
| 0033649677 |
@ -156,7 +156,7 @@
|
|||||||
updateLoading
|
updateLoading
|
||||||
} from '@/utils/loading.js'
|
} from '@/utils/loading.js'
|
||||||
import BleReceive from '@/utils/BleReceive';
|
import BleReceive from '@/utils/BleReceive';
|
||||||
var pagePath = "pages/6155/HBY6155";
|
var pagePath = "/pages/6155/HBY6155";
|
||||||
|
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
@ -514,11 +514,11 @@
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) {
|
bleValueNotify: function(receive, device, path,recArr) {
|
||||||
if (this.Status.pageHide) {
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let json = recei.ReceiveData(receive, device, path);
|
let json = recei.ReceiveData(receive, device, path,recArr);
|
||||||
if (!json) {
|
if (!json) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,7 +183,7 @@
|
|||||||
} from '../../utils/request';
|
} from '../../utils/request';
|
||||||
|
|
||||||
import usrApi from '@/api/670/HBY670.js'
|
import usrApi from '@/api/670/HBY670.js'
|
||||||
const pagePath = "pages/650/HBY650";
|
const pagePath = "/pages/650/HBY650";
|
||||||
|
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
@ -490,9 +490,9 @@
|
|||||||
|
|
||||||
return className;
|
return className;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path,recArr) { //订阅消息
|
||||||
console.log("收到设备的数据", receive)
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath);
|
let data = recei.ReceiveData(receive, device, pagePath,recArr);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if ("staBlue_picture" in data) {
|
if ("staBlue_picture" in data) {
|
||||||
|
|||||||
@ -289,7 +289,7 @@
|
|||||||
} from '../../utils/request';
|
} from '../../utils/request';
|
||||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
|
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
|
||||||
|
|
||||||
const pagePath = "pages/670/HBY670";
|
const pagePath = "/pages/670/HBY670";
|
||||||
var ble = null;
|
var ble = null;
|
||||||
var these = null;
|
var these = null;
|
||||||
var recei = null;
|
var recei = null;
|
||||||
@ -982,9 +982,9 @@
|
|||||||
this.refreshFormData(receiveData, 'auto');
|
this.refreshFormData(receiveData, 'auto');
|
||||||
return receiveData;
|
return receiveData;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path,recArr) { //订阅消息
|
||||||
|
|
||||||
let data = recei.ReceiveData(receive, device, pagePath);
|
let data = recei.ReceiveData(receive, device, pagePath,recArr);
|
||||||
console.log("收到设备的数据", data)
|
console.log("收到设备的数据", data)
|
||||||
if (data) {
|
if (data) {
|
||||||
if ("staBlue_picture" in data) {
|
if ("staBlue_picture" in data) {
|
||||||
|
|||||||
@ -87,21 +87,23 @@
|
|||||||
<text class="usrtitle fleft">人员信息登记</text>
|
<text class="usrtitle fleft">人员信息登记</text>
|
||||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||||
<view class="clear"></view>
|
<view class="clear"></view>
|
||||||
<textToDotMatrixFor7305 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
<textToDotMatrixFor7305 class="TextToHex" ref="textToHex" :txts="formData.textLines"
|
||||||
:color="'#000000'" :fontSize="11" />
|
:bgColor="'#FFFFFF'" :color="'#000000'" :fontSize="11" / </view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">单位:</text>
|
<text class="lbl">单位:</text>
|
||||||
<input class="value" v-model="formData.textLines[0]" placeholder="请输入单位" placeholder-class="usrplace" />
|
<input class="value" v-model="formData.textLines[0]" placeholder="请输入单位"
|
||||||
|
placeholder-class="usrplace" />
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">部门:</text>
|
<text class="lbl">部门:</text>
|
||||||
<input class="value" v-model="formData.textLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" />
|
<input class="value" v-model="formData.textLines[1]" placeholder="请输入姓名"
|
||||||
|
placeholder-class="usrplace" />
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">姓名:</text>
|
<text class="lbl">姓名:</text>
|
||||||
<input class="value" v-model="formData.textLines[2]" placeholder="请输入职位" placeholder-class="usrplace" />
|
<input class="value" v-model="formData.textLines[2]" placeholder="请输入职位"
|
||||||
|
placeholder-class="usrplace" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@ -162,7 +164,7 @@
|
|||||||
var these = null;
|
var these = null;
|
||||||
var BrighInteval = null;
|
var BrighInteval = null;
|
||||||
var recei = null;
|
var recei = null;
|
||||||
var pagePath = "pages/7305/BJQ7305";
|
var pagePath = "/pages/7305/BJQ7305";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
textToDotMatrixFor7305
|
textToDotMatrixFor7305
|
||||||
@ -465,12 +467,12 @@
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) {
|
bleValueNotify: function(receive, device, path, recArr) {
|
||||||
|
|
||||||
if (this.Status.pageHide) {
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let json = recei.ReceiveData(receive, device, path);
|
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||||
|
|
||||||
if (!json) {
|
if (!json) {
|
||||||
return;
|
return;
|
||||||
@ -580,7 +582,9 @@
|
|||||||
imageData.push(0x00);
|
imageData.push(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullPacket = new Uint8Array([...header, ...imageData.slice(0, 1024), ...footer]);
|
const fullPacket = new Uint8Array([...header, ...imageData.slice(0, 1024), ...
|
||||||
|
footer
|
||||||
|
]);
|
||||||
const fullBuffer = fullPacket.buffer;
|
const fullBuffer = fullPacket.buffer;
|
||||||
|
|
||||||
// 2. 将完整数据包切片成20字节的小块进行发送
|
// 2. 将完整数据包切片成20字节的小块进行发送
|
||||||
@ -608,14 +612,17 @@
|
|||||||
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
||||||
const chunk = fullBuffer.slice(start, end);
|
const chunk = fullBuffer.slice(start, end);
|
||||||
|
|
||||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(16).padStart(2, '0'));
|
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(
|
||||||
console.log(`发送图片数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(' '));
|
16).padStart(2, '0'));
|
||||||
|
console.log(`发送图片数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(
|
||||||
|
' '));
|
||||||
|
|
||||||
updateLoading(these, {
|
updateLoading(these, {
|
||||||
text: "正在发送 " + (chunkIndex + 1) + "/" + numChunks
|
text: "正在发送 " + (chunkIndex + 1) + "/" + numChunks
|
||||||
});
|
});
|
||||||
|
|
||||||
ble.sendData(f.deviceId, chunk, f.writeServiceId, f.wirteCharactId, 100)
|
ble.sendData(f.deviceId, chunk, f.writeServiceId, f.wirteCharactId,
|
||||||
|
100)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
chunkIndex++;
|
chunkIndex++;
|
||||||
setTimeout(sendNextChunk, 20); // 每个小包之间延时20ms
|
setTimeout(sendNextChunk, 20); // 每个小包之间延时20ms
|
||||||
@ -1086,10 +1093,13 @@
|
|||||||
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
||||||
const chunk = fullBuffer.slice(start, end);
|
const chunk = fullBuffer.slice(start, end);
|
||||||
|
|
||||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(16).padStart(2, '0'));
|
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b
|
||||||
console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(' '));
|
.toString(16).padStart(2, '0'));
|
||||||
|
console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray
|
||||||
|
.join(' '));
|
||||||
|
|
||||||
ble.sendData(f.deviceId, chunk, f.writeServiceId, f.wirteCharactId, 100).then(() => {
|
ble.sendData(f.deviceId, chunk, f.writeServiceId, f
|
||||||
|
.wirteCharactId, 100).then(() => {
|
||||||
chunkIndex++;
|
chunkIndex++;
|
||||||
setTimeout(sendNextChunk, 30); // 每个小包之间延时30ms
|
setTimeout(sendNextChunk, 30); // 每个小包之间延时30ms
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@ -771,10 +771,10 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// console.log("无人订阅消息");
|
console.log("无人订阅消息");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log("无人订阅receivDataCallback,不处理数据");
|
console.log("无人订阅receivDataCallback,不处理数据");
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error("处理订阅消息失败,ex=", ex);
|
console.error("处理订阅消息失败,ex=", ex);
|
||||||
|
|||||||
@ -1,21 +1,12 @@
|
|||||||
class BleReceive {
|
class BleReceive {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.StorageKey = "linkedDevices";
|
this.StorageKey = "linkedDevices";
|
||||||
|
this.HandlerMap = {
|
||||||
}
|
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
|
||||||
|
'/pages/7305/BJQ7305': this.Receive_6155.bind(this),
|
||||||
getCurrentPagePath() {
|
'/pages/650/HBY650': this.Receive_650.bind(this),
|
||||||
|
'/pages/670/HBY670': this.Receive_670.bind(this)
|
||||||
const pages = getCurrentPages();
|
};
|
||||||
|
|
||||||
if (pages.length === 0) {
|
|
||||||
console.log("pages.length=0");
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentPage = pages[pages.length - 1];
|
|
||||||
console.log("currentPage=", currentPage.route);
|
|
||||||
return currentPage.route;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,22 +40,24 @@ class BleReceive {
|
|||||||
|
|
||||||
ReceiveData(receive, f, path, recArr) {
|
ReceiveData(receive, f, path, recArr) {
|
||||||
if (f && f.macAddress && f.device && f.device.id) {
|
if (f && f.macAddress && f.device && f.device.id) {
|
||||||
let data={};
|
let handler = null;
|
||||||
if(f.device.detailPageUrl=='/pages/6155/deviceDetail' || f.device.detailPageUrl=='/pages/7305/BJQ7305'){
|
let keys = Object.keys(this.HandlerMap);
|
||||||
// console.log("该设备是6155");
|
for (let index = 0; index < keys.length; index++) {
|
||||||
data= this.Receive_6155(receive,f,path,recArr);
|
let key = keys[index].replaceAll('/', '').toLowerCase();
|
||||||
|
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replaceAll('/', '').toLowerCase() : '';
|
||||||
|
if (key == devKey) {
|
||||||
|
handler = this.HandlerMap[keys[index]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f.device.detailPageUrl=='/pages/650/HBY650'){
|
if (handler) {
|
||||||
// console.log("该设备是650");
|
let data = handler(receive, f, path, recArr);
|
||||||
data= this.Receive_650(receive,f,path,recArr);
|
|
||||||
}
|
|
||||||
if(f.device.detailPageUrl=='/pages/670/HBY670'){
|
|
||||||
// console.log("该设备是670");
|
|
||||||
data= this.Receive_670(receive,f,path,recArr);
|
|
||||||
}
|
|
||||||
// console.log("收到数据并处理完毕,",data);
|
|
||||||
return data;
|
return data;
|
||||||
|
} else {
|
||||||
|
console.log("已收到消息,但无指定处理程序", receive);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("已收到该消息,但无法处理", receive);
|
console.log("已收到该消息,但无法处理", receive);
|
||||||
}
|
}
|
||||||
@ -154,10 +147,13 @@ class BleReceive {
|
|||||||
formData.iswarn = iswarn;
|
formData.iswarn = iswarn;
|
||||||
this.setBleFormData(formData, f);
|
this.setBleFormData(formData, f);
|
||||||
|
|
||||||
let route=this.getCurrentPagePath();
|
let recCnt = recArr.find(v => {
|
||||||
console.log("f=",f);
|
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||||
console.log("route="+route);
|
.replaceAll('/', '').toLowerCase();
|
||||||
if (iswarn && f.detailPageUrl.indexOf(route)==-1 ) {
|
});
|
||||||
|
if (!recCnt) {
|
||||||
|
|
||||||
|
if (iswarn) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
content: "环境存在漏电电源",
|
content: "环境存在漏电电源",
|
||||||
title: "警告",
|
title: "警告",
|
||||||
@ -182,8 +178,7 @@ class BleReceive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
}
|
||||||
console.log("当前全局不处理此消息");
|
|
||||||
}
|
}
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -201,9 +196,10 @@ class BleReceive {
|
|||||||
formData.macAddress = str.split(':')[1];
|
formData.macAddress = str.split(':')[1];
|
||||||
this.setBleFormData(formData, f);
|
this.setBleFormData(formData, f);
|
||||||
return formData;
|
return formData;
|
||||||
}
|
} else {
|
||||||
else{
|
let receiveData = {
|
||||||
let receiveData={a:1};
|
a: 1
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
let json = JSON.parse(str);
|
let json = JSON.parse(str);
|
||||||
|
|
||||||
@ -211,25 +207,21 @@ class BleReceive {
|
|||||||
//重发图片
|
//重发图片
|
||||||
console.log("收到重新发送图片的命令");
|
console.log("收到重新发送图片的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_text" in json) {
|
||||||
else if("staBlue_text" in json){
|
|
||||||
//重发文本
|
//重发文本
|
||||||
console.log("收到重新发送文本的命令");
|
console.log("收到重新发送文本的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_vidio" in json) {
|
||||||
else if("staBlue_vidio" in json){
|
|
||||||
//重发视频
|
//重发视频
|
||||||
console.log("收到重新发送视频的命令");
|
console.log("收到重新发送视频的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue" in json) {
|
||||||
else if("staBlue" in json){
|
|
||||||
if (json.staBlue == "finish") {
|
if (json.staBlue == "finish") {
|
||||||
console.log("收到设备回复,全部传输完成");
|
console.log("收到设备回复,全部传输完成");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
receiveData = {};
|
receiveData = {};
|
||||||
console.log("无法解析该文本");
|
console.log("无法解析该文本");
|
||||||
}
|
}
|
||||||
@ -284,7 +276,8 @@ class BleReceive {
|
|||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
// 解析照明档位
|
// 解析照明档位
|
||||||
let lightingLevelByte = bytes[2];
|
let lightingLevelByte = bytes[2];
|
||||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight' : lightingLevelByte === 0x6e ?
|
||||||
|
'low' : 'close';
|
||||||
|
|
||||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||||
let lightingTime = (bytes[3] << 8) | bytes[4];
|
let lightingTime = (bytes[3] << 8) | bytes[4];
|
||||||
@ -323,7 +316,8 @@ class BleReceive {
|
|||||||
this.setBleFormData(receiveData, f);
|
this.setBleFormData(receiveData, f);
|
||||||
console.log("recArr=", recArr);
|
console.log("recArr=", recArr);
|
||||||
let recCnt = recArr.find(v => {
|
let recCnt = recArr.find(v => {
|
||||||
return v.key == f.device.detailPageUrl;
|
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||||
|
.replaceAll('/', '').toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (this.formData.staticWarn) { //有静止报警
|
if (this.formData.staticWarn) { //有静止报警
|
||||||
@ -367,25 +361,21 @@ class BleReceive {
|
|||||||
//重发图片
|
//重发图片
|
||||||
console.log("收到重新发送图片的命令");
|
console.log("收到重新发送图片的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_text" in json) {
|
||||||
else if("staBlue_text" in json){
|
|
||||||
//重发文本
|
//重发文本
|
||||||
console.log("收到重新发送文本的命令");
|
console.log("收到重新发送文本的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_vidio" in json) {
|
||||||
else if("staBlue_vidio" in json){
|
|
||||||
//重发视频
|
//重发视频
|
||||||
console.log("收到重新发送视频的命令");
|
console.log("收到重新发送视频的命令");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue" in json) {
|
||||||
else if("staBlue" in json){
|
|
||||||
if (json.staBlue == "finish") {
|
if (json.staBlue == "finish") {
|
||||||
console.log("收到设备回复,全部传输完成");
|
console.log("收到设备回复,全部传输完成");
|
||||||
receiveData = json;
|
receiveData = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
receiveData = {};
|
receiveData = {};
|
||||||
console.log("无法解析该文本");
|
console.log("无法解析该文本");
|
||||||
}
|
}
|
||||||
@ -412,6 +402,7 @@ class BleReceive {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_6155(receive, f, path, recArr) {
|
Receive_6155(receive, f, path, recArr) {
|
||||||
let bytes = receive.bytes;
|
let bytes = receive.bytes;
|
||||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
@ -474,13 +465,23 @@ class BleReceive {
|
|||||||
formData.statu = warn;
|
formData.statu = warn;
|
||||||
formData.xuhang = lightingTime;
|
formData.xuhang = lightingTime;
|
||||||
|
|
||||||
|
|
||||||
|
let recCnt = recArr.find(v => {
|
||||||
|
|
||||||
|
return v.key.replaceAll('/', '').toLowerCase() === f.device.detailPageUrl.replaceAll(
|
||||||
|
'/', '').toLowerCase();
|
||||||
|
});
|
||||||
|
if (!recCnt) {
|
||||||
if (batteryLevel <= 20) {
|
if (batteryLevel <= 20) {
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
content: "设备电量低",
|
content: "设备电量低",
|
||||||
title: "提示"
|
title: "提示"
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.setBleFormData(formData, f);
|
this.setBleFormData(formData, f);
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user