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

View File

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

View File

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

View File

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

View File

@ -151,12 +151,17 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import {
registerPersonInfo
} from '@/api/6170/deviceControl.js';
var ble = null; var ble = null;
var these = null; var these = null;
var BrighInteval = null; var BrighInteval = null;
export default { export default {
components: { components: {
TextToHexV1 TextToHexV1
}, },
data() { data() {
return { return {
@ -228,7 +233,26 @@
textLines: ['', '', ''], textLines: ['', '', ''],
mode: '' 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 { // } else {
// link(); // link();
// } // }
ble.addReceiveCallback(these.bleValueNotify); ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel(); let eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', function(data) { eventChannel.on('detailData', function(data) {
let device = data.data; let device = data.data;
these.device = device;
console.log("收到父页面的参数:" + JSON.stringify(device)); console.log("收到父页面的参数:" + JSON.stringify(device));
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.deviceId == device.deviceId) { if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v); console.log("找到设备了", v);
these.formData.deviceId = v.deviceId; these.formData.deviceId = v.deviceId;
return true; return true;
@ -362,7 +387,7 @@
// console.log("LinkedList=", ble.data.LinkedList); // console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData); // console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.formData.deviceId; return v.macAddress == these.device.deviceMac;
}); });
return f; return f;
@ -432,7 +457,7 @@
this.formData.statu = warn; this.formData.statu = warn;
this.formData.xuhang = lightingTime; this.formData.xuhang = lightingTime;
if(batteryLevel<=20){ if (batteryLevel <= 20) {
this.showPop({ this.showPop({
message: "设备电量低", message: "设备电量低",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -495,12 +520,12 @@
var list = []; var list = [];
let index = 0; // 用于追踪arr的当前位置 let index = 0; // 用于追踪arr的当前位置
let packetSize=2048; let packetSize = 2048;
let cSize=248; let cSize = 248;
// 外层循环7个主要元素i从1到7 // 外层循环7个主要元素i从1到7
for (let i = 1; i < 8; i++) { for (let i = 1; i < 8; i++) {
let secondLevel = []; let secondLevel = [];
let secondCnt=0; let secondCnt = 0;
// 中层循环每个主要元素包含9个子数组j从1到9 // 中层循环每个主要元素包含9个子数组j从1到9
for (let j = 1; j < 10; j++) { for (let j = 1; j < 10; j++) {
// 确定当前子数组的长度前8个是254第9个是64 // 确定当前子数组的长度前8个是254第9个是64
@ -510,7 +535,7 @@
// 从arr中提取相应数量的元素 // 从arr中提取相应数量的元素
for (let k = 0; k < cSize && index < arr.length; k++) { for (let k = 0; k < cSize && index < arr.length; k++) {
if(secondCnt==packetSize){ if (secondCnt == packetSize) {
break; break;
} }
thirdLevel.push(arr[index]); thirdLevel.push(arr[index]);
@ -523,20 +548,20 @@
list.push(secondLevel); list.push(secondLevel);
} }
console.log("list=",list); console.log("list=", list);
let length=0; let length = 0;
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
const item = list[i]; const item = list[i];
let clength=0; let clength = 0;
for (let j = 0; j < item.length; j++) { for (let j = 0; j < item.length; j++) {
const element = item[j]; const element = item[j];
console.log("第"+i+"包,第"+j+"小包,长度:"+element.length) console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
length+=element.length; length += element.length;
clength+=element.length; clength += element.length;
} }
} }
// 分包发送 // 分包发送
sendImagePackets(list).then(resolve).catch(reject); sendImagePackets(list).then(resolve).catch(reject);
@ -558,22 +583,24 @@
// 发送单个数据包 // 发送单个数据包
const sendNextPacket = () => { const sendNextPacket = () => {
if (currentPacket > totalPackets) { if (currentPacket > totalPackets) {
setTimeout(()=>{ setTimeout(() => {
hideLoading(these); hideLoading(these);
these.Status.BottomMenu.show = false; these.Status.BottomMenu.show = false;
these.showPop({ these.showPop({
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
borderColor : '#BBE600',
buttonBgColor : '#BBE600'
}); });
resolve(); resolve();
},20000) }, 20000)
return; return;
} }
var packetData = imageData[currentPacket - 1][childPacket - 1]; var packetData = imageData[currentPacket - 1][childPacket - 1];
// if (packetData.length == 0) { // if (packetData.length == 0) {
// hideLoading(these); // hideLoading(these);
// these.Status.BottomMenu.show = false; // these.Status.BottomMenu.show = false;
@ -586,31 +613,30 @@
// resolve(); // resolve();
// return; // return;
// } // }
let start=0; let start = 0;
let bufferSize=packetData.length*2; let bufferSize = packetData.length * 2;
if(currentPacket==7 ){ if (currentPacket == 7) {
if(childPacket>2 && childPacket<9){ if (childPacket > 2 && childPacket < 9) {
bufferSize=496; bufferSize = 496;
} } else if (childPacket == 9) {
else if(childPacket==9){ bufferSize = 128;
bufferSize=128;
} }
} }
if(childPacket==1){ if (childPacket == 1) {
bufferSize=bufferSize+8 bufferSize = bufferSize + 8
start=8; start = 8;
} }
if(childPacket==9 ){//|| (currentPacket==7 && childPacket==3 if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
bufferSize=bufferSize+1 bufferSize = bufferSize + 1
} }
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式 //FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
var buffer = new ArrayBuffer(bufferSize); var buffer = new ArrayBuffer(bufferSize);
var dataView = new DataView(buffer); var dataView = new DataView(buffer);
if(childPacket==1){ if (childPacket == 1) {
dataView.setUint8(0, 0xFA); // 帧头 dataView.setUint8(0, 0xFA); // 帧头
dataView.setUint8(1, 0x09); // 帧头 dataView.setUint8(1, 0x09); // 帧头
dataView.setUint8(2, 0x10); // 帧头 dataView.setUint8(2, 0x10); // 帧头
@ -625,10 +651,10 @@
for (let i = 0; i < packetData.length; i++) { for (let i = 0; i < packetData.length; i++) {
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序 dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
} }
console.log("packetData.length=",packetData.length); console.log("packetData.length=", packetData.length);
console.log("bufferSize=",bufferSize) console.log("bufferSize=", bufferSize)
if(childPacket==9){// || (currentPacket==7 && childPacket==3 if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
dataView.setUint8(bufferSize-1, 0xFF); dataView.setUint8(bufferSize - 1, 0xFF);
} }
//发送数据包 //发送数据包
@ -637,8 +663,9 @@
.then(() => { .then(() => {
let curr = childPacket + (currentPacket - 1) * let curr = childPacket + (currentPacket - 1) *
totalChildPacket; totalChildPacket;
console.log(""+currentPacket+"大包,"+childPacket+"小包发送完成,总计"+curr); console.log("第" + currentPacket + "大包,第" + childPacket +
"小包发送完成,总计:" + curr);
updateLoading(these, { updateLoading(these, {
text: "正在发送" + curr + "/63" text: "正在发送" + curr + "/63"
@ -949,7 +976,7 @@
let packetSize = rgbdata.length; //每包均分的数量 let packetSize = rgbdata.length; //每包均分的数量
let mode = rgbdata.length % packetSize; //最后一包的数量 let mode = rgbdata.length % packetSize; //最后一包的数量
let cnt = let cnt =
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量 1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
let curr = 1; //当前包序号 let curr = 1; //当前包序号
let sendNext = () => { let sendNext = () => {
@ -994,7 +1021,7 @@
dataView.setUint8(bufferSize - 1, 0xFF); 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) console.log("inteval=", inteval)
ble.sendData(f.deviceId, buffer, f.writeServiceId, f ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 30).then(() => { .wirteCharactId, 30).then(() => {
@ -1027,12 +1054,12 @@
console.log("11111"); console.log("11111");
var result = null; var result = null;
try { try {
console.log("this.$refs.textToHex=",this.$refs.textToHex); console.log("this.$refs.textToHex=", this.$refs.textToHex);
result = await this.$refs.textToHex.drawAndGetPixels(); result = await this.$refs.textToHex.drawAndGetPixels();
} catch (ex) { } catch (ex) {
console.log("ex=", ex); console.log("ex=", ex);
} }
if(!result){ if (!result) {
hideLoading(this); hideLoading(this);
return; return;
} }
@ -1086,8 +1113,26 @@ if(!result){
if (flag) { if (flag) {
console.log("发送成功"); console.log("发送成功");
this.showPop({ 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 { } else {
this.showPop({ this.showPop({
message: "出现异常发送失败", message: "出现异常发送失败",

View File

@ -173,6 +173,11 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import {request,baseURL} from '../../utils/request';
import {
registerPersonInfo
} from '@/api/6170/deviceControl.js';
const pagePath = "pages/650/HBY650"; const pagePath = "pages/650/HBY650";
var ble = null; var ble = null;
var these = null; var these = null;
@ -259,7 +264,26 @@
iswarn: false iswarn: false
}, },
rgb565Data: [], 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)); console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data; var device = data.data;
these.device=device;
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) { if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v); console.log("找到设备了", v);
@ -374,9 +398,9 @@
return className; return className;
}, },
bleValueNotify: function(receive, device, path) { //订阅消息 bleValueNotify: function(receive, device, path) { //订阅消息
console.log("收到设备的数据", data)
let data = recei.ReceiveData(receive, device, pagePath); let data = recei.ReceiveData(receive, device, pagePath);
console.log("收到设备的数据",data)
if (data) { if (data) {
if ("staBlue_picture" in data) { if ("staBlue_picture" in data) {
//重发图片 //重发图片
@ -403,7 +427,7 @@ console.log("收到设备的数据",data)
let keys = Object.keys(data); let keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
let key = keys[i]; let key = keys[i];
if(key in these.formData){ if (key in these.formData) {
these.formData[key] = data[key]; these.formData[key] = data[key];
} }
@ -434,7 +458,7 @@ console.log("收到设备的数据",data)
// console.log("LinkedList=", ble.data.LinkedList); // console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData); // console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.formData.deviceId; return v.macAddress == these.device.deviceMac;
}); });
return f; return f;
@ -606,10 +630,11 @@ console.log("收到设备的数据",data)
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
}); });
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(()=>{ setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f.deviceId, f these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId); .writeServiceId, f.wirteCharactId);
},500); }, 500);
} }
@ -635,7 +660,7 @@ console.log("收到设备的数据",data)
const packetData = these.rgb565Data.slice(startIndex, const packetData = these.rgb565Data.slice(startIndex,
endIndex); endIndex);
// 构建数据包 // 构建数据包
const bufferSize =505;// 5 + packetData.length * 2; // 头部5字节 + 数据部分 const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize); const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer); const dataView = new DataView(buffer);
@ -771,17 +796,19 @@ console.log("收到设备的数据",data)
this.totalPackets = totalPackets; this.totalPackets = totalPackets;
// 发送单个数据包 // 发送单个数据包
const sendNextVideoPacket = () => { const sendNextVideoPacket = () => {
console.log("准备发送一段数据"); console.log("准备发送一段数据");
if (currentPacket > totalPackets) { if (currentPacket > totalPackets) {
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(()=>{ setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f.deviceId, f these.HoldYouHand("transmit complete", 0, f
.writeServiceId, f.wirteCharactId).then(()=>{ .deviceId, f
.writeServiceId, f.wirteCharactId).then(
() => {
console.log("全部发送完毕") console.log("全部发送完毕")
}).catch((ex)=>{ }).catch((ex) => {
console.log("出现异常",ex); console.log("出现异常", ex);
}); });
},500); }, 500);
} }
these.Status.BottomMenu.show = false; these.Status.BottomMenu.show = false;
@ -837,7 +864,7 @@ console.log("收到设备的数据",data)
} }
let inteval = 50; let inteval = 50;
console.log("开始发送一段视频"); // console.log("开始发送一段视频"); //
ble.sendData(f.deviceId, buffer, f.writeServiceId, f ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => { .wirteCharactId, 10).then(() => {
@ -902,13 +929,28 @@ console.log("收到设备的数据",data)
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId, let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
f.wirteCharactId); f.wirteCharactId);
let p2 = new Promise((succ, err) => { 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({ 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, filePath: videoPath,
name: 'file', name: 'file',
header: { header: {
"Method": "POST", "Method": "POST",
"Content-Type": "multipart/form-data" "Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
}, },
timeout: 600000, timeout: 600000,
fail: (ex) => { fail: (ex) => {
@ -1130,10 +1172,11 @@ console.log("收到设备的数据",data)
if (currentPacket > totalPackets) { if (currentPacket > totalPackets) {
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(()=>{ setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f.deviceId, f.writeServiceId, f these.HoldYouHand("transmit complete", 0, f.deviceId, f
.wirteCharactId); .writeServiceId, f
},500); .wirteCharactId);
}, 500);
} }
@ -1155,6 +1198,16 @@ console.log("收到设备的数据",data)
visibleClose: true visibleClose: true
}); });
these.setBleFormData(); 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; return;
} }
@ -1219,7 +1272,7 @@ console.log("收到设备的数据",data)
} }
if(ReSendNo){ if (ReSendNo) {
sendText(ReSendNo); sendText(ReSendNo);
return; return;
} }
@ -1261,16 +1314,26 @@ console.log("收到设备的数据",data)
} }
console.log("开始握手"); console.log("开始握手");
ble.sendData(deviceid, buffer, serviceid, characid, 10).then( let send = () => {
() => { ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
setTimeout(() => { () => {
console.log("握手成功并完成了等待"); setTimeout(() => {
resolve(true); console.log("握手成功并完成了等待");
}, pauseTime); resolve(true);
}).catch(err => { }, pauseTime);
console.log("握手没有成功", ) }).catch(err => {
reject(err); if (err.code == 10007) {
}); send();
} else {
console.log("握手没有成功", err)
reject(err);
}
});
}
send();
}); });

View File

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

View File

@ -125,7 +125,8 @@
let start = new Date(); let start = new Date();
console.log("Common.baseURL=" + Common.baseURL); console.log("Common.baseURL=" + Common.baseURL);
uni.uploadFile({ 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, filePath: this.videoPath,
name: 'file', name: 'file',
header: { header: {

View File

@ -35,11 +35,12 @@
updateLoading updateLoading
} from '@/utils/loading.js'; } from '@/utils/loading.js';
const pagePath="pages/common/addBLE/LinkBle"; const pagePath = "pages/common/addBLE/LinkBle";
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
var ble = null; var ble = null;
var timeInteval = null;
export default { export default {
data() { data() {
return { return {
@ -57,7 +58,8 @@
], ],
"linkStatu": false, "linkStatu": false,
"macAddress": "" "macAddress": ""
} },
serverDevice:null
} }
}, },
computed: { computed: {
@ -84,7 +86,7 @@
onLoad(option) { onLoad(option) {
these = this; these = this;
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
ble.addReceiveCallback((receive,f,path) => { ble.addReceiveCallback((receive, f, path) => {
console.log("收到设备消息,", receive); console.log("收到设备消息,", receive);
if (these.device.deviceId == receive.deviceId) { if (these.device.deviceId == receive.deviceId) {
// console.log("11111"); // console.log("11111");
@ -97,79 +99,91 @@
} }
} }
} }
},pagePath); }, pagePath);
eventChannel = this.getOpenerEventChannel(); eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) { eventChannel.on('LinkItem', function(data) {
console.log("data=",data); console.log("data=", data);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId; return v.deviceId == data.deviceId;
}); });
if (f) { if (f) {
let keys=Object.keys(f); let keys = Object.keys(f);
keys.forEach((v,index)=>{ keys.forEach((v, index) => {
these.device[v]=f[v]; these.device[v] = f[v];
}) })
console.log("LinkedList=",ble.data.LinkedList) console.log("LinkedList=", ble.data.LinkedList)
console.log("f=", f); console.log("f=", f);
console.log("获取到设备", these.device); console.log("获取到设备", these.device);
if (f.macAddress) { if (f.macAddress) {
these.device.macAddress = f.macAddress; these.device.macAddress = f.macAddress;
these.initDevice(); these.initDevice();
} }
} else { } else {
console.log("未获取到设备"); console.log("未获取到设备");
} }
}) })
let inteval = setInterval(this.initDevice, 5000);
}, },
methods: { methods: {
initDevice: function() { initDevice: function() {
showLoading(these, { clearTimeout(timeInteval);
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);
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() { Link() {
// 调用绑定设备接口 // 调用绑定设备接口
@ -207,6 +221,21 @@
if (res.code == 200) { if (res.code == 200) {
these.Statu.bound = true; these.Statu.bound = true;
these.Statu.boundRemark = "设备绑定成功!"; 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); ble.removeReceiveCallback(pagePath);
uni.$emit("refreshDeviceList"); uni.$emit("refreshDeviceList");

View File

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