650/670增加关闭探测功能,删除一些跟供应商调试的页面
This commit is contained in:
81
pages.json
81
pages.json
@ -226,78 +226,7 @@
|
|||||||
"navigationBarTitleText": "呼叫"
|
"navigationBarTitleText": "呼叫"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/index",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "设备类型"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "发送视频"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "发送视频"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_670",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "发送视频"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY650",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY650"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY650_1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY650"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/ModeSetting",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "7307-0.96TFT"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/update",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "版本更新"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY6155",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY6155"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY6155V1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY6155_V1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/HBY670V1",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "HBY670"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/670/HBY670",
|
"path": "pages/670/HBY670",
|
||||||
"style": {
|
"style": {
|
||||||
@ -317,16 +246,10 @@
|
|||||||
"navigationBarTitleText": "历史记录"
|
"navigationBarTitleText": "历史记录"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/BlueTooth/ModeSetting/4877",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/7305/BJQ7305",
|
"path": "pages/7305/BJQ7305",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
|
||||||
"navigationBarTitleText": "BJQ7305"
|
"navigationBarTitleText": "BJQ7305"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -510,7 +510,7 @@
|
|||||||
dataValue = 0x65;
|
dataValue = 0x65;
|
||||||
break;
|
break;
|
||||||
case "close": //关闭
|
case "close": //关闭
|
||||||
dataValue = 0x68;
|
dataValue = 0x64;
|
||||||
break;
|
break;
|
||||||
case true: //开灯
|
case true: //开灯
|
||||||
dataValue = 0x6E;
|
dataValue = 0x6E;
|
||||||
|
|||||||
@ -27,31 +27,32 @@
|
|||||||
<view class="eqinfo">
|
<view class="eqinfo">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">设备IMEI</text>
|
<text class="lbl">设备IMEI</text>
|
||||||
<text class="value">{{device.deviceImei}}</text>
|
<text class="value valueFont">{{device.deviceImei}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">设备名称</text>
|
<text class="lbl">设备名称</text>
|
||||||
<text class="value">{{device.deviceName}}</text>
|
<text class="value valueFont">{{device.deviceName}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">设备状态</text>
|
<text class="lbl">设备状态</text>
|
||||||
<text class="value">{{formData.sta_system}}</text>
|
<text class="value valueFont">{{formData.sta_system}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="lbl">定位信息</text>
|
<text class="lbl">定位信息</text>
|
||||||
<view class="multiValue">
|
<view class="multiValue">
|
||||||
<view class="valueItem">
|
<view class="valueItem valueFont">
|
||||||
{{formData.Lon}}
|
{{formData.Lon}}
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="valueItem">
|
<view class="valueItem valueFont">
|
||||||
|
|
||||||
{{formData.Lat}}
|
{{formData.Lat}}
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="valueItem">
|
<view class="valueItem">
|
||||||
|
|
||||||
<view style="width:80%;float: right;text-align: right;">{{formData.address}}</view>
|
<view style="width:80%;float: right;text-align: right;" class="valueFont">{{formData.address}}
|
||||||
|
</view>
|
||||||
<view class="clear"></view>
|
<view class="clear"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -95,6 +96,10 @@
|
|||||||
@click="GearSetting('hight','staticBattery')">
|
@click="GearSetting('hight','staticBattery')">
|
||||||
<view class="p100 center">高档</view>
|
<view class="p100 center">高档</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="item " :class="formData.modeCurr=='close'?'active':''"
|
||||||
|
@click="GearSetting('close','staticBattery')">
|
||||||
|
<view class="p100 center">关闭</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="optTitle">
|
<view class="optTitle">
|
||||||
@ -316,7 +321,7 @@
|
|||||||
promptTitle: '设备名称',
|
promptTitle: '设备名称',
|
||||||
modelValue: '',
|
modelValue: '',
|
||||||
visibleClose: false,
|
visibleClose: false,
|
||||||
|
okCallback: null
|
||||||
},
|
},
|
||||||
BottomMenu: {
|
BottomMenu: {
|
||||||
show: false,
|
show: false,
|
||||||
@ -514,7 +519,8 @@
|
|||||||
let warn = dic[json.staDetectResult];
|
let warn = dic[json.staDetectResult];
|
||||||
that.formData.warnLevel = warn;
|
that.formData.warnLevel = warn;
|
||||||
|
|
||||||
let lightingLevelText = json.staLightGrade === 1 ? 'hight' : json.staLightGrade === 2 ? 'low' :
|
let lightingLevelText = json.staLightGrade === 1 ? 'hight' : json.staLightGrade === 2 ?
|
||||||
|
'low' :
|
||||||
'close';
|
'close';
|
||||||
that.formData.lightCurr = lightingLevelText;
|
that.formData.lightCurr = lightingLevelText;
|
||||||
|
|
||||||
@ -1009,7 +1015,12 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: "解除报警",
|
buttonText: "解除报警",
|
||||||
okCallback: callback,
|
okCallback: () => {
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
this.Status.Pop.okCallback = null;
|
||||||
|
},
|
||||||
clickEvt: 'time'
|
clickEvt: 'time'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1097,7 +1108,7 @@
|
|||||||
let OpenSOS = () => {
|
let OpenSOS = () => {
|
||||||
these.formData.qzwarn = true; //标记为强制报警了
|
these.formData.qzwarn = true; //标记为强制报警了
|
||||||
|
|
||||||
these.Status.staticWarn.time = 50;
|
these.Status.staticWarn.time = 180;
|
||||||
this.formData.SOS = type;
|
this.formData.SOS = type;
|
||||||
|
|
||||||
let loopFunc = () => {
|
let loopFunc = () => {
|
||||||
@ -1121,21 +1132,34 @@
|
|||||||
console.log("111111");
|
console.log("111111");
|
||||||
this.showQzWarn(this.Status.Pop.okCallback);
|
this.showQzWarn(this.Status.Pop.okCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
these.Status.staticWarn.inteval = setInterval(() => {
|
these.Status.staticWarn.inteval = setInterval(() => {
|
||||||
loopFunc();
|
loopFunc();
|
||||||
}, 1000)
|
}, 1000);
|
||||||
|
|
||||||
bleSendCmd();
|
bleSendCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rb') { //红蓝报警
|
if (type == 'rb') { //红蓝报警
|
||||||
|
console.log("11111");
|
||||||
|
let sendRb = () => {
|
||||||
this.formData.SOS = type;
|
this.formData.SOS = type;
|
||||||
bleSendCmd();
|
bleSendCmd();
|
||||||
|
these.formData.qzwarn=false;
|
||||||
|
this.Status.staticWarn.time=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type == 'sg') //强制报警
|
if (these.formData.qzwarn) {
|
||||||
|
console.log("222222");
|
||||||
|
these.showQzWarn(sendRb);
|
||||||
|
} else {
|
||||||
|
sendRb();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (type == 'sg') //强制报警
|
||||||
{
|
{
|
||||||
|
|
||||||
this.showPop({
|
this.showPop({
|
||||||
@ -1147,8 +1171,7 @@
|
|||||||
buttonText: "开启"
|
buttonText: "开启"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
} else if (type == 'close') {
|
||||||
if (type == 'close') {
|
|
||||||
|
|
||||||
if (this.formData.SOS = 'sg') { //解除声光报警
|
if (this.formData.SOS = 'sg') { //解除声光报警
|
||||||
this.CloseWarn(true);
|
this.CloseWarn(true);
|
||||||
@ -1178,7 +1201,7 @@
|
|||||||
hight: 0x65,
|
hight: 0x65,
|
||||||
center: 0x66,
|
center: 0x66,
|
||||||
low: 0x67,
|
low: 0x67,
|
||||||
close: 0x68
|
close: 0x64
|
||||||
},
|
},
|
||||||
mqtt: {
|
mqtt: {
|
||||||
hight: 3,
|
hight: 3,
|
||||||
@ -2324,14 +2347,22 @@
|
|||||||
|
|
||||||
.eqinfo .value {
|
.eqinfo .value {
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
font-family: PingFang SC;
|
font-family: 'PingFang SC';
|
||||||
font-size: 28rpx;
|
font-size: 28rpx !important;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
||||||
letter-spacing: 0.07px;
|
letter-spacing: 0.07px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.eqinfo .valueFont {
|
||||||
|
font-family: 'PingFang SC';
|
||||||
|
font-size: 28rpx !important;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
.eqinfo .multiValue {
|
.eqinfo .multiValue {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,529 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="content">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view>
|
|
||||||
重发包序号:{{reSendNumber}}
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view>
|
|
||||||
<text>发送间隔</text>
|
|
||||||
<input type="text" v-model="inteval" />
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<button @click="checkVideo">选择视频</button>
|
|
||||||
|
|
||||||
<button @click="uploadVideo">发送</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="sending-progress" v-if="isSending">
|
|
||||||
<view class="progress-bar">
|
|
||||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
|
||||||
</view>
|
|
||||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Common from '@/utils/Common';
|
|
||||||
import request,{ baseURL } from '@/utils/request.js';
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
videoPath: '',
|
|
||||||
inteval: 0,
|
|
||||||
progress: 0,
|
|
||||||
currentPacket: 0,
|
|
||||||
totalPackets: 100,
|
|
||||||
|
|
||||||
connectedDeviceId: '',
|
|
||||||
serviceId: '0xFFE1',
|
|
||||||
writeCharacteristicId: '0xFFE1',
|
|
||||||
notifyCharacteristicId: '0xFFE2',
|
|
||||||
isSending: "",
|
|
||||||
textProgress: "",
|
|
||||||
|
|
||||||
imgs: [],
|
|
||||||
videoWidth: 320,
|
|
||||||
videoHeight: 160,
|
|
||||||
videoDuration: 2,
|
|
||||||
reSendNumber:null,
|
|
||||||
hexArray: []
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
const eventChannel = this.getOpenerEventChannel();
|
|
||||||
|
|
||||||
eventChannel.on('receiveDevice', (data) => {
|
|
||||||
this.connectedDeviceId = data.connectedDeviceId;
|
|
||||||
this.serviceId = data.serviceId;
|
|
||||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
|
||||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
|
||||||
});
|
|
||||||
|
|
||||||
eventChannel.on('ReSendVideo', (data) => {
|
|
||||||
//重新发送某一包
|
|
||||||
this.reSendNumber = data.videoNo;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.shotVideoClick(this.hexArray, 'rgb565', data.videoNo);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
checkVideo: function() {
|
|
||||||
uni.chooseVideo({
|
|
||||||
sourceType: ['album', 'camera'],
|
|
||||||
compressed: false,
|
|
||||||
maxDuration: 2,
|
|
||||||
camera: 'back',
|
|
||||||
success: (res) => {
|
|
||||||
this.videoPath = res.tempFilePath;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.imgs = [];
|
|
||||||
this.hexArray = [];
|
|
||||||
|
|
||||||
this.videoWidth = res.width;
|
|
||||||
this.videoHeight = res.height;
|
|
||||||
this.videoDuration = res.duration;
|
|
||||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
uploadVideo: function() {
|
|
||||||
|
|
||||||
if (this.hexArray.length > 0) {
|
|
||||||
console.log("开始处理,无需上传");
|
|
||||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!this.videoPath) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "请选择视频",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("正在上传视频");
|
|
||||||
uni.showLoading({
|
|
||||||
title: "上传中"
|
|
||||||
});
|
|
||||||
|
|
||||||
let p2 = new Promise((resolve, reject) => {
|
|
||||||
let start = new Date();
|
|
||||||
console.log("baseURL=" + baseURL);
|
|
||||||
const token ="";// uni.getStorageSync('token');
|
|
||||||
const clientid ="";// uni.getStorageSync('clientID');
|
|
||||||
uni.uploadFile({
|
|
||||||
url: 'http://114.55.111.217/video/upload',
|
|
||||||
// url:baseURL+"/app/video/upload",
|
|
||||||
filePath: this.videoPath,
|
|
||||||
name: 'file',
|
|
||||||
header: {
|
|
||||||
"Method": "POST",
|
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
"Authorization": 'Bearer ' + token,
|
|
||||||
"clientid": clientid
|
|
||||||
},
|
|
||||||
timeout: 600000,
|
|
||||||
fail: (ex) => {
|
|
||||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
|
||||||
uni.showToast({
|
|
||||||
title: "视频文件上传失败了,请检查网络连接",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
uni.hideLoading();
|
|
||||||
reject(ex);
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.hideLoading();
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let p1 = this.HoldYouHand();
|
|
||||||
|
|
||||||
Promise.all([p2, p1]).then((arr) => {
|
|
||||||
|
|
||||||
if (arr[1] === true) {
|
|
||||||
let res = arr[0];
|
|
||||||
res = JSON.parse(res.data);
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
this.hexArray = res.data;
|
|
||||||
uni.showLoading({
|
|
||||||
title: "正在发送"
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.shotVideoClick(res.data, 'rgb565');
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("res")
|
|
||||||
uni.showModal({
|
|
||||||
content: "服务器未返回RGB565数据",
|
|
||||||
title: '错误'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uni.showModal({
|
|
||||||
content: "与设备握手失败了",
|
|
||||||
title: "错误"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
bleSendComplete() {
|
|
||||||
var str = "transmit complete"; //握手的协议字符串
|
|
||||||
let buffer = new ArrayBuffer(str.length);
|
|
||||||
let dataView = new DataView(buffer);
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
dataView.setUint8(i, str.charCodeAt(i));
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
console.log("完成指令发送成功");
|
|
||||||
}).catch(err => {
|
|
||||||
console.log("完成指令发送失败");
|
|
||||||
});
|
|
||||||
}, 3000)
|
|
||||||
|
|
||||||
},
|
|
||||||
shotVideoClick: function(array, type, ReSendNo) {
|
|
||||||
//console.log("处理视频完成", array);
|
|
||||||
//console.log("type=" + type)
|
|
||||||
//console.log("array=", array);
|
|
||||||
this.imgs = array;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var sendImagePackets = (imageData) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
this.isSending = true;
|
|
||||||
this.progress = 0;
|
|
||||||
this.currentPacket = 0;
|
|
||||||
|
|
||||||
// 总数据包数
|
|
||||||
const totalPackets = 1536;
|
|
||||||
this.totalPackets = totalPackets;
|
|
||||||
let currentPacket = 1;
|
|
||||||
if (ReSendNo) {
|
|
||||||
console.log("11111");
|
|
||||||
this.progress = ReSendNo - 1;
|
|
||||||
this.currentPacket = ReSendNo - 1;
|
|
||||||
console.log("22222");
|
|
||||||
|
|
||||||
this.totalPackets = ReSendNo;
|
|
||||||
console.log("11111=",ReSendNo);
|
|
||||||
}
|
|
||||||
// 发送单个数据包
|
|
||||||
const sendNextPacket = () => {
|
|
||||||
console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
|
||||||
if (currentPacket > totalPackets) {
|
|
||||||
this.isSending = false;
|
|
||||||
if (!ReSendNo) {
|
|
||||||
this.bleSendComplete();
|
|
||||||
} else {
|
|
||||||
// this.reSendNumber="";
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算当前包的数据
|
|
||||||
let packetSize = 250;
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
packetSize = 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建数据包
|
|
||||||
const startIndex = (currentPacket - 1) * packetSize;
|
|
||||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
|
||||||
if (startIndex > endIndex) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("111111");
|
|
||||||
const packetData = imageData.slice(startIndex, endIndex);
|
|
||||||
|
|
||||||
// 构建数据包
|
|
||||||
console.log("packetData.length"+packetData.length);
|
|
||||||
const bufferSize = 506; // 头部5字节 + 数据部分
|
|
||||||
const buffer = new ArrayBuffer(bufferSize);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
let sortNo = currentPacket.toString(16).padStart(4, '0');
|
|
||||||
|
|
||||||
// 填充头部
|
|
||||||
dataView.setUint8(0, 0x55); // 帧头
|
|
||||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
|
||||||
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
|
|
||||||
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
|
|
||||||
|
|
||||||
|
|
||||||
dataView.setUint8(4, 0x01);
|
|
||||||
dataView.setUint8(5, 0xF4);
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
if(ReSendNo){
|
|
||||||
this.isSending = false;
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 更新进度
|
|
||||||
this.currentPacket = currentPacket;
|
|
||||||
this.progress = Math.round((currentPacket / totalPackets) *
|
|
||||||
100);
|
|
||||||
console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
|
||||||
|
|
||||||
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
|
|
||||||
currentPacket++;
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(sendNextPacket, inteval);
|
|
||||||
}).catch(err => {
|
|
||||||
|
|
||||||
// console.log(err.errMsg + ",发送失败了,正在补偿:" + currentPacket);
|
|
||||||
setTimeout(sendNextPacket, inteval);
|
|
||||||
// uni.showToast({
|
|
||||||
// title:"发送失败"+JSON.stringify(err)
|
|
||||||
// })
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sendNextPacket();
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
let start = new Date();
|
|
||||||
console.log("开始发送");
|
|
||||||
sendImagePackets(array).then(() => {
|
|
||||||
console.log("发送完成");
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.showModal({
|
|
||||||
content:"发送完成,耗时:" + m + "分" + s + "秒",
|
|
||||||
title:"提示"
|
|
||||||
});
|
|
||||||
|
|
||||||
}).catch((ex1) => {
|
|
||||||
//console.log("出现了异常", ex1)
|
|
||||||
}).finally(() => {
|
|
||||||
uni.hideLoading();
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
HoldYouHand() {
|
|
||||||
|
|
||||||
var promise = new Promise((resolve, reject) => {
|
|
||||||
try {
|
|
||||||
let start = new Date();
|
|
||||||
var str = "video transmit start"; //握手的协议字符串
|
|
||||||
console.log("开始握手:" + str)
|
|
||||||
|
|
||||||
// 1. 创建 ArrayBuffer 和 DataView
|
|
||||||
const buffer = new ArrayBuffer(str.length);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
dataView.setUint8(i, str.charCodeAt(i));
|
|
||||||
}
|
|
||||||
//console.log("111111");
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
// 开始发送第一个包
|
|
||||||
setTimeout(() => {
|
|
||||||
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
|
|
||||||
console.log("握手成功并完成2200ms等待,耗时" + m + "分" + s + "秒");
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
}, 2200);
|
|
||||||
|
|
||||||
}).catch(err => {
|
|
||||||
//console.log("握手没有成功");
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
} catch (ex) {
|
|
||||||
reject(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
|
|
||||||
},
|
|
||||||
sendData(buffer) {
|
|
||||||
////console.log("deviceId=" + this.connectedDeviceId);
|
|
||||||
////console.log("serviceId=" + this.serviceId);
|
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
|
|
||||||
// //console.log("开始发送数据,buffer");
|
|
||||||
|
|
||||||
|
|
||||||
var promise = new Promise((succ, err) => {
|
|
||||||
uni.writeBLECharacteristicValue({
|
|
||||||
deviceId: this.connectedDeviceId,
|
|
||||||
serviceId: this.serviceId,
|
|
||||||
characteristicId: this.writeCharacteristicId,
|
|
||||||
value: buffer,
|
|
||||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
|
||||||
success: () => {
|
|
||||||
// //console.log("发送数据成功");
|
|
||||||
succ();
|
|
||||||
},
|
|
||||||
fail: (ex) => {
|
|
||||||
//console.log("发送数据失败", ex);
|
|
||||||
err(ex);
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
// //console.log("123456");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (plus.os.name == 'iOS') {
|
|
||||||
|
|
||||||
function timeout(ms) {
|
|
||||||
return new Promise((_, err) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
err({
|
|
||||||
code: -1,
|
|
||||||
errMsg: '超时了'
|
|
||||||
})
|
|
||||||
}, ms);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
|
||||||
|
|
||||||
Promise.race([promise, timeout(inteval)]).then(resolve).catch((ex) => {
|
|
||||||
//console.log("ex=", ex);
|
|
||||||
if (ex.code == -1) {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).finally(() => {
|
|
||||||
//console.log("完成了")
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
promise.then(resolve).catch(reject);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.sending-progress {
|
|
||||||
margin-top: 30rpx;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
height: 12rpx;
|
|
||||||
background-color: #e0e0e0;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background-color: #409eff;
|
|
||||||
transition: width 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
border: 2rpx solid #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
height: 100rpx;
|
|
||||||
line-height: 100rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 300px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.splash-frame {
|
|
||||||
height: 320rpx;
|
|
||||||
width: 640rpx;
|
|
||||||
border: 2rpx solid #409eff;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
}
|
|
||||||
.splash-frame image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@ -1,517 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="content">
|
|
||||||
<canvas canvas-id="flashCanvas"
|
|
||||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
|
||||||
|
|
||||||
<f-video ref="compARef" :src="videoPath" :direction="-90" :autoplay="true" @shotVideoClick="shotVideoClick"
|
|
||||||
:videoWidth="videoWidth" :videoHeight="videoHeight"></f-video>
|
|
||||||
|
|
||||||
<view>
|
|
||||||
<text>并发包数量</text>
|
|
||||||
<input type="text" v-model="packgeCnt" />
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<text>发送间隔</text>
|
|
||||||
<input type="text" v-model="inteval" />
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<button @click="checkVideo">选择视频</button>
|
|
||||||
<!-- <button @click="CutImg">发送</button> -->
|
|
||||||
<button @click="uploadVideo">发送</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="sending-progress" v-if="isSending">
|
|
||||||
<view class="progress-bar">
|
|
||||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
|
||||||
</view>
|
|
||||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
videoPath: '',
|
|
||||||
packgeCnt: 20,
|
|
||||||
inteval: 0,
|
|
||||||
progress: 0,
|
|
||||||
currentPacket: 0,
|
|
||||||
totalPackets: 100,
|
|
||||||
|
|
||||||
connectedDeviceId: '',
|
|
||||||
serviceId: '0xFFE1',
|
|
||||||
writeCharacteristicId: '0xFFE1',
|
|
||||||
notifyCharacteristicId: '0xFFE2',
|
|
||||||
isSending: "",
|
|
||||||
textProgress: "",
|
|
||||||
|
|
||||||
imgs: [],
|
|
||||||
videoWidth: 320,
|
|
||||||
videoHeight: 160,
|
|
||||||
videoDuration: 2,
|
|
||||||
|
|
||||||
hexArray: []
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
const eventChannel = this.getOpenerEventChannel();
|
|
||||||
|
|
||||||
eventChannel.on('receiveDevice', (data) => {
|
|
||||||
this.connectedDeviceId = data.connectedDeviceId;
|
|
||||||
this.serviceId = data.serviceId;
|
|
||||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
|
||||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
checkVideo: function() {
|
|
||||||
uni.chooseVideo({
|
|
||||||
sourceType: ['album', 'camera'],
|
|
||||||
compressed: false,
|
|
||||||
maxDuration: 2,
|
|
||||||
camera: 'back',
|
|
||||||
success: (res) => {
|
|
||||||
this.videoPath = res.tempFilePath;
|
|
||||||
|
|
||||||
this.imgs = [];
|
|
||||||
this.hexArray = [];
|
|
||||||
this.$refs.compARef.base64 = [];
|
|
||||||
this.videoWidth = res.width;
|
|
||||||
this.videoHeight = res.height;
|
|
||||||
this.videoDuration = res.duration;
|
|
||||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
uploadVideo: function() {
|
|
||||||
|
|
||||||
if (this.hexArray.length > 0) {
|
|
||||||
console.log("开始处理,无需上传");
|
|
||||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(!this.videoPath){
|
|
||||||
uni.showToast({
|
|
||||||
title: "请选择视频",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("正在上传视频");
|
|
||||||
uni.showLoading({
|
|
||||||
title: "上传中"
|
|
||||||
});
|
|
||||||
|
|
||||||
let p2=new Promise((resolve,reject)=>{
|
|
||||||
console.log("Common.baseURL="+Common.baseURL);
|
|
||||||
let start = new Date();
|
|
||||||
uni.uploadFile({
|
|
||||||
url: Common.baseURL+'video/upload',
|
|
||||||
// url: 'http://192.168.110.169:5000/video/upload',
|
|
||||||
filePath: this.videoPath,
|
|
||||||
name: 'file',
|
|
||||||
header: {
|
|
||||||
"Method": "POST",
|
|
||||||
"Content-Type": "multipart/form-data"
|
|
||||||
},
|
|
||||||
timeout: 600000,
|
|
||||||
fail: (ex) => {
|
|
||||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
|
||||||
uni.showToast({
|
|
||||||
title: "视频文件上传失败了,请检查网络连接",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
uni.hideLoading();
|
|
||||||
reject(ex);
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.hideLoading();
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let p1=this.HoldYouHand();
|
|
||||||
|
|
||||||
Promise.all([p2,p1]).then((arr)=>{
|
|
||||||
if(arr[1]===true){
|
|
||||||
let res=arr[0];
|
|
||||||
res = JSON.parse(res.data);
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
this.hexArray = res.data;
|
|
||||||
uni.showLoading({
|
|
||||||
title: "正在发送"
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.shotVideoClick(res.data, 'rgb565');
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("res")
|
|
||||||
uni.showModal({
|
|
||||||
content: "服务器未返回RGB565数据",
|
|
||||||
title: '错误'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
uni.showModal({
|
|
||||||
content:"与设备握手失败了",
|
|
||||||
title:"错误"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
pause(e) {
|
|
||||||
////console.log('pause--------------------------', e);
|
|
||||||
},
|
|
||||||
shotVideoClick: function(array, type) {
|
|
||||||
//console.log("处理视频完成", array);
|
|
||||||
//console.log("type=" + type)
|
|
||||||
//console.log("array=", array);
|
|
||||||
this.imgs = array;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var sendImagePackets = (imageData) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
this.isSending = true;
|
|
||||||
this.progress = 0;
|
|
||||||
this.currentPacket = 0;
|
|
||||||
|
|
||||||
// 总数据包数
|
|
||||||
const totalPackets = 1536;
|
|
||||||
this.totalPackets = totalPackets;
|
|
||||||
let currentPacket = 1;
|
|
||||||
let promises = [];
|
|
||||||
// 发送单个数据包
|
|
||||||
const sendNextPacket = () => {
|
|
||||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
|
||||||
if (currentPacket > totalPackets) {
|
|
||||||
this.isSending = false;
|
|
||||||
resolve();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算当前包的数据
|
|
||||||
let packetSize = 250;
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
packetSize = 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建数据包
|
|
||||||
const startIndex = (currentPacket - 1) * packetSize;
|
|
||||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
|
||||||
if (startIndex > endIndex) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
////console.log("111111");
|
|
||||||
const packetData = imageData.slice(startIndex, endIndex);
|
|
||||||
|
|
||||||
// 构建数据包
|
|
||||||
////console.log("packetData.length"+packetData.length);
|
|
||||||
const bufferSize = 506; // 头部5字节 + 数据部分
|
|
||||||
const buffer = new ArrayBuffer(bufferSize);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
let sortNo = currentPacket.toString(16).padStart(4, '0');
|
|
||||||
|
|
||||||
// 填充头部
|
|
||||||
dataView.setUint8(0, 0x55); // 帧头
|
|
||||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
|
||||||
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
|
|
||||||
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
|
|
||||||
|
|
||||||
|
|
||||||
dataView.setUint8(4, 0x01);
|
|
||||||
dataView.setUint8(5, 0xF4);
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
|
||||||
let promise = this.sendData(buffer);
|
|
||||||
promises.push(promise);
|
|
||||||
let packgeCnt = parseInt(this.packgeCnt || 20);
|
|
||||||
if (currentPacket % packgeCnt == 0 || (currentPacket >= totalPackets &&
|
|
||||||
promises.length > 0)) {
|
|
||||||
Promise.all(promises).then(() => {
|
|
||||||
if (currentPacket >= totalPackets) {
|
|
||||||
this.isSending = false;
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentPacket = currentPacket;
|
|
||||||
this.progress = Math.round((currentPacket / totalPackets) *
|
|
||||||
100);
|
|
||||||
currentPacket++;
|
|
||||||
setTimeout(sendNextPacket, inteval);
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
currentPacket++;
|
|
||||||
sendNextPacket();
|
|
||||||
}
|
|
||||||
// .then(() => {
|
|
||||||
// // 更新进度
|
|
||||||
// this.currentPacket = currentPacket;
|
|
||||||
// this.progress = Math.round((currentPacket / totalPackets) *
|
|
||||||
// 100);
|
|
||||||
|
|
||||||
// currentPacket++;
|
|
||||||
|
|
||||||
|
|
||||||
// setTimeout(sendNextPacket, inteval);
|
|
||||||
// }).catch(err => {
|
|
||||||
|
|
||||||
// console.log(err.errMsg+",发送失败了,正在补偿:" + currentPacket);
|
|
||||||
// setTimeout(sendNextPacket, inteval);
|
|
||||||
|
|
||||||
// });
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
sendNextPacket();
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
let start = new Date();
|
|
||||||
console.log("开始发送");
|
|
||||||
sendImagePackets(array).then(() => {
|
|
||||||
|
|
||||||
let end = new Date();
|
|
||||||
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.showToast({
|
|
||||||
title: "发送完成,耗时:" + m + "分" + s + "秒",
|
|
||||||
icon: 'success',
|
|
||||||
|
|
||||||
})
|
|
||||||
}).catch((ex1) => {
|
|
||||||
//console.log("出现了异常", ex1)
|
|
||||||
}).finally(() => {
|
|
||||||
uni.hideLoading();
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
HoldYouHand() {
|
|
||||||
|
|
||||||
var promise=new Promise((resolve,reject)=>{
|
|
||||||
try{
|
|
||||||
let start=new Date();
|
|
||||||
var str = "video transmit start"; //握手的协议字符串
|
|
||||||
console.log("开始握手:"+str)
|
|
||||||
|
|
||||||
// 1. 创建 ArrayBuffer 和 DataView
|
|
||||||
const buffer = new ArrayBuffer(str.length);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
dataView.setUint8(i, str.charCodeAt(i));
|
|
||||||
}
|
|
||||||
//console.log("111111");
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
// 开始发送第一个包
|
|
||||||
setTimeout(()=>{
|
|
||||||
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
|
|
||||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
}, 2200);
|
|
||||||
|
|
||||||
}).catch(err => {
|
|
||||||
//console.log("握手没有成功");
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
}catch(ex){
|
|
||||||
reject(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
|
|
||||||
},
|
|
||||||
sendData(buffer) {
|
|
||||||
let sendBuffer = () => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
var promise = new Promise((succ, err) => {
|
|
||||||
uni.writeBLECharacteristicValue({
|
|
||||||
deviceId: this.connectedDeviceId,
|
|
||||||
serviceId: this.serviceId,
|
|
||||||
characteristicId: this.writeCharacteristicId,
|
|
||||||
value: buffer,
|
|
||||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
|
||||||
success: () => {
|
|
||||||
// console.log("发送数据成功");
|
|
||||||
succ();
|
|
||||||
},
|
|
||||||
fail: (ex) => {
|
|
||||||
if (ex.code == '10007') {
|
|
||||||
// console.log("失败重试");
|
|
||||||
setTimeout(() => {
|
|
||||||
sendBuffer().then(succ).catch(err);
|
|
||||||
}, this.inteval || 0)
|
|
||||||
// succ()
|
|
||||||
|
|
||||||
} else
|
|
||||||
|
|
||||||
{
|
|
||||||
// console.log("发送数据失败",ex);
|
|
||||||
err(ex);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
//console.log("123456");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (plus.os.name == 'iOS') {
|
|
||||||
|
|
||||||
function timeout(ms) {
|
|
||||||
return new Promise((_, err) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
err({
|
|
||||||
code: -1,
|
|
||||||
errMsg: '超时了'
|
|
||||||
})
|
|
||||||
}, ms);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.race([promise, timeout(this.inteval ? this.inteval : 0)]).then(() => {
|
|
||||||
// console.log("成功了");
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((ex) => {
|
|
||||||
|
|
||||||
if (ex.code == -1) {
|
|
||||||
// console.log("超时了")
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject(ex);
|
|
||||||
// console.log("异常了", ex);
|
|
||||||
//sendBuffer().then(resolve).catch(reject);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
|
|
||||||
promise.then(() => {
|
|
||||||
//console.log("then........")
|
|
||||||
resolve();
|
|
||||||
}).catch(() => {
|
|
||||||
//console.log("catch.........")
|
|
||||||
reject()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendBuffer();
|
|
||||||
},
|
|
||||||
CutImg: function() {
|
|
||||||
if (this.imgs.length == 30) {
|
|
||||||
this.shotVideoClick(this.imgs, 'img');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//console.log("开始处理视频")
|
|
||||||
uni.showLoading({
|
|
||||||
title: '开始处理'
|
|
||||||
});
|
|
||||||
this.$refs.compARef.shotVideoClick(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.sending-progress {
|
|
||||||
margin-top: 30rpx;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
height: 12rpx;
|
|
||||||
background-color: #e0e0e0;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background-color: #409eff;
|
|
||||||
transition: width 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
border: 2rpx solid #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
height: 100rpx;
|
|
||||||
line-height: 100rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 300px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,546 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="content">
|
|
||||||
|
|
||||||
<view>
|
|
||||||
<view>
|
|
||||||
选择的视频:{{videoPath}}</view>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
重发包序号:{{reSendNumber}}
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<text>发送间隔</text>
|
|
||||||
<input type="text" v-model="inteval" />
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<button @click="checkVideo">选择视频</button>
|
|
||||||
|
|
||||||
<button @click="uploadVideo">发送</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="sending-progress" v-if="isSending">
|
|
||||||
<view class="progress-bar">
|
|
||||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
|
||||||
</view>
|
|
||||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Common from '../../../utils/Common';
|
|
||||||
import { baseURL } from '../../../utils/request';
|
|
||||||
var mqttClient=null;
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
videoPath: '',
|
|
||||||
inteval: 0,
|
|
||||||
progress: 0,
|
|
||||||
currentPacket: 0,
|
|
||||||
totalPackets: 100,
|
|
||||||
|
|
||||||
connectedDeviceId: '',
|
|
||||||
serviceId: '0xFFE1',
|
|
||||||
writeCharacteristicId: '0xFFE1',
|
|
||||||
notifyCharacteristicId: '0xFFE2',
|
|
||||||
isSending: "",
|
|
||||||
textProgress: "",
|
|
||||||
netMode:"ble",
|
|
||||||
IMEI:"",
|
|
||||||
|
|
||||||
|
|
||||||
imgs: [],
|
|
||||||
videoWidth: 320,
|
|
||||||
videoHeight: 160,
|
|
||||||
videoDuration: 2,
|
|
||||||
|
|
||||||
hexArray: [],
|
|
||||||
reSendNumber:""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
const eventChannel = this.getOpenerEventChannel();
|
|
||||||
|
|
||||||
eventChannel.on('receiveDevice', (data) => {
|
|
||||||
this.connectedDeviceId = data.connectedDeviceId;
|
|
||||||
this.serviceId = data.serviceId;
|
|
||||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
|
||||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
|
||||||
this.netMode=data.netMode;
|
|
||||||
mqttClient=data.mqttClient;
|
|
||||||
this.IMEI=data.IMEI;
|
|
||||||
});
|
|
||||||
|
|
||||||
eventChannel.on('ReSendVideo',(data)=>{
|
|
||||||
//重新发送某一包
|
|
||||||
this.reSendNumber=data.videoNo;
|
|
||||||
setTimeout(()=>{
|
|
||||||
this.shotVideoClick(this.hexArray,'rgb565',data.videoNo);
|
|
||||||
},0);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
checkVideo: function() {
|
|
||||||
uni.chooseVideo({
|
|
||||||
sourceType: ['album', 'camera'],
|
|
||||||
compressed: false,
|
|
||||||
maxDuration: 2,
|
|
||||||
camera: 'back',
|
|
||||||
success: (res) => {
|
|
||||||
this.videoPath = res.tempFilePath;
|
|
||||||
|
|
||||||
this.imgs = [];
|
|
||||||
this.hexArray = [];
|
|
||||||
|
|
||||||
this.videoWidth = res.width;
|
|
||||||
this.videoHeight = res.height;
|
|
||||||
this.videoDuration = res.duration;
|
|
||||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
uploadVideo: function() {
|
|
||||||
|
|
||||||
if (this.hexArray.length > 0) {
|
|
||||||
console.log("开始处理,无需上传");
|
|
||||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(!this.videoPath){
|
|
||||||
uni.showToast({
|
|
||||||
title: "请选择视频",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("正在上传视频");
|
|
||||||
uni.showLoading({
|
|
||||||
title: "上传中"
|
|
||||||
});
|
|
||||||
|
|
||||||
let p2=new Promise((resolve,reject)=>{
|
|
||||||
let start = new Date();
|
|
||||||
console.log("baseURL="+baseURL);
|
|
||||||
const token ="";// uni.getStorageSync('token');
|
|
||||||
const clientid ="";// uni.getStorageSync('clientID');
|
|
||||||
uni.uploadFile({
|
|
||||||
url: 'http://114.55.111.217/video/upload',
|
|
||||||
// url:baseURL+"/app/video/upload",
|
|
||||||
filePath: this.videoPath,
|
|
||||||
name: 'file',
|
|
||||||
header: {
|
|
||||||
"Method": "POST",
|
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
"Authorization": 'Bearer ' + token,
|
|
||||||
"clientid": clientid
|
|
||||||
},
|
|
||||||
timeout: 600000,
|
|
||||||
fail: (ex) => {
|
|
||||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
|
||||||
uni.showToast({
|
|
||||||
title: "视频文件上传失败了,请检查网络连接",
|
|
||||||
icon: 'fail'
|
|
||||||
})
|
|
||||||
uni.hideLoading();
|
|
||||||
reject(ex);
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.hideLoading();
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let p1=this.HoldYouHand();
|
|
||||||
|
|
||||||
Promise.all([p2,p1]).then((arr)=>{
|
|
||||||
|
|
||||||
if(arr[1]===true){
|
|
||||||
let res=arr[0];
|
|
||||||
res = JSON.parse(res.data);
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
this.hexArray = res.data;
|
|
||||||
uni.showLoading({
|
|
||||||
title: "正在发送"
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.shotVideoClick(res.data, 'rgb565');
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("res")
|
|
||||||
uni.showModal({
|
|
||||||
content: "服务器未返回RGB565数据",
|
|
||||||
title: '错误'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
uni.showModal({
|
|
||||||
content:"与设备握手失败了",
|
|
||||||
title:"错误"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
shotVideoClick: function(array, type,ReSendNo) {
|
|
||||||
//console.log("处理视频完成", array);
|
|
||||||
//console.log("type=" + type)
|
|
||||||
//console.log("array=", array);
|
|
||||||
this.imgs = array;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var sendImagePackets = (imageData) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
this.isSending = true;
|
|
||||||
this.progress = 0;
|
|
||||||
this.currentPacket = 0;
|
|
||||||
|
|
||||||
// 总数据包数
|
|
||||||
var totalPackets = 1536;
|
|
||||||
this.totalPackets = totalPackets;
|
|
||||||
let currentPacket = 1;
|
|
||||||
if(ReSendNo){
|
|
||||||
this.progress = ReSendNo-1;
|
|
||||||
this.currentPacket = ReSendNo-1;
|
|
||||||
currentPacket=ReSendNo;
|
|
||||||
totalPackets=ReSendNo;
|
|
||||||
this.totalPackets=ReSendNo;
|
|
||||||
}
|
|
||||||
// 发送单个数据包
|
|
||||||
const sendNextPacket = () => {
|
|
||||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
|
||||||
if (currentPacket > totalPackets) {
|
|
||||||
this.isSending = false;
|
|
||||||
if(!ReSendNo){
|
|
||||||
this.bleSendComplete();
|
|
||||||
}else{
|
|
||||||
// this.reSendNumber="";
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算当前包的数据
|
|
||||||
let packetSize = 250;
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
packetSize = 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建数据包
|
|
||||||
const startIndex = (currentPacket - 1) * packetSize;
|
|
||||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
|
||||||
if (startIndex > endIndex) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
////console.log("111111");
|
|
||||||
const packetData = imageData.slice(startIndex, endIndex);
|
|
||||||
|
|
||||||
// 构建数据包
|
|
||||||
////console.log("packetData.length"+packetData.length);
|
|
||||||
const bufferSize = 506; // 头部5字节 + 数据部分
|
|
||||||
const buffer = new ArrayBuffer(bufferSize);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
let sortNo = currentPacket.toString(16).padStart(4, '0');
|
|
||||||
|
|
||||||
// 填充头部
|
|
||||||
dataView.setUint8(0, 0x55); // 帧头
|
|
||||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
|
||||||
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
|
|
||||||
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
|
|
||||||
|
|
||||||
|
|
||||||
dataView.setUint8(4, 0x01);
|
|
||||||
dataView.setUint8(5, 0xF4);
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < packetData.length; i++) {
|
|
||||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
if(ReSendNo){
|
|
||||||
this.isSending = false;
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 更新进度
|
|
||||||
this.currentPacket = currentPacket;
|
|
||||||
this.progress = Math.round((currentPacket / totalPackets) *
|
|
||||||
100);
|
|
||||||
console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
|
||||||
|
|
||||||
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
|
|
||||||
currentPacket++;
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(sendNextPacket, inteval);
|
|
||||||
}).catch(err => {
|
|
||||||
|
|
||||||
console.log(err.errMsg + ",发送失败了,正在补偿:" + currentPacket);
|
|
||||||
setTimeout(sendNextPacket, inteval);
|
|
||||||
// uni.showToast({
|
|
||||||
// title:"发送失败"+JSON.stringify(err)
|
|
||||||
// })
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sendNextPacket();
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'rgb565') {
|
|
||||||
let start = new Date();
|
|
||||||
console.log("开始发送");
|
|
||||||
sendImagePackets(array).then(() => {
|
|
||||||
console.log("发送完成");
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff-s) / 60;
|
|
||||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
|
||||||
uni.showModal({
|
|
||||||
content: "发送完成,耗时:" + m + "分" + s + "秒",
|
|
||||||
title: 'success'
|
|
||||||
});
|
|
||||||
|
|
||||||
}).catch((ex1) => {
|
|
||||||
console.log("出现了异常", ex1)
|
|
||||||
}).finally(() => {
|
|
||||||
uni.hideLoading();
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
HoldYouHand() {
|
|
||||||
|
|
||||||
var promise=new Promise((resolve,reject)=>{
|
|
||||||
try{
|
|
||||||
let start=new Date();
|
|
||||||
var str = "video transmit start"; //握手的协议字符串
|
|
||||||
console.log("开始握手:"+str)
|
|
||||||
|
|
||||||
// 1. 创建 ArrayBuffer 和 DataView
|
|
||||||
const buffer = new ArrayBuffer(str.length);
|
|
||||||
const dataView = new DataView(buffer);
|
|
||||||
|
|
||||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
dataView.setUint8(i, str.charCodeAt(i));
|
|
||||||
}
|
|
||||||
//console.log("111111");
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
// 开始发送第一个包
|
|
||||||
setTimeout(()=>{
|
|
||||||
|
|
||||||
let end = new Date();
|
|
||||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
|
||||||
let s = diff % 60;
|
|
||||||
let m = (diff - s) / 60;
|
|
||||||
|
|
||||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
}, 2200);
|
|
||||||
|
|
||||||
}).catch(err => {
|
|
||||||
//console.log("握手没有成功");
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
}catch(ex){
|
|
||||||
reject(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
|
|
||||||
},
|
|
||||||
bleSendComplete() {
|
|
||||||
var str = "transmit complete"; //握手的协议字符串
|
|
||||||
let buffer = new ArrayBuffer(str.length);
|
|
||||||
let dataView = new DataView(buffer);
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
dataView.setUint8(i, str.charCodeAt(i));
|
|
||||||
}
|
|
||||||
setTimeout(()=>{
|
|
||||||
this.sendData(buffer).then(() => {
|
|
||||||
console.log("完成指令发送成功");
|
|
||||||
}).catch(err => {
|
|
||||||
console.log("完成指令发送失败");
|
|
||||||
});
|
|
||||||
},3000)
|
|
||||||
|
|
||||||
},
|
|
||||||
sendData(buffer) {
|
|
||||||
if(this.netMode=='ble'){
|
|
||||||
return this.sendBle(buffer);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.sendMQ(buffer);
|
|
||||||
},
|
|
||||||
sendBle(buffer){
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
|
|
||||||
// //console.log("开始发送数据,buffer");
|
|
||||||
|
|
||||||
|
|
||||||
var promise = new Promise((succ, err) => {
|
|
||||||
uni.writeBLECharacteristicValue({
|
|
||||||
deviceId: this.connectedDeviceId,
|
|
||||||
serviceId: this.serviceId,
|
|
||||||
characteristicId: this.writeCharacteristicId,
|
|
||||||
value: buffer,
|
|
||||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
|
||||||
success: () => {
|
|
||||||
// //console.log("发送数据成功");
|
|
||||||
succ();
|
|
||||||
},
|
|
||||||
fail: (ex) => {
|
|
||||||
//console.log("发送数据失败", ex);
|
|
||||||
err(ex);
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
// //console.log("123456");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (plus.os.name == 'iOS') {
|
|
||||||
|
|
||||||
function timeout(ms) {
|
|
||||||
return new Promise((_, err) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
err({
|
|
||||||
code: -1,
|
|
||||||
errMsg: '超时了'
|
|
||||||
})
|
|
||||||
}, ms);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
|
||||||
|
|
||||||
Promise.race([promise, timeout(inteval)]).then(resolve).catch((ex) => {
|
|
||||||
//console.log("ex=", ex);
|
|
||||||
if (ex.code == -1) {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).finally(() => {
|
|
||||||
//console.log("完成了")
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
promise.then(resolve).catch(reject);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
sendMQ(message) {
|
|
||||||
|
|
||||||
const topic = `B/${this.IMEI}`;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if(!mqttClient){
|
|
||||||
reject("MQTT未连接");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
let flag=mqttClient.publish(topic, message, {
|
|
||||||
qos: 1
|
|
||||||
});
|
|
||||||
if(flag){
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reject("MQTT未连接,无法发布消息");
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.sending-progress {
|
|
||||||
margin-top: 30rpx;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
height: 12rpx;
|
|
||||||
background-color: #e0e0e0;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background-color: #409eff;
|
|
||||||
transition: width 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
border: 2rpx solid #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
height: 100rpx;
|
|
||||||
line-height: 100rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 300px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,118 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="container">
|
|
||||||
<view class="grid">
|
|
||||||
<view class="cell" @click="goToDetail(item.name)" v-for="item,index in options">{{item.url}}</view>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
options: [{
|
|
||||||
name: '/pages/BlueTooth/ModeSetting/ModeSetting',
|
|
||||||
url: '7307'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '/pages/BlueTooth/ModeSetting/HBY650',
|
|
||||||
url: 'HBY650'
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// name: '/pages/BlueTooth/ModeSetting/HBY650_1',
|
|
||||||
// url: 'HBY650_V1'
|
|
||||||
// },
|
|
||||||
|
|
||||||
{
|
|
||||||
name: '/pages/BlueTooth/ModeSetting/HBY6155',
|
|
||||||
url: '6155'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '/pages/BlueTooth/ModeSetting/HBY6155V1',
|
|
||||||
url: '6155_V1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "/pages/BlueTooth/ModeSetting/HBY670V1",
|
|
||||||
url: 'HBY670'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "/pages/BlueTooth/ModeSetting/4877",
|
|
||||||
url: '4877'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '/pages/MapTest/MapTest',
|
|
||||||
url: '地图测试'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '',
|
|
||||||
url: '更多'
|
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onShow: () => {
|
|
||||||
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
goToDetail: function(url) {
|
|
||||||
console.log("url=" + url)
|
|
||||||
let qd = () => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '敬请期待',
|
|
||||||
duration: 2000,
|
|
||||||
icon: "none"
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
if (url) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: url,
|
|
||||||
success: () => {
|
|
||||||
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
qd();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
qd();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.container {
|
|
||||||
padding: 15px;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid {
|
|
||||||
display: flex;
|
|
||||||
align-content: space-around;
|
|
||||||
align-items: stretch;
|
|
||||||
justify-items: center;
|
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cell {
|
|
||||||
padding: 0rpx 20rpx;
|
|
||||||
border: 2rpx solid rgba(0, 0, 0, 0.3);
|
|
||||||
border-radius: 15rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
height: 70rpx;
|
|
||||||
line-height: 70rpx;
|
|
||||||
margin-left: 30rpx;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,273 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="update-container">
|
|
||||||
<!-- 进度条 -->
|
|
||||||
<view v-if="showProgress" class="progress-container">
|
|
||||||
<view class="progress-title">正在更新 {{ progress }}%</view>
|
|
||||||
<view class="progress-bar">
|
|
||||||
<view class="progress" :style="{ width: progress + '%' }"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 更新提示弹窗 -->
|
|
||||||
<view v-if="showUpdateDialog" class="dialog-mask">
|
|
||||||
<view class="dialog">
|
|
||||||
<view class="dialog-title">发现新版本 v{{ newVersion }}</view>
|
|
||||||
<view class="dialog-content">{{ updateInfo.desc || '有新的功能和优化,建议立即更新' }}</view>
|
|
||||||
<view class="dialog-buttons">
|
|
||||||
<button v-if="!updateInfo.force" class="cancel-btn" @click="showUpdateDialog = false">稍后更新</button>
|
|
||||||
<button class="confirm-btn" @click="startUpdate">立即更新</button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// 当前版本
|
|
||||||
currentVersion: '',
|
|
||||||
// 最新版本
|
|
||||||
newVersion: '',
|
|
||||||
// 更新信息
|
|
||||||
updateInfo: {},
|
|
||||||
// 是否显示更新弹窗
|
|
||||||
showUpdateDialog: false,
|
|
||||||
// 是否显示进度条
|
|
||||||
showProgress: false,
|
|
||||||
// 更新进度
|
|
||||||
progress: 0
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
// 初始化时检查版本
|
|
||||||
this.checkVersion();
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
/**
|
|
||||||
* 检查当前版本
|
|
||||||
*/
|
|
||||||
async checkVersion() {
|
|
||||||
try {
|
|
||||||
// 获取当前应用版本
|
|
||||||
const versionInfo = plus.runtime.version;
|
|
||||||
this.currentVersion = versionInfo;
|
|
||||||
console.log('当前版本:', this.currentVersion);
|
|
||||||
|
|
||||||
// 调用后端接口检查最新版本
|
|
||||||
// 这里替换为你的后端接口地址
|
|
||||||
const res = await this.$http.get('/api/checkVersion', {
|
|
||||||
platform: uni.getSystemInfoSync().platform,
|
|
||||||
version: this.currentVersion
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res.code === 0 && res.data.hasUpdate) {
|
|
||||||
this.newVersion = res.data.version;
|
|
||||||
this.updateInfo = res.data;
|
|
||||||
// 显示更新提示
|
|
||||||
this.showUpdateDialog = true;
|
|
||||||
} else {
|
|
||||||
console.log('当前已是最新版本');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('版本检查失败:', error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始更新
|
|
||||||
*/
|
|
||||||
startUpdate() {
|
|
||||||
if (!this.updateInfo.downloadUrl) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '更新地址不存在',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.showUpdateDialog = false;
|
|
||||||
this.showProgress = true;
|
|
||||||
this.downloadWgt(this.updateInfo.downloadUrl);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载wgt包
|
|
||||||
*/
|
|
||||||
downloadWgt(url) {
|
|
||||||
const downloadTask = uni.downloadFile({
|
|
||||||
url: url,
|
|
||||||
success: (downloadResult) => {
|
|
||||||
if (downloadResult.statusCode === 200) {
|
|
||||||
// 下载成功,安装wgt包
|
|
||||||
this.installWgt(downloadResult.tempFilePath);
|
|
||||||
} else {
|
|
||||||
this.showProgress = false;
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
this.showProgress = false;
|
|
||||||
console.error('下载失败:', err);
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败,请稍后重试',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 监听下载进度
|
|
||||||
downloadTask.onProgressUpdate((res) => {
|
|
||||||
this.progress = res.progress;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安装wgt包
|
|
||||||
*/
|
|
||||||
installWgt(path) {
|
|
||||||
plus.runtime.install(
|
|
||||||
path,
|
|
||||||
{
|
|
||||||
force: false // 是否强制安装
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
console.log('安装成功');
|
|
||||||
this.showProgress = false;
|
|
||||||
|
|
||||||
// 安装成功后提示重启
|
|
||||||
uni.showModal({
|
|
||||||
title: '更新完成',
|
|
||||||
content: '应用已更新,是否立即重启?',
|
|
||||||
showCancel: !this.updateInfo.force,
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
// 重启应用
|
|
||||||
plus.runtime.restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
console.error('安装失败:', err);
|
|
||||||
this.showProgress = false;
|
|
||||||
uni.showToast({
|
|
||||||
title: '更新失败: ' + err.message,
|
|
||||||
icon: 'none',
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.update-container {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 9999;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 进度条样式 */
|
|
||||||
.progress-container {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 10rpx 20rpx;
|
|
||||||
pointer-events: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-title {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
height: 8rpx;
|
|
||||||
background-color: #eee;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress {
|
|
||||||
height: 100%;
|
|
||||||
background-color: #007aff;
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 弹窗样式 */
|
|
||||||
.dialog-mask {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
pointer-events: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog {
|
|
||||||
width: 600rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-title {
|
|
||||||
font-size: 36rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333;
|
|
||||||
padding: 30rpx;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-content {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #666;
|
|
||||||
padding: 40rpx 30rpx;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-buttons {
|
|
||||||
display: flex;
|
|
||||||
border-top: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn, .confirm-btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 100rpx;
|
|
||||||
line-height: 100rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn {
|
|
||||||
color: #666;
|
|
||||||
border-right: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.confirm-btn {
|
|
||||||
color: #007aff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -17,6 +17,9 @@
|
|||||||
<view class="deviceId">
|
<view class="deviceId">
|
||||||
设备Mac:{{device.macAddress}}
|
设备Mac:{{device.macAddress}}
|
||||||
</view>
|
</view>
|
||||||
|
<view class="deviceId">
|
||||||
|
设备IMEI:{{device.imei}}
|
||||||
|
</view>
|
||||||
<view class="bound" v-bind:class="boundStatu">
|
<view class="bound" v-bind:class="boundStatu">
|
||||||
{{Statu.boundRemark}}
|
{{Statu.boundRemark}}
|
||||||
</view>
|
</view>
|
||||||
@ -63,7 +66,8 @@
|
|||||||
],
|
],
|
||||||
"linkStatu": false,
|
"linkStatu": false,
|
||||||
"macAddress": "",
|
"macAddress": "",
|
||||||
"communicationMode":""
|
"communicationMode":"",
|
||||||
|
"imei":""
|
||||||
},
|
},
|
||||||
serverDevice:null
|
serverDevice:null
|
||||||
}
|
}
|
||||||
@ -118,7 +122,7 @@
|
|||||||
console.log("收到设备消息,", receive);
|
console.log("收到设备消息,", receive);
|
||||||
if (these.device.deviceId == receive.deviceId) {
|
if (these.device.deviceId == receive.deviceId) {
|
||||||
console.log("11111:",receive);
|
console.log("11111:",receive);
|
||||||
|
these.device.imei=f.imei;
|
||||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
||||||
if (f && f.macAddress) {
|
if (f && f.macAddress) {
|
||||||
these.device.macAddress = f.macAddress;
|
these.device.macAddress = f.macAddress;
|
||||||
@ -153,11 +157,14 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// let inteval = setInterval(this.initDevice, 5000);
|
let inteval = setInterval(this.initDevice, 5000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
initDevice: function() {
|
initDevice: function() {
|
||||||
|
if(!these.device.macAddress){
|
||||||
|
return;
|
||||||
|
}
|
||||||
clearTimeout(this.Statu.timeInteval);
|
clearTimeout(this.Statu.timeInteval);
|
||||||
|
|
||||||
this.Statu.timeInteval = setTimeout(() => {
|
this.Statu.timeInteval = setTimeout(() => {
|
||||||
@ -251,7 +258,7 @@
|
|||||||
data: {
|
data: {
|
||||||
deviceImei: '',
|
deviceImei: '',
|
||||||
deviceMac: these.device.macAddress,
|
deviceMac: these.device.macAddress,
|
||||||
communicationMode: '1', //0是4g,1是蓝牙
|
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
promise.then((res) => {
|
promise.then((res) => {
|
||||||
|
|||||||
@ -141,7 +141,6 @@
|
|||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onUnload() {
|
onUnload() {
|
||||||
@ -173,11 +172,11 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("equip=", these.EquipMents)
|
// console.log("equip=", these.EquipMents)
|
||||||
}, pagePath);
|
}, pagePath);
|
||||||
// console.log("addEquip")
|
// console.log("addEquip")
|
||||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||||
if (f.macAddress) {
|
if (f.macAddress && these.device) {
|
||||||
showLoading(these, {
|
showLoading(these, {
|
||||||
text: '正在验证设备'
|
text: '正在验证设备'
|
||||||
});
|
});
|
||||||
@ -200,7 +199,7 @@
|
|||||||
onShow: function() {
|
onShow: function() {
|
||||||
|
|
||||||
|
|
||||||
this.EquipMents = [];
|
// this.EquipMents = [];
|
||||||
this.PairEquip = [];
|
this.PairEquip = [];
|
||||||
ble && ble.StartSearch().catch((ex) => {
|
ble && ble.StartSearch().catch((ex) => {
|
||||||
if (ex.code == 10001) {
|
if (ex.code == 10001) {
|
||||||
|
|||||||
@ -533,6 +533,20 @@ class BleHelper {
|
|||||||
this.updateCache();
|
this.updateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (str.indexOf('imei:') == 0) {
|
||||||
|
let imei = str.split(':')[1];
|
||||||
|
|
||||||
|
|
||||||
|
this.data.LinkedList.find((v) => {
|
||||||
|
if (v.deviceId == receive
|
||||||
|
.deviceId) {
|
||||||
|
v.imei=imei;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.updateCache();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
|
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
|
||||||
console.log("收到mac地址:", bytes)
|
console.log("收到mac地址:", bytes)
|
||||||
if (bytes.length >= 7) {
|
if (bytes.length >= 7) {
|
||||||
@ -669,8 +683,8 @@ class BleHelper {
|
|||||||
let RunSearch = (serviceId) => {
|
let RunSearch = (serviceId) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.startBluetoothDevicesDiscovery({
|
uni.startBluetoothDevicesDiscovery({
|
||||||
services: [serviceId],
|
services:serviceId? [serviceId]:[],
|
||||||
allowDuplicatesKey: false,
|
allowDuplicatesKey: true,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
//console.log('开始搜索蓝牙设备成功');
|
//console.log('开始搜索蓝牙设备成功');
|
||||||
resolve(res);
|
resolve(res);
|
||||||
@ -689,11 +703,11 @@ class BleHelper {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
for (let i = 0; i < serviceIds.length; i++) {
|
// for (let i = 0; i < serviceIds.length; i++) {
|
||||||
|
|
||||||
promises.push(RunSearch(serviceIds[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// promises.push(RunSearch(serviceIds[i]));
|
||||||
|
// }
|
||||||
|
promises.push(RunSearch());
|
||||||
Promise.all(promises).then(resolve).catch(reject);
|
Promise.all(promises).then(resolve).catch(reject);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -1150,7 +1164,7 @@ class BleHelper {
|
|||||||
console.log("正在连接" + deviceId);
|
console.log("正在连接" + deviceId);
|
||||||
uni.createBLEConnection({
|
uni.createBLEConnection({
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
timeout: 3000,
|
timeout: 30000,
|
||||||
success: (info) => {
|
success: (info) => {
|
||||||
console.log("新连接成功", this.data.LinkedList);
|
console.log("新连接成功", this.data.LinkedList);
|
||||||
this.getLinkBlue().then((arr) => {
|
this.getLinkBlue().then((arr) => {
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class BleReceive {
|
|||||||
staticLevelText = '低档';
|
staticLevelText = '低档';
|
||||||
modeCurr = "low";
|
modeCurr = "low";
|
||||||
break;
|
break;
|
||||||
case 0x68:
|
case 0x64:
|
||||||
staticLevelText = '关闭';
|
staticLevelText = '关闭';
|
||||||
modeCurr = "close";
|
modeCurr = "close";
|
||||||
break;
|
break;
|
||||||
@ -274,7 +274,7 @@ class BleReceive {
|
|||||||
case 0x67:
|
case 0x67:
|
||||||
staticLevelText = 'low';
|
staticLevelText = 'low';
|
||||||
break
|
break
|
||||||
case 0x68:
|
case 0x64:
|
||||||
staticLevelText = 'close';
|
staticLevelText = 'close';
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import config from '../config/index.js';
|
import config from '../config/index.js';
|
||||||
const env = 'development'; //production development //开发of线上 改这里就行
|
const env = 'production'; //production development //开发of线上 改这里就行
|
||||||
const BASE = config[env];
|
const BASE = config[env];
|
||||||
const request = (options) => {
|
const request = (options) => {
|
||||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||||
@ -22,7 +22,7 @@ const request = (options) => {
|
|||||||
header: options.header || {},
|
header: options.header || {},
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("res=",res);
|
// console.log("res=",res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ function checkAndUpdateWgt(updateUrl) {
|
|||||||
|
|
||||||
let callbck = (res) => {
|
let callbck = (res) => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
console.log("检查更新成功=", res)
|
// console.log("检查更新成功=", res)
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
|
|
||||||
const updateInfo = res.data.data;
|
const updateInfo = res.data.data;
|
||||||
@ -61,10 +61,11 @@ function checkAndUpdateWgt(updateUrl) {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: {
|
||||||
currentVersion: currentVersion,
|
currentVersion: currentVersion,
|
||||||
platform: uni.getSystemInfoSync().platform
|
platform: uni.getSystemInfoSync().platform,
|
||||||
|
appId:"xhyc"
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("res=>",res)
|
// console.log("res=>",res)
|
||||||
res.type='1';
|
res.type='1';
|
||||||
resolve(res);
|
resolve(res);
|
||||||
},
|
},
|
||||||
@ -129,18 +130,18 @@ function checkAndUpdateWgt(updateUrl) {
|
|||||||
let length = results.length;
|
let length = results.length;
|
||||||
let flag=false;
|
let flag=false;
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
console.log('results[i]=',results[i]);
|
console.log('results['+i+']=',results[i]);
|
||||||
if (results[i].status == 'fulfilled' && results[i].value.type==='1' ) {
|
if (results[i].status == 'fulfilled' && results[i].value.type==='1' && !flag ) {
|
||||||
flag=true;
|
flag=true;
|
||||||
callbck(results[i].value)
|
callbck(results[i].value)
|
||||||
|
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(results[i].status == 'fulfilled' && results[i].value.type!=='1'){
|
if(results[i].status == 'fulfilled' && results[i].value.type!=='1' && !flag){
|
||||||
flag=true;
|
flag=true;
|
||||||
Callback1(results[i].value);
|
Callback1(results[i].value);
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!flag){
|
if(!flag){
|
||||||
|
|||||||
Reference in New Issue
Block a user