更新100、670电量低的提示方式为监听式
This commit is contained in:
@ -63,6 +63,10 @@ export function mapReverseGeocoding(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function deviceRealTimeStatus(){
|
||||
return Promise.resolve({code:500});
|
||||
export function deviceRealTimeStatus(params){
|
||||
return request({
|
||||
url: `/app/device/realTimeStatus`,
|
||||
method: 'get',
|
||||
data:params
|
||||
})
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.18",
|
||||
"versionName" : "1.0.19",
|
||||
"versionCode" : 101,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
@ -114,7 +114,8 @@
|
||||
"xhdpi" : "unpackage/res/icons/48x48.png",
|
||||
"xxhdpi" : "unpackage/res/icons/72x72.png"
|
||||
}
|
||||
}
|
||||
},
|
||||
"meizu" : {}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -518,6 +518,11 @@
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = BleTool.getBleTool();
|
||||
|
||||
this.$watch("formData.sta_battery", (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.sta_system==2) {
|
||||
this.showMsg("设备电量低");
|
||||
}
|
||||
});
|
||||
|
||||
ble.addReceiveCallback(this.bleValueNotify, pagePath);
|
||||
ble.addStateBreakCallback(this.bleStateBreak, pagePath);
|
||||
@ -1313,9 +1318,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (this.formData.sta_battery <= 20) {
|
||||
this.showMsg("设备电量低");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
|
||||
@ -411,7 +411,8 @@
|
||||
staPowerTime: null,
|
||||
staPowerPercent: null,
|
||||
staDetectResult: null
|
||||
}
|
||||
},
|
||||
inteval:50
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -994,179 +995,146 @@
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
// 处理像素数据并发送
|
||||
var processAndSendImageData = function(pixels) {
|
||||
|
||||
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// 创建RGB565格式的像素数据
|
||||
const arr = Common.convertToRGB565(pixels, 'bgr');
|
||||
|
||||
var list = [];
|
||||
let index = 0; // 用于追踪arr的当前位置
|
||||
let packetSize = 2048;
|
||||
let cSize = 248;
|
||||
// 外层循环:7个主要元素(i从1到7)
|
||||
for (let i = 1; i < 8; i++) {
|
||||
let secondLevel = [];
|
||||
let secondCnt = 0;
|
||||
// 中层循环:每个主要元素包含9个子数组(j从1到9)
|
||||
for (let j = 1; j < 10; j++) {
|
||||
// 确定当前子数组的长度:前8个是254,第9个是64
|
||||
|
||||
let thirdLevel = [];
|
||||
|
||||
// 从arr中提取相应数量的元素
|
||||
for (let k = 0; k < cSize && index < arr.length; k++) {
|
||||
|
||||
if (secondCnt == packetSize) {
|
||||
break;
|
||||
}
|
||||
thirdLevel.push(arr[index]);
|
||||
secondCnt++;
|
||||
index++;
|
||||
}
|
||||
|
||||
secondLevel.push(thirdLevel);
|
||||
}
|
||||
list.push(secondLevel);
|
||||
}
|
||||
|
||||
console.log("list=", list);
|
||||
|
||||
let length = 0;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
let clength = 0;
|
||||
for (let j = 0; j < item.length; j++) {
|
||||
const element = item[j];
|
||||
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
|
||||
length += element.length;
|
||||
clength += element.length;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// 分包发送
|
||||
sendImagePackets(list).then(resolve).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 分包发送图片数据
|
||||
var sendImagePackets = function(imageData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
const totalPackets = 7;
|
||||
let totalPackets = 52;
|
||||
let currentPacket = 1;
|
||||
let childPacket = 1;
|
||||
let totalChildPacket = 9;
|
||||
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
if (f) {
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
these.closeAction();
|
||||
these.showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png",
|
||||
});
|
||||
|
||||
MsgSuccess("上传成功", "确定", these);
|
||||
|
||||
setTimeout(()=>{
|
||||
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
},1000);
|
||||
|
||||
these.rgb565Data = null;
|
||||
resolve();
|
||||
}, 3000)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var packetData = imageData[currentPacket - 1][childPacket - 1];
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
// if (currentPacket <= 51) {
|
||||
// packetSize = 250; // 前51个包每个500字节
|
||||
// } else {
|
||||
// packetSize = 50; // 最后一个包100字节
|
||||
// }
|
||||
|
||||
let start = 0;
|
||||
let bufferSize = packetData.length * 2;
|
||||
|
||||
if (currentPacket == 7) {
|
||||
if (childPacket > 2 && childPacket < 9) {
|
||||
bufferSize = 496;
|
||||
} else if (childPacket == 9) {
|
||||
bufferSize = 128;
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
|
||||
|
||||
if (packetData.length == 250) {
|
||||
dataView.setUint8(3, 0x01);
|
||||
dataView.setUint8(4, 0xF4);
|
||||
} else {
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x64);
|
||||
}
|
||||
|
||||
if (childPacket == 1) {
|
||||
bufferSize = bufferSize + 8
|
||||
start = 8;
|
||||
}
|
||||
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
|
||||
bufferSize = bufferSize + 1
|
||||
}
|
||||
|
||||
|
||||
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
|
||||
var buffer = new ArrayBuffer(bufferSize);
|
||||
var dataView = new DataView(buffer);
|
||||
if (childPacket == 1) {
|
||||
dataView.setUint8(0, 0xFA); // 帧头
|
||||
dataView.setUint8(1, 0x09); // 帧头
|
||||
dataView.setUint8(2, 0x10); // 帧头
|
||||
dataView.setUint8(3, 0x04); // 帧头
|
||||
dataView.setUint8(4, 0xFC); // 帧头
|
||||
dataView.setUint8(5, 0x09); // 帧头
|
||||
|
||||
dataView.setUint8(6, 0x00); // 图序号,图片固定0,视频的话要写序号
|
||||
dataView.setUint8(7, currentPacket); //子包序号
|
||||
}
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
console.log("packetData.length=", packetData.length);
|
||||
console.log("bufferSize=", bufferSize)
|
||||
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
|
||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||
|
||||
if (currentPacket > 51) { //第52包补FF
|
||||
for (var i = 105; i < bufferSize; i++) {
|
||||
dataView.setUint8(i, 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
30)
|
||||
10)
|
||||
.then(() => {
|
||||
|
||||
let curr = childPacket + (currentPacket - 1) *
|
||||
totalChildPacket;
|
||||
console.log("第" + currentPacket + "大包,第" + childPacket +
|
||||
"小包发送完成,总计:" + curr);
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送" + curr + "/63"
|
||||
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
if (childPacket == 9) {
|
||||
currentPacket++;
|
||||
childPacket = 1;
|
||||
} else {
|
||||
childPacket++;
|
||||
}
|
||||
|
||||
setTimeout(sendNextPacket, 100);
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
}).catch(err => {
|
||||
if (err.code == 10007) {
|
||||
setTimeout(sendNextPacket, 100);
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("发送数据包失败了", err);
|
||||
|
||||
|
||||
showPop({
|
||||
message: "发送数据包失败了" + err.msg,
|
||||
these.closeAction();
|
||||
these.showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
these.rgb565Data = null;
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket(ReSendNo);
|
||||
return;
|
||||
}
|
||||
// 开始牵手
|
||||
ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId,
|
||||
f.wirteCharactId).then(() => {
|
||||
setTimeout(sendNextPacket, 120);
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("握手没有成功");
|
||||
these.showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
// 开始发送数据
|
||||
sendNextPacket();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -1186,10 +1154,11 @@
|
||||
});
|
||||
|
||||
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
|
||||
setTimeout(function() {
|
||||
processAndSendImageData(data.piexls).catch((
|
||||
ex) => {
|
||||
console.log("出现异常", ex);
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
}, 0)
|
||||
|
||||
|
||||
@ -486,10 +486,14 @@
|
||||
},
|
||||
onLoad: function() {
|
||||
|
||||
|
||||
these = this;
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = BleTool.getBleTool();
|
||||
this.$watch("formData.battary", (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.sta_system==2) {
|
||||
this.showMsg("设备电量低");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ble.addReceiveCallback(these.bleValueNotify, pagePath);
|
||||
@ -928,30 +932,16 @@
|
||||
// console.log("收到文本回复", payload);
|
||||
// // this.SendTxtMQ(json);
|
||||
// }
|
||||
if (keys.indexOf('sta_BreakNews') > -
|
||||
1) { //紧急通知
|
||||
if (json.sta_BreakNews ===
|
||||
'I get it'
|
||||
) // && this.Status.msgOkTime && this.Status.msgOkIntval){
|
||||
{
|
||||
if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
|
||||
if(json.sta_BreakNews=='I get it'){
|
||||
these.showPop({
|
||||
showPop: true,
|
||||
message: "用户已确认收到紧急通知",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
});
|
||||
|
||||
// this.Status.msgOkTime=null
|
||||
// clearInterval(this.Status.msgOkIntval);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// else {
|
||||
// console.log("收到不能处理的数据", payload);
|
||||
// }
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("无法解析此消息", payload);
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@
|
||||
callback: this.scan
|
||||
}],
|
||||
title: '扫码'
|
||||
|
||||
},
|
||||
},
|
||||
formData: {
|
||||
@ -208,7 +207,7 @@
|
||||
this.qrCodeResult(cleanedResult, true, null);
|
||||
},
|
||||
fail: (err) => {
|
||||
this.showMsg("扫码失败:" + err.errMsg, MsgType.error);
|
||||
MsgError("扫码失败:" + err.errMsg,"确定",these);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -187,7 +187,8 @@ import BleReceive from '@/utils/BleReceive';
|
||||
navTitle: "我的设备",
|
||||
deleteShow: false,
|
||||
RenameModel: false,
|
||||
menuItems: [{
|
||||
menuItems: [
|
||||
{
|
||||
text: '扫一扫添加',
|
||||
icon: '/static/images/common/scane.png',
|
||||
action: 'scan'
|
||||
|
||||
Reference in New Issue
Block a user