1
0
forked from dyf/APP

修改App图标、名称、蓝牙加入断线重连

This commit is contained in:
liub
2025-09-16 11:37:06 +08:00
parent 52b3bd796c
commit 778594574b
14 changed files with 3589 additions and 3686 deletions

40
App.vue
View File

@ -6,26 +6,26 @@
onLaunch: function() {
//以下代码仅在开发时使用,否则会出现不可预知的问题。
//清除登陆之外的所有信息;
let store=uni.getStorageInfoSync();
store.keys.forEach((val,index,array)=>{
if(val=="tokenTime"){
let time=uni.getStorageSync(val);
if(!time){
time=0;
}
let currTime=new Date().getTime();
if(currTime>=time){
uni.removeStorageSync(val);
uni.removeStorageSync("token");
uni.removeStorageSync("clientID");
}
}
else if(val=="token" || val=="clientID"){
console.log("忽略登陆信息");
}else{
uni.removeStorageSync(val);
}
});
// let store=uni.getStorageInfoSync();
// store.keys.forEach((val,index,array)=>{
// if(val=="tokenTime"){
// let time=uni.getStorageSync(val);
// if(!time){
// time=0;
// }
// let currTime=new Date().getTime();
// if(currTime>=time){
// uni.removeStorageSync(val);
// uni.removeStorageSync("token");
// uni.removeStorageSync("clientID");
// }
// }
// else if(val=="token" || val=="clientID"){
// console.log("忽略登陆信息");
// }else{
// uni.removeStorageSync(val);
// }
// });
//以上代码仅在开发时使用,否则会出现不可预知的问题。
uni.getSystemInfo({success:function(res){

View File

@ -2,7 +2,7 @@
const config = {
// 开发环境
development: {
BASE_URL: 'http://192.168.110.54:8000',
BASE_URL: 'http://192.168.110.56:8000',
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: '47.120.79.150',

View File

@ -1,5 +1,5 @@
{
"name" : "JingQuan",
"name" : "星汉物联",
"appid" : "__UNI__A21EF43",
"description" : "设备管控",
"versionName" : "1.0.24",
@ -21,7 +21,6 @@
"Bluetooth" : {},
"Barcode" : {},
"Camera" : {},
"Maps" : {},
"OAuth" : {},
"Geolocation" : {}
},

View File

@ -1,12 +1,12 @@
{
"pages": [
{
"path": "pages/BlueTooth/ModeSetting/index",
"style": {
"navigationBarTitleText": "设备类型"
}
},
// {
// "path": "pages/BlueTooth/ModeSetting/index",
// "style": {
// "navigationBarTitleText": "设备类型"
// }
// },
{
"path": "pages/common/login/index",
"style": {
@ -197,7 +197,7 @@
"navigationBarTitleText": "呼叫"
}
},
{
"path": "pages/BlueTooth/ModeSetting/VideoSend",
"style": {

View File

@ -151,12 +151,17 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import {
registerPersonInfo
} from '@/api/6170/deviceControl.js';
var ble = null;
var these = null;
var BrighInteval = null;
export default {
components: {
TextToHexV1
TextToHexV1
},
data() {
return {
@ -228,7 +233,26 @@
textLines: ['', '', ''],
mode: ''
},
inteval: 200
inteval: 200,
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "/pages/6155/deviceDetail",
showConfirm: false
}
}
},
@ -283,16 +307,17 @@
// } else {
// link();
// }
ble.addReceiveCallback(these.bleValueNotify);
ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', function(data) {
let device = data.data;
these.device = device;
console.log("收到父页面的参数:" + JSON.stringify(device));
let f = ble.data.LinkedList.find((v) => {
if (v.deviceId == device.deviceId) {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
@ -362,7 +387,7 @@
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.formData.deviceId;
return v.macAddress == these.device.deviceMac;
});
return f;
@ -431,8 +456,8 @@
this.formData.battary = batteryLevel;
this.formData.statu = warn;
this.formData.xuhang = lightingTime;
if(batteryLevel<=20){
if (batteryLevel <= 20) {
this.showPop({
message: "设备电量低",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -448,7 +473,7 @@
}
},
proParam: function() {
uni.navigateTo({
@ -492,25 +517,25 @@
return new Promise((resolve, reject) => {
// 创建RGB565格式的像素数据
const arr = ble.convertToRGB565(pixels, 'bgr');
var list = [];
let index = 0; // 用于追踪arr的当前位置
let packetSize=2048;
let cSize=248;
let packetSize = 2048;
let cSize = 248;
// 外层循环7个主要元素i从1到7
for (let i = 1; i < 8; i++) {
let secondLevel = [];
let secondCnt=0;
let secondCnt = 0;
// 中层循环每个主要元素包含9个子数组j从1到9
for (let j = 1; j < 10; j++) {
// 确定当前子数组的长度前8个是254第9个是64
let thirdLevel = [];
// 从arr中提取相应数量的元素
for (let k = 0; k < cSize && index < arr.length; k++) {
if(secondCnt==packetSize){
if (secondCnt == packetSize) {
break;
}
thirdLevel.push(arr[index]);
@ -523,20 +548,20 @@
list.push(secondLevel);
}
console.log("list=",list);
let length=0;
console.log("list=", list);
let length = 0;
for (let i = 0; i < list.length; i++) {
const item = list[i];
let clength=0;
for (let j = 0; j < item.length; j++) {
const element = item[j];
console.log("第"+i+"包,第"+j+"小包,长度:"+element.length)
length+=element.length;
clength+=element.length;
}
const item = list[i];
let clength = 0;
for (let j = 0; j < item.length; j++) {
const element = item[j];
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
length += element.length;
clength += element.length;
}
}
// 分包发送
sendImagePackets(list).then(resolve).catch(reject);
@ -558,22 +583,24 @@
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
setTimeout(()=>{
setTimeout(() => {
hideLoading(these);
these.Status.BottomMenu.show = false;
these.showPop({
message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600',
buttonBgColor : '#BBE600'
});
resolve();
},20000)
}, 20000)
return;
}
var packetData = imageData[currentPacket - 1][childPacket - 1];
var packetData = imageData[currentPacket - 1][childPacket - 1];
// if (packetData.length == 0) {
// hideLoading(these);
// these.Status.BottomMenu.show = false;
@ -586,38 +613,37 @@
// resolve();
// return;
// }
let start=0;
let bufferSize=packetData.length*2;
if(currentPacket==7 ){
if(childPacket>2 && childPacket<9){
bufferSize=496;
}
else if(childPacket==9){
bufferSize=128;
let start = 0;
let bufferSize = packetData.length * 2;
if (currentPacket == 7) {
if (childPacket > 2 && childPacket < 9) {
bufferSize = 496;
} else if (childPacket == 9) {
bufferSize = 128;
}
}
if(childPacket==1){
bufferSize=bufferSize+8
start=8;
if (childPacket == 1) {
bufferSize = bufferSize + 8
start = 8;
}
if(childPacket==9 ){//|| (currentPacket==7 && childPacket==3
bufferSize=bufferSize+1
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
bufferSize = bufferSize + 1
}
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
var buffer = new ArrayBuffer(bufferSize);
var dataView = new DataView(buffer);
if(childPacket==1){
if (childPacket == 1) {
dataView.setUint8(0, 0xFA); // 帧头
dataView.setUint8(1, 0x09); // 帧头
dataView.setUint8(2, 0x10); // 帧头
dataView.setUint8(3, 0x04); // 帧头
dataView.setUint8(4, 0xFC); // 帧头
dataView.setUint8(5, 0x09); // 帧头
dataView.setUint8(6, 0x00); // 图序号,图片固定0视频的话要写序号
dataView.setUint8(7, currentPacket); //子包序号
}
@ -625,20 +651,21 @@
for (let i = 0; i < packetData.length; i++) {
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
}
console.log("packetData.length=",packetData.length);
console.log("bufferSize=",bufferSize)
if(childPacket==9){// || (currentPacket==7 && childPacket==3
dataView.setUint8(bufferSize-1, 0xFF);
console.log("packetData.length=", packetData.length);
console.log("bufferSize=", bufferSize)
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
dataView.setUint8(bufferSize - 1, 0xFF);
}
//发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
30)
.then(() => {
let curr = childPacket + (currentPacket - 1) *
totalChildPacket;
console.log(""+currentPacket+"大包,"+childPacket+"小包发送完成,总计"+curr);
totalChildPacket;
console.log("第" + currentPacket + "大包,第" + childPacket +
"小包发送完成,总计:" + curr);
updateLoading(these, {
text: "正在发送" + curr + "/63"
@ -949,7 +976,7 @@
let packetSize = rgbdata.length; //每包均分的数量
let mode = rgbdata.length % packetSize; //最后一包的数量
let cnt =
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
let curr = 1; //当前包序号
let sendNext = () => {
@ -994,7 +1021,7 @@
dataView.setUint8(bufferSize - 1, 0xFF);
let inteval =parseInt(this.inteval ? this.inteval : 50);
let inteval = parseInt(this.inteval ? this.inteval : 50);
console.log("inteval=", inteval)
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 30).then(() => {
@ -1027,12 +1054,12 @@
console.log("11111");
var result = null;
try {
console.log("this.$refs.textToHex=",this.$refs.textToHex);
console.log("this.$refs.textToHex=", this.$refs.textToHex);
result = await this.$refs.textToHex.drawAndGetPixels();
} catch (ex) {
console.log("ex=", ex);
}
if(!result){
if (!result) {
hideLoading(this);
return;
}
@ -1041,7 +1068,7 @@ if(!result){
return level1.flat(Infinity);
});
console.log("result=", result);
// var str1="FA 06 01 00 FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 FF 81 03 ED BB DD B7 CB CF F3 C7 CD 39 BE FF FE FF C0 03 FE FB FD FB F3 F7 8F 87 FF FF FF FF FE FF FE FF FE FF C0 03 FF FB FD FB FD FB FD FB FD FB FB FB FB FF F7 F7 EF F7 9F 8F FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
// var str2="FA 07 01 00 FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EF 77 EF 73 EF 7F 80 01 EF 7F EF 7F EF 03 E7 3B 8E BB EE D7 EE EF ED E7 ED 9B 8B 7D FF FF FF FF FF FF F7 EF F7 F7 EF F7 DF FB FF FF FF FF FE FF 80 01 FE 7F FD BF FB DF F7 E7 9F F9 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
// var str3="FA 08 01 00 FF FF EF DF EC 01 EF FF AB FF AA 03 AA FB AE FB EE 03 EF DF EF DF EE DB ED DF ED DD EF 1F FF FF FF FF EF BF EF 87 81 77 EE F7 EC 03 81 7F EF 7F EF 7F EF 03 81 7F EF 7F EF 7D EF 7D EF 03 FF FF FF FF F9 F1 CF BF DF FF DF FF C1 FF DD 81 DD F7 DD F7 C1 F7 DF 77 FF 77 BF 77 BF 77 FF F7 FF FF FF FF FD FF FD FF FB FF FB FF F0 07 E7 F7 EF F7 D8 07 BF F7 FF F7 F8 07 FF F7 FF F7 FF C7 FF FF FF FF FF FF FF FF FF FF FE FF FE 7F FE 7F FE FF FD BF FD FF FB DF F7 EF EF F7 DF FB BF FD FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
@ -1086,8 +1113,26 @@ if(!result){
if (flag) {
console.log("发送成功");
this.showPop({
message: "发送成功"
message: "发送成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600',
buttonBgColor : '#BBE600'
});
// let formdata = {
// code:"",
// name: these.formData.textLines[2],
// position: these.formData.textLines[1],
// unitName: these.formData.textLines[0],
// deviceId: these.device.id,
// deviceImei: these.device.deviceImei
// };
// registerPersonInfo(formdata).then(res=>{
// console.log("res=",res);
// }).catch(ex=>{
// console.log("ex=",ex);
// });
} else {
this.showPop({
message: "出现异常发送失败",

View File

@ -173,6 +173,11 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import {request,baseURL} from '../../utils/request';
import {
registerPersonInfo
} from '@/api/6170/deviceControl.js';
const pagePath = "pages/650/HBY650";
var ble = null;
var these = null;
@ -259,7 +264,26 @@
iswarn: false
},
rgb565Data: [],
videoHexArray: []
videoHexArray: [],
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "/pages/650/HBY650",
showConfirm: false
},
}
},
@ -278,7 +302,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);
@ -374,9 +398,9 @@
return className;
},
bleValueNotify: function(receive, device, path) { //订阅消息
console.log("收到设备的数据", data)
let data = recei.ReceiveData(receive, device, pagePath);
console.log("收到设备的数据",data)
if (data) {
if ("staBlue_picture" in data) {
//重发图片
@ -403,10 +427,10 @@ console.log("收到设备的数据",data)
let keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
if(key in these.formData){
these.formData[key] = data[key];
if (key in these.formData) {
these.formData[key] = data[key];
}
}
if (these.formData.iswarn) {
@ -434,7 +458,7 @@ console.log("收到设备的数据",data)
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.formData.deviceId;
return v.macAddress == these.device.deviceMac;
});
return f;
@ -606,11 +630,12 @@ console.log("收到设备的数据",data)
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
});
if (!ReSendNo) {
setTimeout(()=>{
these.HoldYouHand("transmit complete", 0, f.deviceId, f
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId);
},500);
}, 500);
}
resolve();
@ -635,7 +660,7 @@ console.log("收到设备的数据",data)
const packetData = these.rgb565Data.slice(startIndex,
endIndex);
// 构建数据包
const bufferSize =505;// 5 + packetData.length * 2; // 头部5字节 + 数据部分
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
@ -771,18 +796,20 @@ console.log("收到设备的数据",data)
this.totalPackets = totalPackets;
// 发送单个数据包
const sendNextVideoPacket = () => {
console.log("准备发送一段数据");
console.log("准备发送一段数据");
if (currentPacket > totalPackets) {
if (!ReSendNo) {
setTimeout(()=>{
these.HoldYouHand("transmit complete", 0, f.deviceId, f
.writeServiceId, f.wirteCharactId).then(()=>{
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId).then(
() => {
console.log("全部发送完毕")
}).catch((ex)=>{
console.log("出现异常",ex);
});
},500);
}).catch((ex) => {
console.log("出现异常", ex);
});
}, 500);
}
these.Status.BottomMenu.show = false;
hideLoading(these);
@ -793,7 +820,7 @@ console.log("收到设备的数据",data)
});
resolve();
@ -837,10 +864,10 @@ console.log("收到设备的数据",data)
}
let inteval = 50;
console.log("开始发送一段视频"); //
console.log("开始发送一段视频"); //
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => {
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
@ -902,13 +929,28 @@ console.log("收到设备的数据",data)
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
f.wirteCharactId);
let p2 = new Promise((succ, err) => {
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
if (!token) {
err({
code: 401,
msg: "请先登陆后再试"
});
hideLoading(these);
return;
}
uni.uploadFile({
url: 'http://114.55.111.217/video/upload',
// url: 'http://114.55.111.217/video/upload',
url: baseURL+"app/video/upload",
filePath: videoPath,
name: 'file',
header: {
"Method": "POST",
"Content-Type": "multipart/form-data"
"Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
},
timeout: 600000,
fail: (ex) => {
@ -1127,14 +1169,15 @@ console.log("收到设备的数据",data)
// console.log("currentPacket=",currentPacket);
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
if (!ReSendNo) {
setTimeout(()=>{
these.HoldYouHand("transmit complete", 0, f.deviceId, f.writeServiceId, f
.wirteCharactId);
},500);
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f.deviceId, f
.writeServiceId, f
.wirteCharactId);
}, 500);
}
these.showPop({
@ -1155,6 +1198,16 @@ console.log("收到设备的数据",data)
visibleClose: true
});
these.setBleFormData();
// let formdata = {
// code: these.formData.id,
// name: these.formData.name,
// position: these.formData.job,
// unitName: these.formData.company,
// deviceId: these.device.id,
// deviceImei: these.device.deviceImei
// };
// registerPersonInfo(formdata);
return;
}
@ -1163,7 +1216,7 @@ console.log("收到设备的数据",data)
let arr = gbk.encode(text)
let gbkData = gbk.arr2hex(arr);
// 构建数据包
const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
@ -1174,7 +1227,7 @@ console.log("收到设备的数据",data)
dataView.setUint8(1, 0x03); // 帧类型:文字
dataView.setUint8(2, currentPacket.toString(16)); // 包序号
dataView.setUint16(3, (text.length * 2).toString(16)); // 数据长度
// 填充数据
let index = 0;
for (var i = 0; i < gbkData.length; i += 2) {
@ -1182,8 +1235,8 @@ console.log("收到设备的数据",data)
dataView.setUint8(5 + index, value);
index++;
}
// 发送数据包
@ -1219,7 +1272,7 @@ console.log("收到设备的数据",data)
}
if(ReSendNo){
if (ReSendNo) {
sendText(ReSendNo);
return;
}
@ -1261,16 +1314,26 @@ console.log("收到设备的数据",data)
}
console.log("开始握手");
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
() => {
setTimeout(() => {
console.log("握手成功并完成了等待");
resolve(true);
}, pauseTime);
}).catch(err => {
console.log("握手没有成功", )
reject(err);
});
let send = () => {
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
() => {
setTimeout(() => {
console.log("握手成功并完成了等待");
resolve(true);
}, pauseTime);
}).catch(err => {
if (err.code == 10007) {
send();
} else {
console.log("握手没有成功", err)
reject(err);
}
});
}
send();
});

View File

@ -249,6 +249,14 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import {
request,
baseURL
} from '../../utils/request';
import {
registerPersonInfo
} from '@/api/6170/deviceControl.js';
const pagePath = "pages/650/HBY650";
var ble = null;
var these = null;
@ -629,7 +637,7 @@
receiveData.modeCurr = staticLevelText;
receiveData.lightCurr = lightingLevelText;
receiveData.xuhang = json.sta_PowerTime + "分钟";
receiveData.battary = json.sta_PowerPercent ;
receiveData.battary = json.sta_PowerPercent;
receiveData.warnLevel = warn;
receiveData.staticWarn = staticWarn;
@ -699,10 +707,10 @@
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.formData.deviceId;
return v.macAddress == these.device.deviceMac;
});
return f;
@ -800,60 +808,60 @@
setTimeout(task, 0);
},
CloseWarn: function(ispop) {
let closeEvt=()=>{
let closeEvt = () => {
{
these.Status.Pop.showPop = false;
these.formData.qzwarn = false;
clearInterval(these.Status.staticWarn.inteval);
let closeSOS=()=>{
let closeSOS = () => {
let json = {
ins_SOSGrade: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=",ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
});
}
let closeWarn=()=>{
let closeWarn = () => {
let json = {
ins_ShakeBit: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=",ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
});
}
let f = this.getDevice();
let buffer = null;
if (f) {
@ -866,31 +874,32 @@
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x71); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x68);
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(()=>{
console.log("成功");
});
}).catch(ex => {
() => {
console.log("关闭强制报警成功")
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x68);
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10)
.then(() => {
console.log("成功");
});
}).catch(ex => {
closeSOS();
closeWarn();
// closeWarn();
});
} else {
closeSOS();
closeWarn();
// closeWarn();
}
}
}
if(!ispop){
if (!ispop) {
closeEvt();
return;
}
@ -901,8 +910,8 @@
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText:"解除报警",
okCallback: closeEvt
buttonText: "解除报警",
okCallback: closeEvt
});
},
@ -972,21 +981,21 @@
() => {
console.log("蓝牙发送成功了");
dic = {
close: 0x71
}
if (type in dic) {
dataView.setUint8(1, 0x06); // 帧类型
dataView.setUint8(5, 0x71); // 数据
// dic = {
// close: 0x71
// }
// if (type in dic) {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x71); // 数据
} else {
dataView.setUint8(1, 0x06); // 帧类型
dataView.setUint8(5, 0x70); // 数据
}
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
10).then(() => {
console.log("蓝牙发送报警成功", type);
})
// } else {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x70); // 数据
// }
// ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
// 10).then(() => {
// console.log("蓝牙发送报警成功", type);
// })
hideLoading(these);
these.setBleFormData();
@ -1012,16 +1021,28 @@
okCallback: function() {
these.formData.qzwarn = true;
these.Status.staticWarn.time = 5;
these.Status.staticWarn.inteval = setInterval(() => {
these.Status.staticWarn.time = 180;
let loopFunc = () => {
if (these.Status.staticWarn.inteval === null) {
return;
}
if (these.Status.staticWarn.time === 0) {
console.log("111111");
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
these.formData.qzwarn = false;
these.formData.SOS = 'close';
these.CloseWarn(false);
return;
}
these.Status.staticWarn.time = these.Status.staticWarn
.time - 1;
}
these.Status.staticWarn.inteval = setInterval(() => {
loopFunc();
}, 1000)
SendCmd();
@ -1101,8 +1122,14 @@
these.setBleFormData();
}).catch((ex) => {
//使用4G发送
console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
if (ex.code == 10007) {
console.log("蓝牙发送失败,正在重试");
task();
} else {
console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
}
});
} else {
console.log("找不到蓝牙设备使用4G发送")
@ -1437,6 +1464,8 @@
dataView.setUint8(6 + i, '0x' + packetData[i]);
}
let inteval = 30;
console.log("开始发送一段视频"); //
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
@ -1487,6 +1516,17 @@
}
var sendVideo = (videoPath) => {
let f = these.getDevice();
if (!f) {
these.showPop({
message: "蓝牙未连接,请连接后再试",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
return;
}
let uploadVideo = () => {
if (these.videoHexArray.length > 0) {
@ -1495,7 +1535,9 @@
return;
}
console.log("开始处理,正在上传");
console.log("开始处理,正在上传", f);
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
showLoading(these, {
text: "上传中"
@ -1503,13 +1545,25 @@
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
f.wirteCharactId);
let p2 = new Promise((succ, err) => {
if (!token) {
err({
code: 401,
msg: "请先登陆后再试"
});
hideLoading(these);
return;
}
console.log("baseURL=", baseURL);
uni.uploadFile({
url: 'http://114.55.111.217/video/upload',
// url: 'http://114.55.111.217/video/upload',
url: baseURL + "/app/video/upload",
filePath: videoPath,
name: 'file',
header: {
"Method": "POST",
"Content-Type": "multipart/form-data"
"Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
},
timeout: 600000,
fail: (ex) => {
@ -1564,7 +1618,7 @@
});
})
}
let f = these.getDevice();
@ -1818,6 +1872,17 @@
});
these.setBleFormData();
hideLoading(these);
// let formdata = {
// code: these.formData.usrid,
// name: these.formData.usrname,
// position: these.formData.job,
// unitName: these.formData.company,
// deviceId: these.device.id,
// deviceImei: these.device.deviceImei
// };
// registerPersonInfo(formdata);
return;
}

View File

@ -125,7 +125,8 @@
let start = new Date();
console.log("Common.baseURL=" + Common.baseURL);
uni.uploadFile({
url: Common.baseURL + 'video/upload',
// url: Common.baseURL + 'video/upload',
url:'http://192.168.110.56:8000/app/video/upload',
filePath: this.videoPath,
name: 'file',
header: {

View File

@ -34,12 +34,13 @@
hideLoading,
updateLoading
} from '@/utils/loading.js';
const pagePath="pages/common/addBLE/LinkBle";
const pagePath = "pages/common/addBLE/LinkBle";
var these = null;
var eventChannel = null;
var ble = null;
var timeInteval = null;
export default {
data() {
return {
@ -57,7 +58,8 @@
],
"linkStatu": false,
"macAddress": ""
}
},
serverDevice:null
}
},
computed: {
@ -84,11 +86,11 @@
onLoad(option) {
these = this;
ble = bleTool.getBleTool();
ble.addReceiveCallback((receive,f,path) => {
ble.addReceiveCallback((receive, f, path) => {
console.log("收到设备消息,", receive);
if (these.device.deviceId == receive.deviceId) {
// console.log("11111");
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
if (f && f.macAddress) {
these.device.macAddress = f.macAddress;
@ -97,79 +99,91 @@
}
}
}
},pagePath);
}, pagePath);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) {
console.log("data=",data);
console.log("data=", data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId;
});
if (f) {
let keys=Object.keys(f);
keys.forEach((v,index)=>{
these.device[v]=f[v];
let keys = Object.keys(f);
keys.forEach((v, index) => {
these.device[v] = f[v];
})
console.log("LinkedList=",ble.data.LinkedList)
console.log("f=", f);
console.log("LinkedList=", ble.data.LinkedList)
console.log("f=", f);
console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
}
these.device.macAddress = f.macAddress;
these.initDevice();
}
} else {
console.log("未获取到设备");
}
})
let inteval = setInterval(this.initDevice, 5000);
},
methods: {
initDevice: function() {
showLoading(these, {
text: '正在获取设备信息'
});
console.log("these.device=",these.device);
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
data: {
deviceMac: these.device.macAddress
}
}).then(res => {
console.log("获取设备信息", res);
if (res && res.code == 200) {
let data = res.data;
if (data) {
let keys = Object.keys(data);
ble.data.LinkedList.find((v) => {
if(v.deviceId == these.device.deviceId){
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
v[key] = data[key];
// console.log("key="+key);
// console.log("value="+data[key]);
these.$set(these.device, key, data[key]);
}
ble.setBleData();
}
});
console.log("device=",these.device);
console.log("LinkedList=",ble.data.LinkedList);
clearTimeout(timeInteval);
timeInteval = setTimeout(() => {
showLoading(these, {
text: '正在获取设备信息'
});
console.log("these.device=", these.device);
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
data: {
deviceMac: these.device.macAddress
}
}
}).then(res => {
console.log("获取设备信息", res);
if (res && res.code == 200) {
let data = res.data;
this.serverDevice=data;
if (data) {
let keys = Object.keys(data);
ble.data.LinkedList.find((v) => {
if (v.deviceId == these.device.deviceId) {
for (var i = 0; i < keys.length; i++) {
// let key = keys[i];
// if(!v.device){
// v.device={};
// }
// v.device[key] = data[key];
// console.log("key="+key);
// console.log("value="+data[key]);
these.$set(these.device, key, data[key]);
}
// ble.setBleData();
}
});
console.log("device=", these.device);
console.log("LinkedList=", ble.data.LinkedList);
}
}
}).catch((ex) => {
console.log("获取设备出现异常:", ex);
}).finally(() => {
hideLoading(these);
});
}, 500);
}).catch((ex) => {
console.log("获取设备出现异常:", ex);
}).finally(() => {
hideLoading(these);
});
},
Link() {
// 调用绑定设备接口
@ -207,6 +221,21 @@
if (res.code == 200) {
these.Statu.bound = true;
these.Statu.boundRemark = "设备绑定成功!";
ble.data.LinkedList.find((v) => {
if (v.deviceId == these.device.deviceId) {
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
if(!v.device){
v.device={};
}
v.device[key] = data[key];
}
ble.setBleData();
}
});
ble.removeReceiveCallback(pagePath);
uni.$emit("refreshDeviceList");

View File

@ -1,8 +1,8 @@
var isReady=false;var onReadyCallbacks=[];
var isServiceReady=false;var onServiceReadyCallbacks=[];
var __uniConfig = {"pages":["pages/BlueTooth/ModeSetting/index","pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"JingQuan","compilerVersion":"4.75","entryPagePath":"pages/BlueTooth/ModeSetting/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
var __uniRoutes = [{"path":"/pages/BlueTooth/ModeSetting/index","meta":{"isQuit":true},"window":{"navigationBarTitleText":"设备类型"}},{"path":"/pages/common/login/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"添加设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}}];
var __uniConfig = {"pages":["pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"星汉物联","compilerVersion":"4.75","entryPagePath":"pages/common/login/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
var __uniRoutes = [{"path":"/pages/common/login/index","meta":{"isQuit":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"添加设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}}];
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -40,8 +40,8 @@ class BleHelper {
onDeviceFound: [], //发现新设备的事件
receivDataCallback: [] //接收到数据的事件
}
this.addReceiveCallback((a,b,c)=>{
recei.ReceiveData(a,b,c);
this.addReceiveCallback((a, b, c) => {
recei.ReceiveData(a, b, c);
}, "BleReceiveData");
this.dic = {
errRemarks: [{
@ -105,14 +105,17 @@ class BleHelper {
}
linkAllDevices() {
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
for (var i = 0; i < this.data.LinkedList.length; i++) {
let device = this.data.LinkedList[i];
// console.log("自动连接:" + device.deviceId);
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
.notifyCharactId);
// console.log("自动连接绑定过的设备:" + device.deviceId);
if(device.macAddress && device.device && device.device.id){
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
.notifyCharactId);
}
}
} else {
// console.log("无设备连接");
@ -335,8 +338,8 @@ class BleHelper {
}
uni.getBluetoothAdapterState({
success: (info) => {
this.data.available=info.available;
this.data.discovering=info.discovering;
this.data.available = info.available;
this.data.discovering = info.discovering;
resolve(info);
},
fail: (ex1) => {
@ -360,12 +363,12 @@ class BleHelper {
resolve(false);
return;
}
uni.openBluetoothAdapter({
success: (args) => {
// console.log("蓝牙初始化成功:" + JSON.stringify(args));
this.data.isOpenBlue = true;
this.data.available=true;
this.data.available = true;
resolve(true);
if (this.data.isSubscribe) { //整个App生命周期只订阅一次
@ -386,7 +389,7 @@ class BleHelper {
this.data.discovering = state.discovering;
if (this.data.available && this.data
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
this.linkAllDevices();
}
@ -437,9 +440,9 @@ class BleHelper {
uni.onBLECharacteristicValueChange((receive) => {
//订阅消息
console.log("收到订阅消息",receive);
let f=this.data.LinkedList.find((v) => {
return v.deviceId == receive.deviceId;
console.log("收到订阅消息", receive);
let f = this.data.LinkedList.find((v) => {
return v.deviceId == receive.deviceId;
})
let dataView = new DataView(receive.value);
@ -458,7 +461,7 @@ class BleHelper {
// 将每个字节转换为对应的字符
str += String.fromCharCode(uint8Array[i]);
}
let header = "mac address:";
if (str.indexOf(header) == 0) { //650以文本传输mac
@ -467,7 +470,7 @@ class BleHelper {
.deviceId) {
v.macAddress = str.replace(
header, "");
console.log("收到mac地址:", str)
console.log("收到mac地址:", str)
}
});
uni.setStorageSync(this.StorageKey, this.data
@ -475,9 +478,9 @@ class BleHelper {
}
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
console.log("收到mac地址:", bytes)
console.log("收到mac地址:", bytes)
if (bytes.length >= 7) {
console.log("hexs=",hexs);
console.log("hexs=", hexs);
let mac = hexs.slice(1, 7).join(":")
.toUpperCase();
this.data.LinkedList.find((v) => {
@ -491,7 +494,7 @@ class BleHelper {
.data.LinkedList);
}
}
console.log("str=",str);
console.log("str=", str);
} catch (ex) {
console.log("将数据转文本失败", ex);
}
@ -503,18 +506,18 @@ class BleHelper {
str: str,
hexs: hexs
};
console.log("监听到特征值:" + JSON.stringify(recData));
console.log("监听到特征值:" + JSON.stringify(recData));
if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) {
let path = this.getCurrentPagePath();
this.cfg.receivDataCallback.forEach((rec) => {
if (rec.callback) {
rec.callback(recData, f, path);
}
}
})
}
} else {
@ -672,7 +675,8 @@ class BleHelper {
}
// console.log("c=", c);
let startSubScribe = (id, serviceId, characteristicId) => {
console.log("serviceId=",serviceId);
console.log("characteristicId=",characteristicId);
return new Promise((succ, err) => {
uni.notifyBLECharacteristicValueChange({
deviceId: id,
@ -681,7 +685,7 @@ class BleHelper {
state: state,
success: (res) => {
if (state) {
// console.log("订阅消息成功", res);
console.log("订阅消息成功", res);
} else {
console.log("取消订阅成功", res);
}
@ -701,24 +705,27 @@ class BleHelper {
});
}
let promies = new Array();
for (var i = 0; i < c.Characteristics.length; i++) {
let item = c.Characteristics[i];
let serviceId = item.serviceId;
let characteristicId = item.uuid;
if (item.properties.notify) {
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
if(c.Characteristics && c.Characteristics.length){
for (var i = 0; i < c.Characteristics.length; i++) {
let item = c.Characteristics[i];
let serviceId = item.serviceId;
let characteristicId = item.uuid;
if (item.properties.notify) {
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
}
}
}
if (promies.length > 0) {
Promise.allSettled(promies).then((results) => {
results.forEach((result, index) => {
if (result.status === "fulfilled") {
//console.log(`操作${index + 1}成功:`, result.value);
console.log(`操作${index + 1}成功:`, result.value);
} else {
// console.log(`操作${index + 1}失败:`, result.reason
// .message);
console.log(`操作${index + 1}失败:`, result.reason
.message);
}
});
@ -732,7 +739,7 @@ class BleHelper {
}, 20);
}, 800);
});
}
@ -939,79 +946,90 @@ class BleHelper {
//连接设备
var linkDevice = () => {
return new Promise((resolve, reject) => {
if (fIndex > -1 && f?.Linked) {
console.log("当前已连接,跳过其他步骤")
resolve(false);
return;
}
if(!this.data.available){
reject(this.getError({code:10001}));
return;
}
console.log("正在连接" + deviceId);
uni.createBLEConnection({
deviceId: deviceId,
timeout: 30000,
success: (info) => {
console.log("新连接成功", this.data.LinkedList);
this.getLinkBlue().then((arr) => {
let cr = arr.devices.find(c => {
if (c.deviceId == deviceId) {
c.Linked = true;
return true;
}
return false;
});
if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true;
} else {
this.data.LinkedList.push(cr);
}
uni.setStorageSync(this.StorageKey, this.data
.LinkedList);
let os = plus.os.name;
console.log("os=",os);
if (os == 'Android') {
uni.setBLEMTU({
deviceId: deviceId,
mtu: 512,
success: (mtu) => {
console.log("mtu设置成功",mtu);
resolve(true);
},
fail: () => {
console.log("mtu设置失败")
resolve(true);
},
finally:()=>{
}
});
}else{
resolve(true);
}
}).catch((ex) => {
reject(this.getError(ex));
});
},
fail: (ex) => {
ex = this.getError(ex)
console.log("蓝牙连接失败" + JSON.stringify(ex));
reject(ex);
}
});
});
}
// 添加重试次数限制
let retryCount = 0;
const maxRetries = 10; // 最大重试次数
const connect = () => {
return new Promise((resolve, reject) => {
if (fIndex > -1 && f?.Linked) {
console.log("当前已连接,跳过其他步骤");
resolve(false);
return;
}
if (!this.data.available) {
reject(this.getError({ code: 10001 }));
return;
}
console.log("正在连接" + deviceId);
uni.createBLEConnection({
deviceId: deviceId,
timeout: 30000,
success: (info) => {
console.log("新连接成功", this.data.LinkedList);
this.getLinkBlue().then((arr) => {
let cr = arr.devices.find(c => {
if (c.deviceId == deviceId) {
c.Linked = true;
return true;
}
return false;
});
if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true;
} else {
this.data.LinkedList.push(cr);
}
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
console.log("LinkedList=", this.data.LinkedList);
// 处理 MTU 设置
if (plus.os.name === 'Android') {
uni.setBLEMTU({
deviceId: deviceId,
mtu: 512,
success: (mtu) => {
console.log("mtu设置成功", mtu);
resolve(true);
},
fail: () => {
console.log("mtu设置失败");
resolve(true); // MTU设置失败不影响连接成功
}
});
} else {
resolve(true);
}
}).catch((ex) => {
reject(this.getError(ex));
});
},
fail: (ex) => {
ex = this.getError(ex);
console.log("蓝牙连接失败" + JSON.stringify(ex));
// 连接超时后自动重试
if (ex.code === 10012 && retryCount < maxRetries) {
retryCount++;
console.log(`重试连接 (${retryCount}/${maxRetries})`);
// 使用 setTimeout 避免递归调用栈溢出
setTimeout(() => {
connect().then(resolve).catch(reject);
}, 1000); // 延迟1秒后重试
} else {
reject(ex);
}
}
});
});
};
return connect();
};
@ -1021,19 +1039,32 @@ class BleHelper {
////console.log("2222222");
return linkDevice(deviceId);
}).then((res) => {
////console.log("11111111");
if (res) { //新连接
console.log("11111111");
if (fIndex == -1) {
console.log("开始获取服务", targetServiceId)
return this.getService(deviceId, targetServiceId, writeCharId,
notifyCharId); //获取服务
notifyCharId); //获取服务
} else {
if (!f.notifyState) {
this.subScribe(deviceId, true);
if(f.wirteCharactId && f.notifyCharactId){
if (!f.notifyState) {
console.log("开始订阅特征");
this.subScribe(deviceId, true);
}else{
console.log("不订阅消息");
}
return Promise.resolve(true);
}else{
console.log("开始获取服务", targetServiceId)
return this.getService(deviceId, targetServiceId, writeCharId,
notifyCharId);
}
return Promise.resolve(true);
}
} else { //已连接过,直接订阅消息
} else { //已连接过,直接订阅消息
console.log("11111111");
if (fIndex > -1 && f && !f.notifyState) {
this.subScribe(deviceId, true);
@ -1157,7 +1188,7 @@ class BleHelper {
})); //没有找到指定设备
return;
}
console.log("device=", device);
console.log("device=", device);
uni.writeBLECharacteristicValue({
deviceId: device.deviceId,
serviceId: device.writeServiceId,
@ -1252,7 +1283,7 @@ class BleHelper {
let a = pixels[i + 3];
if (type == 'bgr') {
result[index++] = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
result[index++] = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
} else {
result[index++] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
}