1
0
forked from dyf/APP

Compare commits

...

7 Commits

22 changed files with 3700 additions and 943 deletions

View File

@ -0,0 +1,159 @@
/**
* HBY102J 晶全应用层协议:下行 FA … FF上行 FB/FC … FF。
* 与 HBY100-J 使用同一颗蓝牙模组 / 同一套 GATTAE30 + AE03 写 + AE02 通知),
* 见 `api/100J/HBY100-J.js` 中 SERVICE_UUID / WRITE / NOTIFY仅帧语义与 100J 不同。
*/
export const HBY102J_SERVICE = '0000AE30-0000-1000-8000-00805F9B34FB'
export const HBY102J_WRITE = '0000AE03-0000-1000-8000-00805F9B34FB'
export const HBY102J_NOTIFY = '0000AE02-0000-1000-8000-00805F9B34FB'
function buildFaFrame(func, dataBytes = []) {
return [0xfa, func & 0xff, ...dataBytes.map((b) => b & 0xff), 0xff]
}
const BYTE_TO_RADAR = {
0: 'status_off',
1: 'status_2M',
2: 'status_4M',
3: 'status_7M',
4: 'status_10M'
}
const BYTE_TO_LED = {
0: 'led_off',
1: 'led_flash',
2: 'led_low_flash',
3: 'led_steady',
4: 'led_alarm'
}
const RADAR_KEY_TO_BYTE = {
status_off: 0,
status_2M: 1,
status_4M: 2,
status_7M: 3,
status_10M: 4,
status_on: 1
}
const LED_KEY_TO_BYTE = {
led_off: 0,
led_flash: 1,
led_low_flash: 2,
led_steady: 3,
led_alarm: 4
}
export function encodeChannelSet(channelDecimal1to80) {
const ch = Math.max(1, Math.min(80, Number(channelDecimal1to80) || 1))
return buildFaFrame(0x21, [ch])
}
export function encodeOnline(on) {
return buildFaFrame(0x22, [on ? 1 : 0])
}
export function encodeRadarFromUiKey(sta_RadarType) {
const b = RADAR_KEY_TO_BYTE[sta_RadarType] !== undefined ? RADAR_KEY_TO_BYTE[sta_RadarType] : 0
return buildFaFrame(0x23, [b])
}
export function encodeWarningLightFromLedKey(ledKey) {
const m = LED_KEY_TO_BYTE[ledKey] !== undefined ? LED_KEY_TO_BYTE[ledKey] : 0
return buildFaFrame(0x24, [m])
}
export function encodeQueryOnlineCount() {
return buildFaFrame(0x25, [0])
}
export function encodeQueryPower() {
return buildFaFrame(0x26, [])
}
function formatMacFromBytes(u8, start, len) {
const hex = []
for (let i = 0; i < len; i++) {
hex.push(u8[start + i].toString(16).padStart(2, '0'))
}
return hex.join(':').toUpperCase()
}
/**
* 解析设备上行一帧Notify输出与 HBY102 页 formData 对齐的字段
*/
export function parseHby102jUplink(u8) {
const out = {}
if (!u8 || u8.length < 3) return out
const h = u8[0]
const func = u8[1]
const tail = u8[u8.length - 1]
if (tail !== 0xff && u8.length >= 4) {
// 非标准结尾时仍尽量解析
}
if (h === 0xfc && u8.length >= 8 && u8[7] === 0xff) {
out.sta_address = formatMacFromBytes(u8, 1, 6)
return out
}
if (h !== 0xfb) return out
switch (func) {
case 0x21:
if (u8.length >= 4) {
out.sta_Channel = u8[2]
}
break
case 0x22:
out.sta_Online = u8[2] === 1 ? 'E49_on' : 'E49_off'
break
case 0x23:
out.sta_RadarType = BYTE_TO_RADAR[u8[2]] !== undefined ? BYTE_TO_RADAR[u8[2]] : 'status_off'
break
case 0x24:
out.sta_LedType = BYTE_TO_LED[u8[2]] !== undefined ? BYTE_TO_LED[u8[2]] : 'led_off'
break
case 0x25:
if (u8.length >= 4) {
out.sta_onlineQuantity = u8[2]
}
break
case 0x26:
if (u8.length >= 5) {
out.sta_PowerPercent = u8[2]
out.sta_charge = u8[3]
}
break
case 0x27:
if (u8.length >= 9) {
out.sta_PowerPercent = u8[2]
out.sta_charge = u8[3]
out.sta_Channel = u8[4]
out.sta_LedType = BYTE_TO_LED[u8[5]] !== undefined ? BYTE_TO_LED[u8[5]] : 'led_off'
out.sta_RadarType = BYTE_TO_RADAR[u8[6]] !== undefined ? BYTE_TO_RADAR[u8[6]] : 'status_off'
out.sta_Online = u8[7] === 1 ? 'E49_on' : 'E49_off'
}
break
case 0x28:
if (u8.length >= 10) {
const peerMac = formatMacFromBytes(u8, 2, 6)
const ev = u8[8]
if (ev === 0x01) {
out.sta_sosadd = peerMac
out.sta_Intrusion = 1
} else if (ev === 0x02) {
out.sta_sosadd_off = peerMac
} else if (ev === 0x03) {
out.sta_tomac = peerMac
}
}
break
default:
break
}
return out
}

