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
|
||||||
@ -273,9 +275,9 @@
|
|||||||
|
|
||||||
ble.addReceiveCallback(these.bleValueNotify, pagePath);
|
ble.addReceiveCallback(these.bleValueNotify, pagePath);
|
||||||
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
|
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
|
||||||
ble.addStateRecoveryCallback(these.bleStateRecovry,pagePath);
|
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
|
||||||
ble.addDisposeCallback(these.deviceDispose,pagePath);
|
ble.addDisposeCallback(these.deviceDispose, pagePath);
|
||||||
ble.addRecoveryCallback(these.deviceRecovry,pagePath);
|
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
|
||||||
let eventChannel = this.getOpenerEventChannel();
|
let eventChannel = this.getOpenerEventChannel();
|
||||||
|
|
||||||
eventChannel.on('detailData', function(data) {
|
eventChannel.on('detailData', function(data) {
|
||||||
@ -311,9 +313,9 @@
|
|||||||
these.formData.img = device.devicePic;
|
these.formData.img = device.devicePic;
|
||||||
these.formData.id = device.id;
|
these.formData.id = device.id;
|
||||||
these.formData.deviceId = f.deviceId;
|
these.formData.deviceId = f.deviceId;
|
||||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res=>{
|
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||||
console.log("连接成功")
|
console.log("连接成功")
|
||||||
these.formData.bleStatu=true;
|
these.formData.bleStatu = true;
|
||||||
});
|
});
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
these.getDetail();
|
these.getDetail();
|
||||||
@ -377,40 +379,40 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
deviceRecovry(res){
|
deviceRecovry(res) {
|
||||||
if(this.Status.pageHide){
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(res.deviceId==these.formData.deviceId){
|
if (res.deviceId == these.formData.deviceId) {
|
||||||
this.formData.bleStatu=true;
|
this.formData.bleStatu = true;
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
hideLoading(these,1000);
|
hideLoading(these, 1000);
|
||||||
});
|
});
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon:'success',
|
icon: 'success',
|
||||||
title:'蓝牙连接成功'
|
title: '蓝牙连接成功'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
deviceDispose(res){
|
deviceDispose(res) {
|
||||||
if(this.Status.pageHide){
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(res.deviceId==these.formData.deviceId){
|
if (res.deviceId == these.formData.deviceId) {
|
||||||
this.formData.bleStatu=false;
|
this.formData.bleStatu = false;
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
hideLoading(these,1000);
|
hideLoading(these, 1000);
|
||||||
});
|
});
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon:'fail',
|
icon: 'fail',
|
||||||
title:'蓝牙连接已断开'
|
title: '蓝牙连接已断开'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
bleStateBreak() {
|
bleStateBreak() {
|
||||||
if(this.Status.pageHide){
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//蓝牙适配器不可用
|
//蓝牙适配器不可用
|
||||||
@ -423,7 +425,7 @@
|
|||||||
},
|
},
|
||||||
bleStateRecovry() {
|
bleStateRecovry() {
|
||||||
console.log("蓝牙可用");
|
console.log("蓝牙可用");
|
||||||
if(this.Status.pageHide){
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("蓝牙可用");
|
console.log("蓝牙可用");
|
||||||
@ -433,8 +435,8 @@
|
|||||||
});
|
});
|
||||||
ble.LinkBlue(these.formData.deviceId).then(() => {
|
ble.LinkBlue(these.formData.deviceId).then(() => {
|
||||||
these.formData.bleStatu = true;
|
these.formData.bleStatu = true;
|
||||||
updateLoading(these,{
|
updateLoading(these, {
|
||||||
text:'连接成功'
|
text: '连接成功'
|
||||||
});
|
});
|
||||||
}).catch(ex => {
|
}).catch(ex => {
|
||||||
updateLoading(these, {
|
updateLoading(these, {
|
||||||
@ -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;
|
||||||
@ -538,7 +540,7 @@
|
|||||||
events: {
|
events: {
|
||||||
BindOver: function(data) {
|
BindOver: function(data) {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
these.formData.bleStatu=true;
|
these.formData.bleStatu = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
@ -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
|
||||||
@ -1024,16 +1031,16 @@
|
|||||||
these.showBleUnConnect()
|
these.showBleUnConnect()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let err=false;
|
let err = false;
|
||||||
this.formData.textLines.find((txt)=>{
|
this.formData.textLines.find((txt) => {
|
||||||
if(txt.length===0 || txt.length>5){
|
if (txt.length === 0 || txt.length > 5) {
|
||||||
console.log("txt=",txt);
|
console.log("txt=", txt);
|
||||||
err=true;
|
err = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
if(err){
|
if (err) {
|
||||||
this.showPop({
|
this.showPop({
|
||||||
message: "单位、部门、姓名必须填写且最多5字",
|
message: "单位、部门、姓名必须填写且最多5字",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
@ -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 => {
|
||||||
@ -1239,7 +1249,7 @@
|
|||||||
if (f) {
|
if (f) {
|
||||||
// 发送数据
|
// 发送数据
|
||||||
|
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex=>{
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => {
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "发送失败," + ex.msg,
|
message: "发送失败," + ex.msg,
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
@ -1288,7 +1298,7 @@
|
|||||||
if (f) {
|
if (f) {
|
||||||
// 发送数据
|
// 发送数据
|
||||||
|
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex=>{
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => {
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "发送失败," + ex.msg,
|
message: "发送失败," + ex.msg,
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
|
|||||||
@ -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,45 +1,36 @@
|
|||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setBleFormData(data,f) {
|
setBleFormData(data, f) {
|
||||||
if(data){
|
if (data) {
|
||||||
let linkedList=uni.getStorageSync(this.StorageKey);
|
let linkedList = uni.getStorageSync(this.StorageKey);
|
||||||
if(!linkedList){
|
if (!linkedList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linkedList.find((v)=>{
|
linkedList.find((v) => {
|
||||||
if(f.deviceId==v.deviceId){
|
if (f.deviceId == v.deviceId) {
|
||||||
let keys=Object.keys(data);
|
let keys = Object.keys(data);
|
||||||
keys.forEach((key)=>{
|
keys.forEach((key) => {
|
||||||
if(!v.formData){
|
if (!v.formData) {
|
||||||
v.formData={};
|
v.formData = {};
|
||||||
}
|
}
|
||||||
if(!f.formData){
|
if (!f.formData) {
|
||||||
f.formData={};
|
f.formData = {};
|
||||||
}
|
}
|
||||||
v.formData[key]=data[key];
|
v.formData[key] = data[key];
|
||||||
f.formData[key]=data[key];
|
f.formData[key] = data[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.setStorageSync(this.StorageKey,linkedList);
|
uni.setStorageSync(this.StorageKey, linkedList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -47,34 +38,36 @@ 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{
|
} else {
|
||||||
console.log("已收到该消息,但无法处理",receive);
|
console.log("已收到消息,但无指定处理程序", receive);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("已收到该消息,但无法处理", receive);
|
||||||
}
|
}
|
||||||
|
|
||||||
return receive;
|
return receive;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_650(receive,f,path,recArr) {
|
Receive_650(receive, f, path, recArr) {
|
||||||
console.log("通用程序正在处理650的数据",receive);
|
console.log("通用程序正在处理650的数据", receive);
|
||||||
|
|
||||||
var parseData = () => {
|
var parseData = () => {
|
||||||
let bytes = receive.bytes;
|
let bytes = receive.bytes;
|
||||||
@ -145,26 +138,29 @@ class BleReceive {
|
|||||||
warn = '非常强预警';
|
warn = '非常强预警';
|
||||||
}
|
}
|
||||||
|
|
||||||
let formData={};
|
let formData = {};
|
||||||
formData.battary = batteryLevel;
|
formData.battary = batteryLevel;
|
||||||
formData.xuhang = xuhang;
|
formData.xuhang = xuhang;
|
||||||
formData.cMode = lightingLevelByte === 0x6e;
|
formData.cMode = lightingLevelByte === 0x6e;
|
||||||
formData.modeCurr = modeCurr;
|
formData.modeCurr = modeCurr;
|
||||||
formData.warnLevel = warn;
|
formData.warnLevel = warn;
|
||||||
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: "警告",
|
||||||
success(res){
|
success(res) {
|
||||||
if(res.confirm){
|
if (res.confirm) {
|
||||||
|
|
||||||
if(f){
|
if (f) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: f.detailPageUrl,
|
url: f.detailPageUrl,
|
||||||
events: {
|
events: {
|
||||||
@ -182,8 +178,7 @@ class BleReceive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
}
|
||||||
console.log("当前全局不处理此消息");
|
|
||||||
}
|
}
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -197,47 +192,44 @@ class BleReceive {
|
|||||||
let str = receive.str;
|
let str = receive.str;
|
||||||
|
|
||||||
if (str.indexOf('mac address:') == 0) {
|
if (str.indexOf('mac address:') == 0) {
|
||||||
let formData={};
|
let formData = {};
|
||||||
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);
|
||||||
|
|
||||||
if("staBlue_picture" in json){
|
if ("staBlue_picture" in json) {
|
||||||
//重发图片
|
//重发图片
|
||||||
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("无法解析该文本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
console.log("文本解析失败")
|
console.log("文本解析失败")
|
||||||
}
|
}
|
||||||
return receiveData;
|
return receiveData;
|
||||||
@ -250,15 +242,15 @@ class BleReceive {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let data=parseData(receive.bytes);
|
let data = parseData(receive.bytes);
|
||||||
console.log("data=",data);
|
console.log("data=", data);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_670(receive,f,path,recArr){
|
Receive_670(receive, f, path, recArr) {
|
||||||
console.log("pagh=",path);
|
console.log("pagh=", path);
|
||||||
var todo = (bytes) =>{
|
var todo = (bytes) => {
|
||||||
// console.log("todo",receive);
|
// console.log("todo",receive);
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
if (bytes[0] == 0x55) {
|
if (bytes[0] == 0x55) {
|
||||||
@ -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];
|
||||||
@ -307,34 +300,35 @@ class BleReceive {
|
|||||||
warn = 'veryhight';
|
warn = 'veryhight';
|
||||||
}
|
}
|
||||||
|
|
||||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
let staticWarn = bytes[7] == 0x01; //静止报警
|
||||||
let fourGStrenth = bytes[8]; //4g信号强度
|
let fourGStrenth = bytes[8]; //4g信号强度
|
||||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = lightingTime ;
|
receiveData.xuhang = lightingTime;
|
||||||
receiveData.battary = batteryLevel;
|
receiveData.battary = batteryLevel;
|
||||||
receiveData.warnLevel = warn;
|
receiveData.warnLevel = warn;
|
||||||
receiveData.staticWarn = staticWarn;
|
receiveData.staticWarn = staticWarn;
|
||||||
receiveData.fourGStrenth = fourGStrenth;
|
receiveData.fourGStrenth = fourGStrenth;
|
||||||
receiveData.SOS=sosTxt;
|
receiveData.SOS = sosTxt;
|
||||||
|
|
||||||
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) { //有静止报警
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title:"警告",
|
title: "警告",
|
||||||
content:"设备静止报警中",
|
content: "设备静止报警中",
|
||||||
showCancel:false
|
showCancel: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
}
|
}
|
||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
@ -362,58 +356,55 @@ class BleReceive {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// console.log("str=",str);
|
// console.log("str=",str);
|
||||||
let json=JSON.parse(str);
|
let json = JSON.parse(str);
|
||||||
if("staBlue_picture" in json){
|
if ("staBlue_picture" in json) {
|
||||||
//重发图片
|
//重发图片
|
||||||
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("无法解析该文本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
// console.log("文本解析失败",error)
|
// console.log("文本解析失败",error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch (ex) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log("todo",receiveData);
|
// console.log("todo",receiveData);
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData, f);
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let data=todo(receive.bytes);
|
let data = todo(receive.bytes);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
Receive_6155(receive,f,path,recArr) {
|
|
||||||
let bytes=receive.bytes;
|
Receive_6155(receive, f, path, recArr) {
|
||||||
|
let bytes = receive.bytes;
|
||||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -467,21 +458,31 @@ class BleReceive {
|
|||||||
let HH = Math.max(0, Math.min(100, bytes[6]));
|
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||||
let mm = Math.max(0, Math.min(100, bytes[7]));
|
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||||
lightingTime = HH + "小时" + mm + "分钟";
|
lightingTime = HH + "小时" + mm + "分钟";
|
||||||
let formData={};
|
let formData = {};
|
||||||
formData.mode = staticLevelText;
|
formData.mode = staticLevelText;
|
||||||
formData.fuMode = lightingLevelText;
|
formData.fuMode = lightingLevelText;
|
||||||
formData.battary = batteryLevel;
|
formData.battary = batteryLevel;
|
||||||
formData.statu = warn;
|
formData.statu = warn;
|
||||||
formData.xuhang = lightingTime;
|
formData.xuhang = lightingTime;
|
||||||
|
|
||||||
if (batteryLevel <= 20) {
|
|
||||||
uni.showModal({
|
|
||||||
content:"设备电量低",
|
|
||||||
title:"提示"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
let recCnt = recArr.find(v => {
|
||||||
|
|
||||||
|
return v.key.replaceAll('/', '').toLowerCase() === f.device.detailPageUrl.replaceAll(
|
||||||
|
'/', '').toLowerCase();
|
||||||
|
});
|
||||||
|
if (!recCnt) {
|
||||||
|
if (batteryLevel <= 20) {
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
content: "设备电量低",
|
||||||
|
title: "提示"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.setBleFormData(formData,f);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setBleFormData(formData, f);
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user