Compare commits
7 Commits
b20a93dd28
...
0909d9f023
| Author | SHA1 | Date | |
|---|---|---|---|
| 0909d9f023 | |||
| 1d8b3b4a9a | |||
| a5c6faa9da | |||
| 15ba241317 | |||
| fa64e7f1fc | |||
| 45328120c1 | |||
| 0033649677 |
@ -156,7 +156,7 @@
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
var pagePath = "pages/6155/HBY6155";
|
||||
var pagePath = "/pages/6155/HBY6155";
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -514,11 +514,11 @@
|
||||
|
||||
return f;
|
||||
},
|
||||
bleValueNotify: function(receive, device, path) {
|
||||
bleValueNotify: function(receive, device, path,recArr) {
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
let json = recei.ReceiveData(receive, device, path);
|
||||
let json = recei.ReceiveData(receive, device, path,recArr);
|
||||
if (!json) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@
|
||||
} from '../../utils/request';
|
||||
|
||||
import usrApi from '@/api/670/HBY670.js'
|
||||
const pagePath = "pages/650/HBY650";
|
||||
const pagePath = "/pages/650/HBY650";
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -490,9 +490,9 @@
|
||||
|
||||
return className;
|
||||
},
|
||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||
bleValueNotify: function(receive, device, path,recArr) { //订阅消息
|
||||
console.log("收到设备的数据", receive)
|
||||
let data = recei.ReceiveData(receive, device, pagePath);
|
||||
let data = recei.ReceiveData(receive, device, pagePath,recArr);
|
||||
|
||||
if (data) {
|
||||
if ("staBlue_picture" in data) {
|
||||
|
||||
@ -289,7 +289,7 @@
|
||||
} from '../../utils/request';
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
|
||||
|
||||
const pagePath = "pages/670/HBY670";
|
||||
const pagePath = "/pages/670/HBY670";
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var recei = null;
|
||||
@ -982,9 +982,9 @@
|
||||
this.refreshFormData(receiveData, 'auto');
|
||||
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)
|
||||
if (data) {
|
||||
if ("staBlue_picture" in data) {
|
||||
|
||||
@ -87,63 +87,65 @@
|
||||
<text class="usrtitle fleft">人员信息登记</text>
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<textToDotMatrixFor7305 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="11" />
|
||||
<textToDotMatrixFor7305 class="TextToHex" ref="textToHex" :txts="formData.textLines"
|
||||
:bgColor="'#FFFFFF'" :color="'#000000'" :fontSize="11" / </view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model="formData.textLines[0]" placeholder="请输入单位"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model="formData.textLines[1]" placeholder="请输入姓名"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model="formData.textLines[2]" placeholder="请输入职位"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="proinfo lamp">
|
||||
<text class="title">产品信息</text>
|
||||
<view class="itemcontent">
|
||||
<view class="item" @click="proParam()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/param.png" mode="aspectFit"></image>
|
||||
<text class="txt">产品参数</text>
|
||||
</view>
|
||||
<view class="item" @click="handRemark()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/remark.png" mode="aspectFit"></image>
|
||||
<text class="txt">操作说明</text>
|
||||
</view>
|
||||
<view class="item" @click="handVideo()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/video.png" mode="aspectFit"></image>
|
||||
<text class="txt">操作视频</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model="formData.textLines[0]" placeholder="请输入单位" placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model="formData.textLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model="formData.textLines[2]" placeholder="请输入职位" placeholder-class="usrplace" />
|
||||
</view>
|
||||
<!-- 弹窗通知 -->
|
||||
<MessagePopup :visible="Status.Pop.showPop" :type="Status.Pop.popType" :bgColor="Status.Pop.bgColor"
|
||||
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
||||
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
||||
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
||||
@buttonClick="HidePop" @closePop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
|
||||
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" />
|
||||
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</BottomSlideMenuPlus>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
<view class="proinfo lamp">
|
||||
<text class="title">产品信息</text>
|
||||
<view class="itemcontent">
|
||||
<view class="item" @click="proParam()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/param.png" mode="aspectFit"></image>
|
||||
<text class="txt">产品参数</text>
|
||||
</view>
|
||||
<view class="item" @click="handRemark()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/remark.png" mode="aspectFit"></image>
|
||||
<text class="txt">操作说明</text>
|
||||
</view>
|
||||
<view class="item" @click="handVideo()">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/video.png" mode="aspectFit"></image>
|
||||
<text class="txt">操作视频</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 弹窗通知 -->
|
||||
<MessagePopup :visible="Status.Pop.showPop" :type="Status.Pop.popType" :bgColor="Status.Pop.bgColor"
|
||||
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
||||
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
||||
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
||||
@buttonClick="HidePop" @closePop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
|
||||
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" />
|
||||
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</BottomSlideMenuPlus>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -162,7 +164,7 @@
|
||||
var these = null;
|
||||
var BrighInteval = null;
|
||||
var recei = null;
|
||||
var pagePath = "pages/7305/BJQ7305";
|
||||
var pagePath = "/pages/7305/BJQ7305";
|
||||
export default {
|
||||
components: {
|
||||
textToDotMatrixFor7305
|
||||
@ -273,9 +275,9 @@
|
||||
|
||||
ble.addReceiveCallback(these.bleValueNotify, pagePath);
|
||||
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
|
||||
ble.addStateRecoveryCallback(these.bleStateRecovry,pagePath);
|
||||
ble.addDisposeCallback(these.deviceDispose,pagePath);
|
||||
ble.addRecoveryCallback(these.deviceRecovry,pagePath);
|
||||
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
|
||||
ble.addDisposeCallback(these.deviceDispose, pagePath);
|
||||
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(data) {
|
||||
@ -311,9 +313,9 @@
|
||||
these.formData.img = device.devicePic;
|
||||
these.formData.id = device.id;
|
||||
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("连接成功")
|
||||
these.formData.bleStatu=true;
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
these.setBleFormData();
|
||||
these.getDetail();
|
||||
@ -377,40 +379,40 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deviceRecovry(res){
|
||||
if(this.Status.pageHide){
|
||||
deviceRecovry(res) {
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
if(res.deviceId==these.formData.deviceId){
|
||||
this.formData.bleStatu=true;
|
||||
setTimeout(()=>{
|
||||
hideLoading(these,1000);
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon:'success',
|
||||
title:'蓝牙连接成功'
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
deviceDispose(res){
|
||||
if(this.Status.pageHide){
|
||||
deviceDispose(res) {
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
if(res.deviceId==these.formData.deviceId){
|
||||
this.formData.bleStatu=false;
|
||||
setTimeout(()=>{
|
||||
hideLoading(these,1000);
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = false;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon:'fail',
|
||||
title:'蓝牙连接已断开'
|
||||
icon: 'fail',
|
||||
title: '蓝牙连接已断开'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
bleStateBreak() {
|
||||
if(this.Status.pageHide){
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
//蓝牙适配器不可用
|
||||
@ -423,18 +425,18 @@
|
||||
},
|
||||
bleStateRecovry() {
|
||||
console.log("蓝牙可用");
|
||||
if(this.Status.pageHide){
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("蓝牙可用");
|
||||
console.log("蓝牙可用");
|
||||
//蓝牙适配器再次可用,尝试恢复连接
|
||||
showLoading(this, {
|
||||
text: "蓝牙恢复可用,正在连接设备"
|
||||
});
|
||||
ble.LinkBlue(these.formData.deviceId).then(() => {
|
||||
these.formData.bleStatu = true;
|
||||
updateLoading(these,{
|
||||
text:'连接成功'
|
||||
updateLoading(these, {
|
||||
text: '连接成功'
|
||||
});
|
||||
}).catch(ex => {
|
||||
updateLoading(these, {
|
||||
@ -465,12 +467,12 @@
|
||||
|
||||
return f;
|
||||
},
|
||||
bleValueNotify: function(receive, device, path) {
|
||||
bleValueNotify: function(receive, device, path, recArr) {
|
||||
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
let json = recei.ReceiveData(receive, device, path);
|
||||
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||
|
||||
if (!json) {
|
||||
return;
|
||||
@ -538,7 +540,7 @@
|
||||
events: {
|
||||
BindOver: function(data) {
|
||||
console.log(data)
|
||||
these.formData.bleStatu=true;
|
||||
these.formData.bleStatu = true;
|
||||
}
|
||||
},
|
||||
success: function(res) {
|
||||
@ -580,7 +582,9 @@
|
||||
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;
|
||||
|
||||
// 2. 将完整数据包切片成20字节的小块进行发送
|
||||
@ -608,14 +612,17 @@
|
||||
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
||||
const chunk = fullBuffer.slice(start, end);
|
||||
|
||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(16).padStart(2, '0'));
|
||||
console.log(`发送图片数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(' '));
|
||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(
|
||||
16).padStart(2, '0'));
|
||||
console.log(`发送图片数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(
|
||||
' '));
|
||||
|
||||
updateLoading(these, {
|
||||
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(() => {
|
||||
chunkIndex++;
|
||||
setTimeout(sendNextChunk, 20); // 每个小包之间延时20ms
|
||||
@ -1024,16 +1031,16 @@
|
||||
these.showBleUnConnect()
|
||||
return;
|
||||
}
|
||||
let err=false;
|
||||
this.formData.textLines.find((txt)=>{
|
||||
if(txt.length===0 || txt.length>5){
|
||||
console.log("txt=",txt);
|
||||
err=true;
|
||||
let err = false;
|
||||
this.formData.textLines.find((txt) => {
|
||||
if (txt.length === 0 || txt.length > 5) {
|
||||
console.log("txt=", txt);
|
||||
err = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
if(err){
|
||||
if (err) {
|
||||
this.showPop({
|
||||
message: "单位、部门、姓名必须填写且最多5字",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
@ -1086,10 +1093,13 @@
|
||||
const end = Math.min(start + chunkSize, fullBuffer.byteLength);
|
||||
const chunk = fullBuffer.slice(start, end);
|
||||
|
||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b.toString(16).padStart(2, '0'));
|
||||
console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray.join(' '));
|
||||
const hexArray = Array.from(new Uint8Array(chunk)).map(b => b
|
||||
.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++;
|
||||
setTimeout(sendNextChunk, 30); // 每个小包之间延时30ms
|
||||
}).catch(err => {
|
||||
@ -1239,7 +1249,7 @@
|
||||
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({
|
||||
message: "发送失败," + ex.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
@ -1288,7 +1298,7 @@
|
||||
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({
|
||||
message: "发送失败," + ex.msg,
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
|
||||
@ -771,10 +771,10 @@ class BleHelper {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// console.log("无人订阅消息");
|
||||
console.log("无人订阅消息");
|
||||
}
|
||||
} else {
|
||||
// console.log("无人订阅receivDataCallback,不处理数据");
|
||||
console.log("无人订阅receivDataCallback,不处理数据");
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error("处理订阅消息失败,ex=", ex);
|
||||
|
||||
@ -1,45 +1,36 @@
|
||||
class BleReceive {
|
||||
constructor() {
|
||||
this.StorageKey = "linkedDevices";
|
||||
|
||||
}
|
||||
|
||||
getCurrentPagePath() {
|
||||
|
||||
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;
|
||||
this.HandlerMap = {
|
||||
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
|
||||
'/pages/7305/BJQ7305': this.Receive_6155.bind(this),
|
||||
'/pages/650/HBY650': this.Receive_650.bind(this),
|
||||
'/pages/670/HBY670': this.Receive_670.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
setBleFormData(data,f) {
|
||||
if(data){
|
||||
let linkedList=uni.getStorageSync(this.StorageKey);
|
||||
if(!linkedList){
|
||||
setBleFormData(data, f) {
|
||||
if (data) {
|
||||
let linkedList = uni.getStorageSync(this.StorageKey);
|
||||
if (!linkedList) {
|
||||
return;
|
||||
}
|
||||
linkedList.find((v)=>{
|
||||
if(f.deviceId==v.deviceId){
|
||||
let keys=Object.keys(data);
|
||||
keys.forEach((key)=>{
|
||||
if(!v.formData){
|
||||
v.formData={};
|
||||
linkedList.find((v) => {
|
||||
if (f.deviceId == v.deviceId) {
|
||||
let keys = Object.keys(data);
|
||||
keys.forEach((key) => {
|
||||
if (!v.formData) {
|
||||
v.formData = {};
|
||||
}
|
||||
if(!f.formData){
|
||||
f.formData={};
|
||||
if (!f.formData) {
|
||||
f.formData = {};
|
||||
}
|
||||
v.formData[key]=data[key];
|
||||
f.formData[key]=data[key];
|
||||
v.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) {
|
||||
if(f && f.macAddress && f.device && f.device.id){
|
||||
let data={};
|
||||
if(f.device.detailPageUrl=='/pages/6155/deviceDetail' || f.device.detailPageUrl=='/pages/7305/BJQ7305'){
|
||||
// console.log("该设备是6155");
|
||||
data= this.Receive_6155(receive,f,path,recArr);
|
||||
ReceiveData(receive, f, path, recArr) {
|
||||
if (f && f.macAddress && f.device && f.device.id) {
|
||||
let handler = null;
|
||||
let keys = Object.keys(this.HandlerMap);
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
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'){
|
||||
// console.log("该设备是650");
|
||||
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;
|
||||
}else{
|
||||
console.log("已收到该消息,但无法处理",receive);
|
||||
}
|
||||
|
||||
return receive;
|
||||
if (handler) {
|
||||
let data = handler(receive, f, path, recArr);
|
||||
return data;
|
||||
} else {
|
||||
console.log("已收到消息,但无指定处理程序", receive);
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("已收到该消息,但无法处理", receive);
|
||||
}
|
||||
|
||||
return receive;
|
||||
|
||||
}
|
||||
|
||||
Receive_650(receive,f,path,recArr) {
|
||||
console.log("通用程序正在处理650的数据",receive);
|
||||
Receive_650(receive, f, path, recArr) {
|
||||
console.log("通用程序正在处理650的数据", receive);
|
||||
|
||||
var parseData = () => {
|
||||
let bytes = receive.bytes;
|
||||
@ -145,45 +138,47 @@ class BleReceive {
|
||||
warn = '非常强预警';
|
||||
}
|
||||
|
||||
let formData={};
|
||||
let formData = {};
|
||||
formData.battary = batteryLevel;
|
||||
formData.xuhang = xuhang;
|
||||
formData.cMode = lightingLevelByte === 0x6e;
|
||||
formData.modeCurr = modeCurr;
|
||||
formData.warnLevel = warn;
|
||||
formData.iswarn = iswarn;
|
||||
this.setBleFormData(formData,f);
|
||||
this.setBleFormData(formData, f);
|
||||
|
||||
let route=this.getCurrentPagePath();
|
||||
console.log("f=",f);
|
||||
console.log("route="+route);
|
||||
if (iswarn && f.detailPageUrl.indexOf(route)==-1 ) {
|
||||
uni.showModal({
|
||||
content:"环境存在漏电电源",
|
||||
title:"警告",
|
||||
success(res){
|
||||
if(res.confirm){
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||
.replaceAll('/', '').toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
|
||||
if(f){
|
||||
uni.navigateTo({
|
||||
url: f.detailPageUrl,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: f,
|
||||
deviceType: '',
|
||||
apiType: 'listA'
|
||||
});
|
||||
}
|
||||
});
|
||||
if (iswarn) {
|
||||
uni.showModal({
|
||||
content: "环境存在漏电电源",
|
||||
title: "警告",
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
|
||||
if (f) {
|
||||
uni.navigateTo({
|
||||
url: f.detailPageUrl,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: f,
|
||||
deviceType: '',
|
||||
apiType: 'listA'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}else{
|
||||
console.log("当前全局不处理此消息");
|
||||
})
|
||||
}
|
||||
}
|
||||
return formData;
|
||||
} catch (error) {
|
||||
@ -197,47 +192,44 @@ class BleReceive {
|
||||
let str = receive.str;
|
||||
|
||||
if (str.indexOf('mac address:') == 0) {
|
||||
let formData={};
|
||||
let formData = {};
|
||||
formData.macAddress = str.split(':')[1];
|
||||
this.setBleFormData(formData,f);
|
||||
this.setBleFormData(formData, f);
|
||||
return formData;
|
||||
}
|
||||
else{
|
||||
let receiveData={a:1};
|
||||
} else {
|
||||
let receiveData = {
|
||||
a: 1
|
||||
};
|
||||
try {
|
||||
let json=JSON.parse(str);
|
||||
let json = JSON.parse(str);
|
||||
|
||||
if("staBlue_picture" in json){
|
||||
if ("staBlue_picture" in json) {
|
||||
//重发图片
|
||||
console.log("收到重新发送图片的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue_text" in json){
|
||||
receiveData = json;
|
||||
} else if ("staBlue_text" in json) {
|
||||
//重发文本
|
||||
console.log("收到重新发送文本的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue_vidio" in json){
|
||||
receiveData = json;
|
||||
} else if ("staBlue_vidio" in json) {
|
||||
//重发视频
|
||||
console.log("收到重新发送视频的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue" in json){
|
||||
if(json.staBlue=="finish"){
|
||||
receiveData = json;
|
||||
} else if ("staBlue" in json) {
|
||||
if (json.staBlue == "finish") {
|
||||
console.log("收到设备回复,全部传输完成");
|
||||
receiveData=json;
|
||||
receiveData = json;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
receiveData={};
|
||||
} else {
|
||||
receiveData = {};
|
||||
console.log("无法解析该文本");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
receiveData={};
|
||||
receiveData = {};
|
||||
console.log("文本解析失败")
|
||||
}
|
||||
return receiveData;
|
||||
@ -250,41 +242,42 @@ class BleReceive {
|
||||
|
||||
}
|
||||
|
||||
let data=parseData(receive.bytes);
|
||||
console.log("data=",data);
|
||||
let data = parseData(receive.bytes);
|
||||
console.log("data=", data);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
Receive_670(receive,f,path,recArr){
|
||||
console.log("pagh=",path);
|
||||
var todo = (bytes) =>{
|
||||
Receive_670(receive, f, path, recArr) {
|
||||
console.log("pagh=", path);
|
||||
var todo = (bytes) => {
|
||||
// console.log("todo",receive);
|
||||
let receiveData = {};
|
||||
if (bytes[0] == 0x55) {
|
||||
try {
|
||||
// console.log("todo");
|
||||
// console.log("todo");
|
||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||
let staticLevelByte = bytes[1];
|
||||
let staticLevelText = '';
|
||||
switch (staticLevelByte) {
|
||||
case 0x65:
|
||||
staticLevelText = 'hight';
|
||||
break
|
||||
case 0x66:
|
||||
staticLevelText = 'center';
|
||||
break
|
||||
case 0x67:
|
||||
staticLevelText = 'low';
|
||||
break
|
||||
case 0x64:
|
||||
staticLevelText = 'close';
|
||||
break
|
||||
case 0x65:
|
||||
staticLevelText = 'hight';
|
||||
break
|
||||
case 0x66:
|
||||
staticLevelText = 'center';
|
||||
break
|
||||
case 0x67:
|
||||
staticLevelText = 'low';
|
||||
break
|
||||
case 0x64:
|
||||
staticLevelText = 'close';
|
||||
break
|
||||
}
|
||||
// console.log("todo");
|
||||
// console.log("todo");
|
||||
// 解析照明档位
|
||||
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];
|
||||
@ -293,7 +286,7 @@ class BleReceive {
|
||||
let batteryLevelByte = bytes[5];
|
||||
|
||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||
// console.log("todo");
|
||||
// console.log("todo");
|
||||
let warn = bytes[6];
|
||||
if (warn == 0x00) {
|
||||
warn = 'none';
|
||||
@ -307,34 +300,35 @@ class BleReceive {
|
||||
warn = 'veryhight';
|
||||
}
|
||||
|
||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
||||
let staticWarn = bytes[7] == 0x01; //静止报警
|
||||
let fourGStrenth = bytes[8]; //4g信号强度
|
||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||
// console.log("todo");
|
||||
// console.log("todo");
|
||||
receiveData.modeCurr = staticLevelText;
|
||||
receiveData.lightCurr = lightingLevelText;
|
||||
receiveData.xuhang = lightingTime ;
|
||||
receiveData.xuhang = lightingTime;
|
||||
receiveData.battary = batteryLevel;
|
||||
receiveData.warnLevel = warn;
|
||||
receiveData.staticWarn = staticWarn;
|
||||
receiveData.fourGStrenth = fourGStrenth;
|
||||
receiveData.SOS=sosTxt;
|
||||
receiveData.SOS = sosTxt;
|
||||
|
||||
this.setBleFormData(receiveData,f);
|
||||
console.log("recArr=",recArr);
|
||||
let recCnt=recArr.find(v=>{
|
||||
return v.key == f.device.detailPageUrl;
|
||||
this.setBleFormData(receiveData, f);
|
||||
console.log("recArr=", recArr);
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||
.replaceAll('/', '').toLowerCase();
|
||||
});
|
||||
if(!recCnt){
|
||||
if (!recCnt) {
|
||||
if (this.formData.staticWarn) { //有静止报警
|
||||
uni.showModal({
|
||||
title:"警告",
|
||||
content:"设备静止报警中",
|
||||
showCancel:false
|
||||
});
|
||||
uni.showModal({
|
||||
title: "警告",
|
||||
content: "设备静止报警中",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
// console.log("todo");
|
||||
@ -348,7 +342,7 @@ class BleReceive {
|
||||
}
|
||||
if (str.indexOf('mac address:') == 0) {
|
||||
receiveData.macAddress = str.split(':').slice(1).join(":");
|
||||
console.log('收到mac地址:', +this.receiveData.macAddress);
|
||||
console.log('收到mac地址:', +this.receiveData.macAddress);
|
||||
} else if (str.indexOf('imei:') == 0) {
|
||||
receiveData.imei = str.split(':')[1];
|
||||
console.log('收到IEMI:', +this.receiveData.macAddress);
|
||||
@ -362,58 +356,55 @@ class BleReceive {
|
||||
} else {
|
||||
try {
|
||||
// console.log("str=",str);
|
||||
let json=JSON.parse(str);
|
||||
if("staBlue_picture" in json){
|
||||
let json = JSON.parse(str);
|
||||
if ("staBlue_picture" in json) {
|
||||
//重发图片
|
||||
console.log("收到重新发送图片的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue_text" in json){
|
||||
receiveData = json;
|
||||
} else if ("staBlue_text" in json) {
|
||||
//重发文本
|
||||
console.log("收到重新发送文本的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue_vidio" in json){
|
||||
receiveData = json;
|
||||
} else if ("staBlue_vidio" in json) {
|
||||
//重发视频
|
||||
console.log("收到重新发送视频的命令");
|
||||
receiveData=json;
|
||||
}
|
||||
else if("staBlue" in json){
|
||||
if(json.staBlue=="finish"){
|
||||
receiveData = json;
|
||||
} else if ("staBlue" in json) {
|
||||
if (json.staBlue == "finish") {
|
||||
console.log("收到设备回复,全部传输完成");
|
||||
receiveData=json;
|
||||
receiveData = json;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
receiveData={};
|
||||
} else {
|
||||
receiveData = {};
|
||||
console.log("无法解析该文本");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
receiveData={};
|
||||
receiveData = {};
|
||||
// console.log("文本解析失败",error)
|
||||
}
|
||||
}
|
||||
} catch(ex) {
|
||||
receiveData={};
|
||||
} catch (ex) {
|
||||
receiveData = {};
|
||||
console.log('将数据转文本失败', ex);
|
||||
}
|
||||
}
|
||||
// console.log("todo",receiveData);
|
||||
this.setBleFormData(receiveData,f);
|
||||
this.setBleFormData(receiveData, f);
|
||||
return receiveData;
|
||||
}
|
||||
|
||||
|
||||
let data=todo(receive.bytes);
|
||||
let data = todo(receive.bytes);
|
||||
|
||||
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) {
|
||||
try {
|
||||
|
||||
@ -467,22 +458,32 @@ class BleReceive {
|
||||
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||
lightingTime = HH + "小时" + mm + "分钟";
|
||||
let formData={};
|
||||
let formData = {};
|
||||
formData.mode = staticLevelText;
|
||||
formData.fuMode = lightingLevelText;
|
||||
formData.battary = batteryLevel;
|
||||
formData.battary = batteryLevel;
|
||||
formData.statu = warn;
|
||||
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);
|
||||
return formData;
|
||||
|
||||
|
||||
this.setBleFormData(formData, f);
|
||||
return formData;
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user