View File

@ -347,6 +347,14 @@
"navigationBarTitleText" : "HBY102"
}
},
{
"path" : "pages/102J/HBY102J",
"style" :
{
"navigationStyle": "custom",
"navigationBarTitleText" : "HBY102"
}
},
{
"path" : "pages/common/user/logOff",
"style" :

View File

@ -215,7 +215,7 @@
sta_leftFan: null,
sta_rightFan: null,
sta_channel: null,
sta_Ms: null,
sta_Ms: 'S',
sta_PowerPercent: null,
sta_PowerTime: null,
sta_system: null,
@ -379,6 +379,12 @@
these.formData.deviceId = v.deviceId;
return true;
}
if(v.device){
if(v.device.id==device.id){
these.formData.deviceId = v.deviceId;
return true;
}
}
return false;
});
if (!f) {
@ -603,14 +609,24 @@
},
getDevice: function() {
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
showBleUnConnect() {
@ -994,10 +1010,11 @@
border-width: 5rpx;
border-color: #00000000;
padding: 5rpx;
height:130rpx !important;
}
.lampMode .type .txt {
color: rgba(255, 255, 255, 0.2);
color: rgba(255, 255, 255, 0.5);
background-color: #00000000;
font-family: "PingFang SC";
font-size: 50rpx;

View File

@ -1160,14 +1160,23 @@
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
});
if (f) {
this.formData.deviceId = f.deviceId;
let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},

View File

@ -509,14 +509,7 @@
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f =this.getDevice();
if (!f) {
@ -1300,12 +1293,23 @@ onFreqChanging(e){
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},

View File

@ -248,14 +248,7 @@
if (these.device.deviceImei) {
these.initMQ();
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f =these.getDevice();
if (!f) {
these.showBleUnConnect();
these.getDetail();
@ -472,7 +465,27 @@
})
}
},
getDevice: function() {
let f = ble.data.LinkedList.find((v) => {
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
}
}
}
</script>

View File

@ -459,14 +459,7 @@ created() {
}
these.device = device;
these.getWarns();
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
@ -1304,13 +1297,27 @@ created() {
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
bleStatuToggle() {

2306
pages/102J/HBY102J.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -562,14 +562,7 @@
if (these.device.deviceImei) {
these.initMQ();
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.showBleUnConnect();
these.getDetail();
@ -1468,18 +1461,22 @@
},
getDevice: function() {
let f ={deviceId:'123'};
// #ifdef APP
f= ble.data.LinkedList.find((v) => {
if (v.macAddress == these.device.deviceMac) {
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
let f = ble.data.LinkedList.find((v) => {
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #endif
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},

View File

@ -531,14 +531,7 @@
});
})
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
@ -1271,12 +1264,23 @@
},
getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("formData=", these.device);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
@ -1614,7 +1618,8 @@
border-color: #aed600 !important;
}
.lampMode .mode.active .bigTxt,.lampMode .mode.active .smallTxt {
.lampMode .mode.active .bigTxt,
.lampMode .mode.active .smallTxt {
color: #aed600 !important;
}

View File

@ -624,6 +624,9 @@
this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
console.log("电量发生变化");
if(!newVal){
return;
}
if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
//电量在20%及以及下,且是未充电状态提醒
showPop({
@ -1282,17 +1285,23 @@
},
getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == these.device.deviceMac) {
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
showBleUnConnect() {
@ -1524,7 +1533,8 @@
},
gotoMap() {
let promise = Promise.resolve([this.formData.sta_longitude, this.formData
.sta_latitude]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
.sta_latitude
]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
promise.then(lnglat => {
this.detailData.longitude = lnglat[0];

View File

@ -377,14 +377,7 @@
// console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
these.device = device;
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
@ -803,12 +796,23 @@
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
@ -1846,6 +1850,4 @@
.volMath {
color: rgba(174, 214, 0, 1);
}
</style>

View File

@ -37,7 +37,8 @@
<view class="row">
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt" v-show="getMode('main')!='关闭'||getMode('fu')!='关闭'">{{formData.xuhang}}</view>
<view class="bigTxt" v-show="getMode('main')!='关闭'||getMode('fu')!='关闭'">{{formData.xuhang}}
</view>
<view class="smallTxt">续航时间</view>
</view>
</view>
@ -375,14 +376,7 @@
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.getDetail();
@ -665,12 +659,23 @@
})
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
bleValueNotify: function(receive, device, path, recArr) {
@ -1748,7 +1753,9 @@
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
these.formData.textLines=[personnelInfo.position, personnelInfo.name,personnelInfo.unitName];
these.formData.textLines = [personnelInfo.position, personnelInfo.name, personnelInfo
.unitName
];
}
}
});

View File

@ -344,14 +344,7 @@
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.getDetail();
@ -632,12 +625,23 @@
})
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
bleValueNotify: function(receive, device, path, recArr) {

View File

@ -557,14 +557,22 @@
if (ble) {
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == this.itemInfo.deviceMac) {
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
}
return null;
@ -2117,14 +2125,7 @@
this.initBle();
console.log("ble=", ble);
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == this.itemInfo.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (f) {
these.formData.bleStatu = 'connecting';

View File

@ -218,7 +218,9 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js';
import request, {
baseURL
} from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js';
import {
@ -360,14 +362,7 @@ import request, { baseURL } from '@/utils/request.js';
// console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
these.device = device;
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
@ -693,12 +688,23 @@ import request, { baseURL } from '@/utils/request.js';
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
getDetail() {

View File

@ -113,8 +113,7 @@
</view>
</view>
<view class="mode marginLeft fleft"
v-on:click.stop="ShowUpload()">
<view class="mode marginLeft fleft" v-on:click.stop="ShowUpload()">
<view class="leftImg">
<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
</view>
@ -183,7 +182,9 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js';
import request, {
baseURL
} from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js';
import {
@ -334,14 +335,7 @@ created() {
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
@ -640,12 +634,23 @@ created() {
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
getDetail() {

View File

@ -1,7 +1,7 @@
<template>
<view class="content contentBg">
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true"
background-color="#121212" color="#FFFFFF" :title="Status.navbar.title">
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left>
<view>
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
@ -9,7 +9,8 @@
</template>
<block slot="right">
<view class="navbarRight center">
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons" class="img" :src="item.src" mode="aspectFit"></image>
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
class="img" :src="item.src" mode="aspectFit"></image>
</view>
</block>
@ -287,7 +288,9 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js';
import request, {
baseURL
} from '@/utils/request.js';
import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
import {
MsgSuccess,
@ -511,14 +514,7 @@
if (these.device.deviceImei) {
these.initMQ();
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.showBleUnConnect();
these.getDetail();
@ -931,7 +927,8 @@
// console.log("收到文本回复", payload);
// // this.SendTxtMQ(json);
// }
if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
if (keys.indexOf('sta_BreakNews') > -
1) { //紧急通知
if (json.sta_BreakNews == 'I get it') {
showPop({
showPop: true,
@ -1134,12 +1131,23 @@
},
getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
setBleFormData() {
@ -3345,6 +3353,7 @@
height: 35rpx;
margin-right: 30rpx;
}
.uni-navbar--fixed {
top: 0rpx;
}

View File

@ -119,15 +119,18 @@
<view class="item">
<text class="lbl">单位</text>
<input class="value" maxlength="5" v-model="formData.inputLines[0]" placeholder="请输入单位" placeholder-class="usrplace" />
<input class="value" maxlength="5" v-model="formData.inputLines[0]" placeholder="请输入单位"
placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">部门</text>
<input class="value" maxlength="5" v-model="formData.inputLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" />
<input class="value" maxlength="5" v-model="formData.inputLines[1]" placeholder="请输入姓名"
placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">姓名</text>
<input class="value" maxlength="5" v-model="formData.inputLines[2]" placeholder="请输入职位" placeholder-class="usrplace" />
<input class="value" maxlength="5" v-model="formData.inputLines[2]" placeholder="请输入职位"
placeholder-class="usrplace" />
</view>
</view>
@ -320,14 +323,7 @@
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.getDetail();
@ -568,12 +564,23 @@
})
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
bleValueNotify: function(receive, device, path, recArr) {
@ -1184,7 +1191,9 @@ debugger;
}
this.formData.textLines=[this.formData.inputLines[0],this.formData.inputLines[1],this.formData.inputLines[2]];
this.formData.textLines = [this.formData.inputLines[0], this.formData.inputLines[1], this.formData
.inputLines[2]
];
showLoading(these, {
text: "发送中..."
@ -1234,7 +1243,10 @@ debugger;
.toString(16).padStart(2, '0'));
console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray
.join(' '));
updateLoading(these,{text:'正在发送'+((index-1)*14+chunkIndex + 1)+'/42'})
updateLoading(these, {
text: '正在发送' + ((index - 1) * 14 + chunkIndex +
1) + '/42'
})
ble.sendData(f.deviceId, chunk, f.writeServiceId, f
.wirteCharactId, 100).then(() => {
chunkIndex++;
@ -1344,7 +1356,9 @@ debugger;
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
these.formData.inputLines=[personnelInfo.position,personnelInfo.name,personnelInfo.unitName];
these.formData.inputLines = [personnelInfo.position, personnelInfo.name, personnelInfo
.unitName
];
}
}
});

View File

@ -58,7 +58,7 @@
</view>
<view class="list searchList">
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
v-show="item.name.indexOf(search)>-1">
v-show="item.name.toLowerCase().indexOf(search.toLowerCase())>-1">
<view class="before" v-if="item.isTarget"></view>
<view class="leftImg ">
<image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="heightFix">
@ -131,7 +131,7 @@
var ble = null;
var these = null;
var eventChannel = null;
var sortTime = null;
export default {
data() {
return {
@ -276,7 +276,7 @@
}
console.log("处理蓝牙不可用");
hideLoading(these);
clearInterval(these.Status.intval);
these.PairEquip = [];
these.EquipMents = [];
uni.showToast({
@ -310,14 +310,12 @@
if (these.Status.isPageHidden) {
return;
}
// console.log("处理蓝牙断开连接");
console.log("处理蓝牙断开连接");
if(res.deviceId==this.item.deviceId){
these.item.deviceId = null;
these.refreshLinked();
setTimeout(() => {
hideLoading(these);
}, 1500);
clearInterval(these.Status.intval);
}
}, pagePath);
@ -357,16 +355,23 @@
device.isTarget = true;
}
}
// 102J与 100J 同 AE30 芯片;协议不同。广播名一般为 HBY102J-xxxxxx见协议
if (device.name && /^HBY102J/i.test(device.name)) {
device.isTarget = true;
}
if (device.name) {
device.name = device.name.replace('JQZM-', '');
device.name = device.name.replace(/^HBY102J-/i, '');
}
these.EquipMents.push(device);
}
}
clearTimeout(sortTime);
sortTime = setTimeout(() => {
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI);
}, 500);
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
}, pagePath);
@ -402,9 +407,12 @@
return;
}
if (receivData.str.indexOf('mac address:') > -1 || receivData.str.indexOf(
'sta_address') > -1 ||
(receivData.bytes[0] === 0xFC && receivData.bytes.length >= 7)) {
if (f.deviceId == this.item.deviceId) {//只处理本次连接的设备消息
if ((receivData.str && (receivData.str.indexOf('mac address:') > -1 || receivData
.str.indexOf(
'sta_address') > -1)) ||
(receivData.bytes && receivData.bytes[0] === 0xFC && receivData.bytes.length >=
7)) {
if (f.macAddress && these.device) {
@ -421,6 +429,7 @@
}, 0);
}
}
}
}, pagePath);
}
}
@ -628,9 +637,9 @@
}
hideLoading(these);
these.device.bleId = deviceId;
eventChannel.emit('BindOver', these.device);
ble.updateCache();
eventChannel.emit('BindOver', these.device);
uni.navigateBack();
}
@ -638,7 +647,8 @@
if (f && f.macAddress) {
if (!these.device || !these.device.deviceMac) { //走服务端验证
console.error("走服务端验证")
console.error("理论上永远不会走这里,走服务端验证");
console.error("我TM太相信理论了");
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
@ -646,8 +656,6 @@
deviceMac: f.macAddress
}
}).then(res => {
if (res && res.code == 200) {
let data = res.data;
@ -697,17 +705,7 @@
clearInterval(this.Status.intval)
this.Status.intval = null;
this.Status.time = null;
f = ble.data.LinkedList.find(v => {
if (v.deviceId == deviceId) {
v.device = these.device;
return true;
}
return false;
});
if (!(f && f.macAddress)) {
deviceInvalid()
return;
}
deviceInvalid();
return;
}
@ -725,9 +723,9 @@
return false;
},
Link: function(item) {
this.item.deviceId = item.deviceId;
showLoading(this, {
text: "正在连接:第1次"
text: "正在连接..."
});
let index = 1;
@ -765,15 +763,18 @@
ble.LinkBlue(item.deviceId).then((res) => {
this.tmpLink = [item];
console.log("连接成功");
ble.StopSearch();
these.item.deviceId = item.deviceId;
ble.StopSearch().catch(ex=>{});
resolve(res);
}).catch((ex) => {
if (index == total) {
console.log("连接了N次都没连上");
reject(ex);
updateLoading(this, {
text: ex.msg
})
});
this.item.deviceId =null;
return;
}
index++;

View File

@ -164,7 +164,20 @@ class BleHelper {
//更新缓存
updateCache() {
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
let task =async () => {
await uni.setStorage({
key: this.StorageKey,
data: this.data.LinkedList,
success() {
},
fail(ex) {
console.error("更新蓝牙缓存失败");
}
});
}
task();
}
//连接所有已连接过的设备
@ -933,7 +946,9 @@ class BleHelper {
return false;
});
this.updateCache();
if (f && f.device && f.device.id && this.data.available) {
//已绑定过的设备尝试重连
let fdis = this.data.Disconnect.find(dis => {
return dis === res.deviceId
}); //用户主动断开的,不再重连
@ -954,6 +969,9 @@ class BleHelper {
}
}else{
//未绑定过的设备播放连接锁
delete this.data.connectingDevices[res.deviceId];
}
if (this.cfg.bleDisposeCallback.length > 0) {
@ -1613,7 +1631,6 @@ class BleHelper {
}
}
if (this.data.platform == 'web') {
LinkedCallback();
return Promise.resolve(true);
@ -1711,9 +1728,11 @@ class BleHelper {
if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true;
this.data.LinkedList[fIndex].linkId =linkId;
this.data.LinkedList[fIndex].linkId =
linkId;
this.data.LinkedList[fIndex].name = cr.name;
this.data.LinkedList[fIndex].advertisData =cr.advertisData;
this.data.LinkedList[fIndex].advertisData =
cr.advertisData;
} else {
this.data.LinkedList.push(cr);
}

View File

@ -2,6 +2,9 @@ import Common from '@/utils/Common.js'
import {
parseBleData
} from '@/api/100J/HBY100-J.js'
import {
parseHby102jUplink
} from '@/api/102J/hby102jBleProtocol.js'
import {
MsgSuccess,
MsgError,
@ -30,6 +33,7 @@ class BleReceive {
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
'/pages/100/HBY100': this.Receive_100.bind(this),
'/pages/102/HBY102': this.Receive_102.bind(this),
'/pages/102J/HBY102J': this.Receive_102J.bind(this),
'/pages/6170/deviceControl/index': this.Receive_6170.bind(this),
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
'/pages/6075J/BJQ6075J': this.Receive_6075.bind(this),
@ -70,15 +74,24 @@ class BleReceive {
ReceiveData(receive, f, path, recArr) {
// 100J首页等场景 LinkedList 项可能未带齐 mac/device但语音分片上传依赖 parseBleData 消费 FB 05
// AE30 服务100J 与 102J 为同一套蓝牙芯片GATT 相同),应用层协议不同。
// 100Jf 未就绪时仍需 parseBleData 消费 FB 05 等语音/文件应答。
// 102J上行 FB 2128 为晶全协议,不得走 100J parseBleData避免误触发语音/文件回调。
const sid = receive && receive.serviceId ? String(receive.serviceId) : '';
const is100JAe30 = /ae30/i.test(sid);
const isAe30 = /ae30/i.test(sid);
const fReady = f && f.macAddress && f.device && f.device.id;
if (is100JAe30 && receive && receive.bytes && receive.bytes.length >= 3 && !fReady) {
const u8Early = receive && receive.bytes && receive.bytes.length >= 4
? new Uint8Array(receive.bytes)
: null;
const is102JFbControl = u8Early && u8Early[0] === 0xfb && u8Early[u8Early.length - 1] === 0xff
&& u8Early[1] >= 0x21 && u8Early[1] <= 0x28;
if (isAe30 && receive && receive.bytes && receive.bytes.length >= 3 && !fReady) {
if (!is102JFbControl) {
try {
parseBleData(new Uint8Array(receive.bytes));
} catch (e) {
console.warn('[100J] ReceiveData 兜底解析失败', e);
console.warn('[100J/AE30] ReceiveData 兜底 parseBleData 失败', e);
}
}
return receive;
}
@ -107,8 +120,8 @@ class BleReceive {
}
} else {
// 100J AE30 二进制帧在 f 不完整时已在上方 parseBleData,此处不再误报「无法处理」
if (!is100JAe30) {
// AE30100J 在 f 不完整时已在上方 parseBleData102J 控制帧被有意跳过 parseBleData
if (!isAe30) {
console.error("已收到该消息,但无法处理", receive, "f:", f);
}
}
@ -1013,6 +1026,147 @@ class BleReceive {
}
Receive_102J(receive, f, path, recArr) {
let receiveData = {}
try {
if (receive && receive.bytes && receive.bytes.length >= 3) {
receiveData = parseHby102jUplink(new Uint8Array(receive.bytes))
}
let recCnt = recArr.find((v) => {
return v.key.replace(/\//g, '').toLowerCase() == f.device.detailPageUrl
.replace(/\//g, '').toLowerCase()
})
if (!recCnt) {
let msgs = []
if (receiveData.sta_PowerPercent <= 20 && receiveData.sta_charge == 0) {
msgs.push("设备'" + f.device.deviceName + "'电量低")
}
if (receiveData.sta_Intrusion === 1) {
msgs.push("设备'" + f.device.deviceName + "'闯入报警中")
}
if (this.ref && msgs.length > 0) {
const text = msgs.join(',')
MsgError(text, '', this.ref, () => {
MsgClear(this.ref)
})
}
}
if (f.device && path === 'pages/common/index') {
let linkKey = '102J_' + f.device.id + '_linked'
let warnKey = '102J_' + f.device.id + '_warning'
let time = new Date()
if (receiveData.sta_tomac) {
if (receiveData.sta_tomac.indexOf(':') === -1) {
receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -1)
}
uni.getStorageInfo({
success: function(res) {
let arr = []
let linked = {
linkId: f.linkId,
read: false,
linkEqs: [{
linkTime: time,
linkMac: f.macAddress
}, {
linkTime: time,
linkMac: receiveData.sta_tomac
}]
}
if (res.keys.includes(linkKey)) {
arr = uni.getStorageSync(linkKey)
}
if (arr.length === 0) {
arr.unshift(linked)
} else {
let dev = arr.find((v) => {
if (v.linkId === f.linkId) {
let vl = v.linkEqs.find((cvl) => {
if (cvl.linkMac === receiveData.sta_tomac) {
v.read = false
cvl.linkTime = time
return true
}
return false
})
if (!vl) {
v.linkEqs.push({
linkTime: time,
linkMac: receiveData.sta_tomac
})
}
return vl
}
return false
})
if (!dev) {
arr.unshift(linked)
}
}
uni.setStorage({
key: linkKey,
data: arr
})
}
})
}
let warnArrs = []
let guid = Common.guid()
if (receiveData.sta_sosadd) {
if (receiveData.sta_sosadd.indexOf(':') === -1) {
receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -1)
}
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: '闯入报警',
warnMac: receiveData.sta_sosadd,
warnTime: time,
warnName: ''
})
}
if (receiveData.sta_LedType === 'led_alarm' || receiveData.ins_LedType === 'led_alarm') {
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: '强制报警',
warnMac: f.macAddress,
warnTime: time,
warnName: ''
})
}
if (warnArrs.length > 0) {
uni.getStorageInfo({
success: function(res) {
let arr = []
if (res.keys.includes(warnKey)) {
arr = uni.getStorageSync(warnKey)
arr = warnArrs.concat(arr)
} else {
arr = warnArrs
}
uni.setStorage({
key: warnKey,
data: arr
})
}
})
}
}
} catch (error) {
receiveData = {}
console.log('Receive_102J 解析失败', error)
}
return receiveData
}
Receive_6075(receive, f, path, recArr) {
let receiveData = {};