650添加应答,app图标添加
This commit is contained in:
76
App.vue
76
App.vue
@ -6,32 +6,32 @@
|
||||
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){
|
||||
if(res.uniPlatform=='app'){
|
||||
upgrade.checkAndUpdateWgt("http://114.55.111.217/app/CheckUpdate");
|
||||
bleTool.getBleTool();
|
||||
bleTool.getBleTool();
|
||||
}
|
||||
}});
|
||||
},
|
||||
@ -47,21 +47,21 @@
|
||||
|
||||
<style lang="scss">
|
||||
@import 'vk-uview-ui/index.scss';
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
uni-slider .uni-slider-thumb {
|
||||
width: 66rpx !important;
|
||||
height: 80rpx !important;
|
||||
margin-top: -40rpx !important;
|
||||
border-radius: 16rpx !important;
|
||||
margin-left: -72rpx !important;
|
||||
// uni-slider .uni-slider-handle-wrapper {
|
||||
// border-radius: 20rpx;
|
||||
// }
|
||||
// uni-slider .uni-slider-thumb {
|
||||
// width: 66rpx !important;
|
||||
// height: 80rpx !important;
|
||||
// margin-top: -40rpx !important;
|
||||
// border-radius: 16rpx !important;
|
||||
// margin-left: -72rpx !important;
|
||||
|
||||
}
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
height: 88rpx;
|
||||
position: relative;
|
||||
}
|
||||
// }
|
||||
// uni-slider .uni-slider-handle-wrapper {
|
||||
// height: 88rpx;
|
||||
// position: relative;
|
||||
// }
|
||||
.custom-file-picker .file-picker__box-content {
|
||||
background: rgba(26, 26, 26, 1);
|
||||
border: none !important;
|
||||
@ -91,4 +91,10 @@
|
||||
font-family: "PingFang SC";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "PingFangBold";
|
||||
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -1,194 +0,0 @@
|
||||
<template>
|
||||
<view>
|
||||
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
|
||||
class="offscreen-canvas"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextToHexV1",
|
||||
props: {
|
||||
txts: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
validator: (value) => value.every(item => typeof item === 'string')
|
||||
},
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 16,
|
||||
validator: (value) => value > 0 && value <= 100
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#ffffff"
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: "#000000"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前Canvas的宽高(动态调整)
|
||||
currentCanvasWidth: 0,
|
||||
currentCanvasHeight: 0,
|
||||
// Canvas上下文(复用)
|
||||
ctx: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
validTxts() {
|
||||
return this.txts.filter(line => line.trim() !== '');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化Canvas上下文(只创建一次)
|
||||
this.ctx = uni.createCanvasContext('reusableCanvas', this);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 估算单行文本所需的Canvas宽度
|
||||
*/
|
||||
calcLineWidth(textLine) {
|
||||
return textLine.length * this.fontSize;
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除Canvas内容
|
||||
*/
|
||||
clearCanvas() {
|
||||
this.ctx.setFillStyle(this.bgColor);
|
||||
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* 复用单个Canvas处理所有文本行
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
// 逐行处理
|
||||
for (let y = 0; y < 16; y++) {
|
||||
let byte1 = 0,
|
||||
byte2 = 0;
|
||||
|
||||
// 每行16个像素,分为两个字节
|
||||
for (let x = 0; x < 16; x++) {
|
||||
// 计算像素在imageData中的索引 (RGBA格式)
|
||||
let index = (y * 16 + x) * 4;
|
||||
let red = imageData[index];
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = red < 128;
|
||||
|
||||
if (x < 8) {
|
||||
// 第一个字节(左8位)
|
||||
if (isBlack) {
|
||||
byte1 |= 0x80 >> x; // 从左到右设置位
|
||||
}
|
||||
} else {
|
||||
// 第二个字节(右8位)
|
||||
if (isBlack) {
|
||||
byte2 |= 0x80 >> (x - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将字节转换为两位十六进制字符串
|
||||
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
|
||||
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
// 1. 动态调整Canvas尺寸
|
||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||
this.currentCanvasHeight = this.fontSize;
|
||||
|
||||
// 2. 清空Canvas(绘制背景)
|
||||
this.clearCanvas();
|
||||
|
||||
// 3. 设置文字样式
|
||||
ctx.setFillStyle(this.color);
|
||||
ctx.setTextBaseline('middle');
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFang SC", PingFang SC, Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
let currentY = this.fontSize / 2;
|
||||
for (let j = 0; j < textLine.length; j++) {
|
||||
let char = textLine[j];
|
||||
ctx.fillText(char, currentX, currentY);
|
||||
// 按实际字符宽度计算间距
|
||||
let charWidth = ctx.measureText(char).width;
|
||||
currentX += charWidth;
|
||||
}
|
||||
|
||||
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.draw(false, () => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'reusableCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight,
|
||||
success: res => {
|
||||
|
||||
result={
|
||||
line: textLine,
|
||||
pixelData: res.data,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight
|
||||
};
|
||||
resolve();
|
||||
},
|
||||
fail: err => {
|
||||
// console.error(`处理第${i+1}行失败:`, err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
let linePixls = [];
|
||||
let item = this.validTxts[i];
|
||||
console.log("item=",item);
|
||||
for (var j = 0; j < item.length; j++) {
|
||||
let result = await drawTxt(item[j]);
|
||||
linePixls.push(convertCharToMatrix(result.pixelData));
|
||||
}
|
||||
console.log("hexs=",linePixls.join(","));
|
||||
arr.push(linePixls);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.offscreen-canvas {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@ -1,194 +1,195 @@
|
||||
<template>
|
||||
<view>
|
||||
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
|
||||
class="offscreen-canvas"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextToHexV1",
|
||||
props: {
|
||||
txts: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
validator: (value) => value.every(item => typeof item === 'string')
|
||||
},
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 16,
|
||||
validator: (value) => value > 0 && value <= 100
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#ffffff"
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: "#000000"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前Canvas的宽高(动态调整)
|
||||
currentCanvasWidth: 0,
|
||||
currentCanvasHeight: 0,
|
||||
// Canvas上下文(复用)
|
||||
ctx: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
validTxts() {
|
||||
return this.txts.filter(line => line.trim() !== '');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化Canvas上下文(只创建一次)
|
||||
this.ctx = uni.createCanvasContext('reusableCanvas', this);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 估算单行文本所需的Canvas宽度
|
||||
*/
|
||||
calcLineWidth(textLine) {
|
||||
return textLine.length * this.fontSize;
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除Canvas内容
|
||||
*/
|
||||
clearCanvas() {
|
||||
this.ctx.setFillStyle(this.bgColor);
|
||||
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* 复用单个Canvas处理所有文本行
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
// 逐行处理
|
||||
for (let y = 0; y < 16; y++) {
|
||||
let byte1 = 0,
|
||||
byte2 = 0;
|
||||
|
||||
// 每行16个像素,分为两个字节
|
||||
for (let x = 0; x < 16; x++) {
|
||||
// 计算像素在imageData中的索引 (RGBA格式)
|
||||
let index = (y * 16 + x) * 4;
|
||||
let red = imageData[index];
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = red < 128;
|
||||
|
||||
if (x < 8) {
|
||||
// 第一个字节(左8位)
|
||||
if (isBlack) {
|
||||
byte1 |= 0x80 >> x; // 从左到右设置位
|
||||
}
|
||||
} else {
|
||||
// 第二个字节(右8位)
|
||||
if (isBlack) {
|
||||
byte2 |= 0x80 >> (x - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将字节转换为两位十六进制字符串
|
||||
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
|
||||
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
// 1. 动态调整Canvas尺寸
|
||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||
this.currentCanvasHeight = this.fontSize;
|
||||
|
||||
// 2. 清空Canvas(绘制背景)
|
||||
this.clearCanvas();
|
||||
|
||||
// 3. 设置文字样式
|
||||
ctx.setFillStyle(this.color);
|
||||
<template>
|
||||
<view>
|
||||
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
|
||||
class="offscreen-canvas"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextToHexV1",
|
||||
props: {
|
||||
txts: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
validator: (value) => value.every(item => typeof item === 'string')
|
||||
},
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 16,
|
||||
validator: (value) => value > 0 && value <= 100
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#ffffff"
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: "#000000"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前Canvas的宽高(动态调整)
|
||||
currentCanvasWidth: 0,
|
||||
currentCanvasHeight: 0,
|
||||
// Canvas上下文(复用)
|
||||
ctx: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
validTxts() {
|
||||
return this.txts.filter(line => line.trim() !== '');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化Canvas上下文(只创建一次)
|
||||
this.ctx = uni.createCanvasContext('reusableCanvas', this);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 估算单行文本所需的Canvas宽度
|
||||
*/
|
||||
calcLineWidth(textLine) {
|
||||
return textLine.length * 16;
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除Canvas内容
|
||||
*/
|
||||
clearCanvas() {
|
||||
this.ctx.setFillStyle(this.bgColor);
|
||||
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* 复用单个Canvas处理所有文本行
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
// 逐行处理
|
||||
for (let y = 0; y < 16; y++) {
|
||||
let byte1 = 0,
|
||||
byte2 = 0;
|
||||
|
||||
// 每行16个像素,分为两个字节
|
||||
for (let x = 0; x < 16; x++) {
|
||||
// 计算像素在imageData中的索引 (RGBA格式)
|
||||
let index = (y * 16 + x) * 4;
|
||||
let red = imageData[index];
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = red < 128;
|
||||
|
||||
if (x < 8) {
|
||||
// 第一个字节(左8位)
|
||||
if (isBlack) {
|
||||
byte1 |= 0x80 >> x; // 从左到右设置位
|
||||
}
|
||||
} else {
|
||||
// 第二个字节(右8位)
|
||||
if (isBlack) {
|
||||
byte2 |= 0x80 >> (x - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将字节转换为两位十六进制字符串
|
||||
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
|
||||
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
// 1. 动态调整Canvas尺寸
|
||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||
this.currentCanvasHeight = 16;
|
||||
|
||||
// 2. 清空Canvas(绘制背景)
|
||||
this.clearCanvas();
|
||||
|
||||
// 3. 设置文字样式
|
||||
ctx.setFillStyle(this.color);
|
||||
ctx.setTextBaseline('middle');
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFang SC", PingFang SC, Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
let currentY = this.fontSize / 2;
|
||||
for (let j = 0; j < textLine.length; j++) {
|
||||
let char = textLine[j];
|
||||
ctx.fillText(char, currentX, currentY);
|
||||
// 按实际字符宽度计算间距
|
||||
let charWidth = ctx.measureText(char).width;
|
||||
currentX += charWidth;
|
||||
}
|
||||
|
||||
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.draw(false, () => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'reusableCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight,
|
||||
success: res => {
|
||||
|
||||
result={
|
||||
line: textLine,
|
||||
pixelData: res.data,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight
|
||||
};
|
||||
resolve();
|
||||
},
|
||||
fail: err => {
|
||||
// console.error(`处理第${i+1}行失败:`, err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
let linePixls = [];
|
||||
let item = this.validTxts[i];
|
||||
console.log("item=",item);
|
||||
for (var j = 0; j < item.length; j++) {
|
||||
let result = await drawTxt(item[j]);
|
||||
linePixls.push(convertCharToMatrix(result.pixelData));
|
||||
}
|
||||
console.log("hexs=",linePixls.join(","));
|
||||
arr.push(linePixls);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.offscreen-canvas {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
// ctx.setTextAlign('center')
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
let currentY = this.fontSize / 2;
|
||||
for (let j = 0; j < textLine.length; j++) {
|
||||
let char = textLine[j];
|
||||
ctx.fillText(char, currentX, currentY);
|
||||
// 按实际字符宽度计算间距
|
||||
let charWidth = ctx.measureText(char).width;
|
||||
currentX += charWidth;
|
||||
}
|
||||
|
||||
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.draw(false, () => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'reusableCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight,
|
||||
success: res => {
|
||||
|
||||
result={
|
||||
line: textLine,
|
||||
pixelData: res.data,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight
|
||||
};
|
||||
resolve();
|
||||
},
|
||||
fail: err => {
|
||||
// console.error(`处理第${i+1}行失败:`, err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
let linePixls = [];
|
||||
let item = this.validTxts[i];
|
||||
console.log("item=",item);
|
||||
for (var j = 0; j < item.length; j++) {
|
||||
let result = await drawTxt(item[j]);
|
||||
linePixls.push(convertCharToMatrix(result.pixelData));
|
||||
}
|
||||
console.log("hexs=",linePixls.join(","));
|
||||
arr.push(linePixls);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.offscreen-canvas {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@ -2,7 +2,7 @@
|
||||
const config = {
|
||||
// 开发环境
|
||||
development: {
|
||||
BASE_URL: 'http://192.168.2.34:8000',
|
||||
BASE_URL: 'http://192.168.110.54:8000',
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: '47.120.79.150',
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "JingQuan",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.9",
|
||||
"versionName" : "1.0.24",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
|
||||
36
pages.json
36
pages.json
@ -1,6 +1,12 @@
|
||||
{
|
||||
"pages": [
|
||||
|
||||
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设备类型"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/login/index",
|
||||
"style": {
|
||||
@ -116,12 +122,12 @@
|
||||
"navigationBarTitleText": "扫描到的设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/deviceDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY 6155"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/deviceDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY 6155"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/ImgCrop",
|
||||
"style": {
|
||||
@ -191,6 +197,7 @@
|
||||
"navigationBarTitleText": "呼叫"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/VideoSend",
|
||||
"style": {
|
||||
@ -256,11 +263,6 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY670"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/BlueTooth/ModeSetting/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设备类型"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/670/HBY670",
|
||||
@ -276,10 +278,16 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/670/History",
|
||||
"path": "pages/670/History",
|
||||
"style": {
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/BlueTooth/ModeSetting/4877",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "历史记录"
|
||||
"navigationBarTitleText" : ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,11 +35,11 @@
|
||||
handleCrop(e) {
|
||||
|
||||
var these = this;
|
||||
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
this.Statu = true;
|
||||
console.log("裁剪完成");
|
||||
console.log(e.tempFilePath);
|
||||
//
|
||||
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
|
||||
const ctx = uni.createCanvasContext('splashCanvas', this);
|
||||
ctx.drawImage(
|
||||
e.tempFilePath,
|
||||
@ -56,7 +56,7 @@
|
||||
height: 80,
|
||||
success: (res) => {
|
||||
// 处理像素数据并发送
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
|
||||
console.log("res.data.length="+res.data.length);
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<text class="value">{{formData.deviceName}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="lbl">充电状态</text>
|
||||
<text class="value">{{formData.statu}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -83,8 +83,8 @@
|
||||
<text class="usrtitle fleft">人员信息登记</text>
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHex class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#000000'"
|
||||
:color="'#FFFFFF'" :fontSize="16" />
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="14" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
@ -143,7 +143,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TextToHexVue from '@/components/TextToHex/TextToHex.vue';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
|
||||
import {
|
||||
@ -153,7 +153,11 @@
|
||||
} from '@/utils/loading.js'
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var BrighInteval = null;
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
@ -221,10 +225,10 @@
|
||||
liangDu: '100',
|
||||
id: '',
|
||||
deviceId: '',
|
||||
textLines: ['我爱你', '中国', '五星红旗'],
|
||||
textLines: ['', '', ''],
|
||||
mode: ''
|
||||
},
|
||||
|
||||
inteval: 200
|
||||
|
||||
}
|
||||
},
|
||||
@ -234,7 +238,52 @@
|
||||
onLoad: function() {
|
||||
these = this;
|
||||
ble = bleTool.getBleTool();
|
||||
ble.addReceiveCallback(these.bleValueNotify);
|
||||
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
|
||||
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
// if (v.name == bleName) {
|
||||
// console.log("找到设备了", v);
|
||||
// these.formData.deviceId = v.deviceId;
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// let link = () => {
|
||||
// if (bleName == 'FB_Site_UART') {
|
||||
// ble.LinkBlue(f.deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
|
||||
// '0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
|
||||
// } else {
|
||||
// ble.LinkBlue(f.deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
|
||||
// '0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
|
||||
// }
|
||||
|
||||
// }
|
||||
// if (!f) {
|
||||
|
||||
|
||||
// ble.addDeviceFound((res) => {
|
||||
// // console.log("发现新设备", res);
|
||||
// f = res.devices.find((v) => {
|
||||
// return v.name == bleName;
|
||||
// });
|
||||
// if (f) {
|
||||
|
||||
// console.log("找到目标设备了", f);
|
||||
// these.formData.deviceId = f.deviceId;
|
||||
|
||||
// link();
|
||||
|
||||
// ble.StopSearch();
|
||||
// }
|
||||
// });
|
||||
|
||||
// ble.StartSearch();
|
||||
// } else {
|
||||
// link();
|
||||
// }
|
||||
ble.addReceiveCallback(these.bleValueNotify);
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(data) {
|
||||
@ -243,7 +292,7 @@
|
||||
let device = data.data;
|
||||
console.log("收到父页面的参数:" + JSON.stringify(device));
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
if (v.deviceId == device.deviceId) {
|
||||
console.log("找到设备了", v);
|
||||
these.formData.deviceId = v.deviceId;
|
||||
return true;
|
||||
@ -310,8 +359,8 @@
|
||||
},
|
||||
methods: {
|
||||
getDevice: function() {
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("formData=", these.formData);
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("formData=", these.formData);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId == these.formData.deviceId;
|
||||
});
|
||||
@ -382,6 +431,15 @@
|
||||
this.formData.battary = batteryLevel;
|
||||
this.formData.statu = warn;
|
||||
this.formData.xuhang = lightingTime;
|
||||
|
||||
if(batteryLevel<=20){
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
this.setBleFormData();
|
||||
} catch (error) {
|
||||
@ -390,7 +448,7 @@
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
proParam: function() {
|
||||
|
||||
uni.navigateTo({
|
||||
@ -433,10 +491,55 @@
|
||||
var processAndSendImageData = function(pixels) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 创建RGB565格式的像素数据
|
||||
const rgb565Data = ble.convertToRGB565(pixels);
|
||||
const arr = ble.convertToRGB565(pixels, 'bgr');
|
||||
|
||||
var list = [];
|
||||
let index = 0; // 用于追踪arr的当前位置
|
||||
let packetSize=2048;
|
||||
let cSize=248;
|
||||
// 外层循环:7个主要元素(i从1到7)
|
||||
for (let i = 1; i < 8; i++) {
|
||||
let secondLevel = [];
|
||||
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){
|
||||
break;
|
||||
}
|
||||
thirdLevel.push(arr[index]);
|
||||
secondCnt++;
|
||||
index++;
|
||||
}
|
||||
|
||||
secondLevel.push(thirdLevel);
|
||||
}
|
||||
list.push(secondLevel);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// 分包发送
|
||||
sendImagePackets(rgb565Data).then(resolve).catch(reject);
|
||||
sendImagePackets(list).then(resolve).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
@ -446,90 +549,114 @@
|
||||
var sendImagePackets = function(imageData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
const totalPackets = 52;
|
||||
const totalPackets = 7;
|
||||
let currentPacket = 1;
|
||||
let childPacket = 1;
|
||||
let totalChildPacket = 9;
|
||||
|
||||
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
these.showPop({
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
});
|
||||
|
||||
resolve();
|
||||
setTimeout(()=>{
|
||||
hideLoading(these);
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
these.showPop({
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
});
|
||||
|
||||
resolve();
|
||||
},20000)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
if (currentPacket <= 51) {
|
||||
packetSize = 250; // 前51个包每个500字节
|
||||
} else {
|
||||
packetSize = 50; // 最后一个包100字节
|
||||
}
|
||||
var packetData = imageData[currentPacket - 1][childPacket - 1];
|
||||
// if (packetData.length == 0) {
|
||||
// hideLoading(these);
|
||||
// these.Status.BottomMenu.show = false;
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, imageData
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = imageData.slice(startIndex,
|
||||
endIndex); // imageData.subarray(startIndex, endIndex);
|
||||
console.log("imageData.length=" + imageData.length +
|
||||
",startIndex=" +
|
||||
startIndex +
|
||||
",endIndex=" + endIndex + ",数据包长度" + (endIndex -
|
||||
startIndex) +
|
||||
',packetData.length=' + packetData.length);
|
||||
// 构建数据包
|
||||
const bufferSize = 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
// these.showPop({
|
||||
// message: "上传成功",
|
||||
// iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
// });
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
// if(packetData.length==250)
|
||||
// {
|
||||
// dataView.setUint8(3, 0x01);
|
||||
// dataView.setUint8(4, 0xFF);
|
||||
// resolve();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (packetData.length == 250) {
|
||||
dataView.setUint8(3, 0x01);
|
||||
dataView.setUint8(4, 0xF4);
|
||||
} else {
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x64);
|
||||
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==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){
|
||||
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); //子包序号
|
||||
}
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
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);
|
||||
}
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
30)
|
||||
.then(() => {
|
||||
console.log("发送一个包完成了");
|
||||
|
||||
|
||||
let curr = childPacket + (currentPacket - 1) *
|
||||
totalChildPacket;
|
||||
console.log("第"+currentPacket+"大包,第"+childPacket+"小包发送完成,总计:"+curr);
|
||||
updateLoading(these, {
|
||||
text: "正在发送" + currentPacket + "/" +
|
||||
totalPackets
|
||||
text: "正在发送" + curr + "/63"
|
||||
|
||||
})
|
||||
currentPacket++;
|
||||
if (childPacket == 9) {
|
||||
currentPacket++;
|
||||
childPacket = 1;
|
||||
} else {
|
||||
childPacket++;
|
||||
}
|
||||
|
||||
setTimeout(sendNextPacket, 100);
|
||||
}).catch(err => {
|
||||
if (err.code == 10007) {
|
||||
setTimeout(sendNextPacket, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("发送数据包失败了", err);
|
||||
|
||||
these.Status.BottomMenu.show = false;
|
||||
@ -567,7 +694,8 @@
|
||||
|
||||
these.Status.BottomMenu.show = false;
|
||||
setTimeout(function() {
|
||||
processAndSendImageData(data.piexls).catch((ex) => {
|
||||
processAndSendImageData(data.piexls).catch((
|
||||
ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 0)
|
||||
@ -617,7 +745,7 @@
|
||||
{
|
||||
text: '爆闪',
|
||||
icon: '/static/images/6155/DeviceDetail/shan.png'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
icon: '/static/images/6155/DeviceDetail/close.png'
|
||||
@ -668,20 +796,23 @@
|
||||
this.setBleFormData();
|
||||
|
||||
|
||||
if (type == 'main') {
|
||||
|
||||
type = 0x04;
|
||||
} else if (type == 'fu') {
|
||||
|
||||
type = 0x05;
|
||||
}
|
||||
|
||||
this.currentMode = mode;
|
||||
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
dataValue = 0x01;
|
||||
|
||||
|
||||
if (type == 'main') {
|
||||
|
||||
dataValue = 0x01;
|
||||
} else if (type == 'fu') {
|
||||
|
||||
dataValue = 0x0A;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
dataValue = 0x04;
|
||||
@ -693,11 +824,11 @@
|
||||
dataValue = 0x03;
|
||||
break;
|
||||
case 4:
|
||||
dataValue = 0x00;
|
||||
dataValue = 0x0B;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
console.log("dataValue=", dataValue)
|
||||
// 构建数据包
|
||||
var buffer = new ArrayBuffer(6);
|
||||
var dataView = new DataView(buffer);
|
||||
@ -817,8 +948,8 @@
|
||||
|
||||
let packetSize = rgbdata.length; //每包均分的数量
|
||||
let mode = rgbdata.length % packetSize; //最后一包的数量
|
||||
let cnt = parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :
|
||||
0); //总包数量
|
||||
let cnt =
|
||||
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
|
||||
let curr = 1; //当前包序号
|
||||
|
||||
let sendNext = () => {
|
||||
@ -831,6 +962,7 @@
|
||||
let bufferSize = 261;
|
||||
|
||||
console.log("bufferSize=", bufferSize)
|
||||
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
let startIndex = (curr - 1) * packetSize;
|
||||
@ -844,7 +976,7 @@
|
||||
|
||||
let packetData = rgbdata.slice(startIndex,
|
||||
endIndex); //取一片数据发送
|
||||
|
||||
console.log("packetData.length=", packetData.length);
|
||||
let start = 0;
|
||||
if (curr == 1) {
|
||||
dataView.setUint8(0, 0xFA);
|
||||
@ -852,7 +984,7 @@
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
|
||||
// dataView.setUint16(2, str.length, false);
|
||||
|
||||
start = 4;
|
||||
}
|
||||
|
||||
@ -862,8 +994,8 @@
|
||||
|
||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
|
||||
let inteval =parseInt(this.inteval ? this.inteval : 50);
|
||||
console.log("inteval=", inteval)
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 30).then(() => {
|
||||
|
||||
@ -892,12 +1024,36 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
var result = await this.$refs.textToHex.drawAndGetPixels();
|
||||
|
||||
console.log("11111");
|
||||
var result = null;
|
||||
try {
|
||||
console.log("this.$refs.textToHex=",this.$refs.textToHex);
|
||||
result = await this.$refs.textToHex.drawAndGetPixels();
|
||||
} catch (ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
if(!result){
|
||||
hideLoading(this);
|
||||
return;
|
||||
}
|
||||
console.log("result=", result);
|
||||
result = result.map(level1 => {
|
||||
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"
|
||||
|
||||
// let arr1=('0x'+(str1.split(' ').join(",0x"))).split(',');
|
||||
// let arr2=('0x'+(str2.split(' ').join(",0x"))).split(',');
|
||||
// let arr3=('0x'+(str3.split(' ').join(",0x"))).split(',');
|
||||
|
||||
// result=[arr1,arr2,arr3];
|
||||
|
||||
|
||||
// console.log("result=",result);
|
||||
|
||||
|
||||
let h3dic = [0x06, 0x07, 0x08];
|
||||
@ -913,9 +1069,9 @@
|
||||
var rgb = result[i];
|
||||
|
||||
try {
|
||||
console.log("1111");
|
||||
// console.log("1111");
|
||||
await sendTxtPackge(rgb, h3dic[i], str);
|
||||
console.log("222222");
|
||||
// console.log("222222");
|
||||
} catch (ex) {
|
||||
flag = false;
|
||||
console.log("33333");
|
||||
@ -929,7 +1085,7 @@
|
||||
hideLoading(these);
|
||||
if (flag) {
|
||||
console.log("发送成功");
|
||||
this.showPop( {
|
||||
this.showPop({
|
||||
message: "发送成功"
|
||||
});
|
||||
} else {
|
||||
@ -956,23 +1112,25 @@
|
||||
},
|
||||
sliderChange: function(evt) {
|
||||
this.formData.liangDu = evt.detail.value;
|
||||
clearTimeout(BrighInteval)
|
||||
//给蓝牙设备发送信号更新亮度
|
||||
setTimeout(() => {
|
||||
BrighInteval = setTimeout(() => {
|
||||
this.sendBrightness();
|
||||
this.setBleFormData();
|
||||
}, 10);
|
||||
}, 100);
|
||||
},
|
||||
sendBrightness: function() {
|
||||
const buffer = new ArrayBuffer(6);
|
||||
const dataView = new DataView(buffer);
|
||||
let data = '0x' + parseInt(this.formData.liangDu).toString(16);
|
||||
console.log("亮度:" + this.formData.liangDu + ',16进制:' + data);
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x01); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x01); // 包序号
|
||||
dataView.setUint8(3, 0x00); // 数据长度
|
||||
dataView.setUint8(4, 0x01); // 数据长度
|
||||
dataView.setUint8(5, data); // 数据
|
||||
dataView.setUint8(0, 0xFA); // 帧头
|
||||
dataView.setUint8(1, 0x05); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x00); // 包序号
|
||||
dataView.setUint8(3, 0x01); // 包序号
|
||||
dataView.setUint8(4, data); // 数据长度
|
||||
dataView.setUint8(5, 0xFF); // 数据长度
|
||||
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
// 发送数据
|
||||
|
||||
@ -1382,7 +1382,7 @@
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
1267
pages/BlueTooth/ModeSetting/4877.vue
Normal file
1267
pages/BlueTooth/ModeSetting/4877.vue
Normal file
File diff suppressed because it is too large
Load Diff
@ -219,7 +219,7 @@
|
||||
|
||||
<script>
|
||||
import gbk from '@/utils/gbk.js';
|
||||
import TextToHexVue from '@/components/TextToHex/TextToHex.vue';
|
||||
import TextToHexVue from '@/components/TextToHex/TextToHexV1.vue';
|
||||
export default {
|
||||
comments: {
|
||||
TextToHexVue
|
||||
|
||||
@ -240,6 +240,8 @@
|
||||
import gbk from '@/utils/gbk.js';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import Common from '../../../utils/Common';
|
||||
import BleHelper from '../../../utils/BleHelper';
|
||||
var ble=BleHelper.getBleTool();
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
@ -251,7 +253,7 @@
|
||||
|
||||
canvasTop: '-1000px',
|
||||
canvasLeft: '-1000px',
|
||||
inteval: 100,
|
||||
inteval: 1000,
|
||||
isLoading: false,
|
||||
isBluetoothOpen: false,
|
||||
isSearching: false,
|
||||
@ -270,7 +272,7 @@
|
||||
logList: [],
|
||||
packetCount: 1,
|
||||
currentPage: 'deviceList',
|
||||
targetDeviceName: 'JQZM-EF4651',
|
||||
targetDeviceName: 'JQZM-EF4651',//FB_Site_UART
|
||||
currentTab: 'mode',
|
||||
brightness: 50,
|
||||
brightnessTimer: null,
|
||||
@ -287,7 +289,7 @@
|
||||
totalPackets: 100,
|
||||
imageWidth: 0,
|
||||
imageHeight: 0,
|
||||
textLines: ['下雨了', '天亮了', '连接成功'],
|
||||
textLines: ['那个', '你看到我的小熊', '了吗'],
|
||||
textProgress: 0,
|
||||
currentTextPacket: 0,
|
||||
totalTextPackets: 4,
|
||||
@ -308,6 +310,7 @@
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
this.initBluetoothAdapter();
|
||||
},
|
||||
methods: {
|
||||
@ -335,32 +338,41 @@
|
||||
},
|
||||
// 蓝牙初始化
|
||||
initBluetoothAdapter() {
|
||||
ble.addDeviceFound(this.onDeviceFound);
|
||||
console.log('开始初始化蓝牙适配器');
|
||||
uni.openBluetoothAdapter({
|
||||
success: (res) => {
|
||||
this.isBluetoothOpen = true;
|
||||
this.bluetoothStatus = '已开启';
|
||||
console.log('蓝牙适配器初始化成功');
|
||||
this.getBluetoothAdapterState();
|
||||
|
||||
// 自动开始搜索设备
|
||||
this.startSearch();
|
||||
},
|
||||
fail: (err) => {
|
||||
this.bluetoothStatus = '初始化失败';
|
||||
console.log(`蓝牙适配器初始化失败: ${err.errMsg}`);
|
||||
if (err.errCode === 10001) {
|
||||
uni.onBluetoothAdapterStateChange((res) => {
|
||||
if (res.available) {
|
||||
this.isBluetoothOpen = true;
|
||||
this.bluetoothStatus = '已开启';
|
||||
console.log('蓝牙适配器已开启');
|
||||
this.startSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ble.OpenBlue().then((res)=>{
|
||||
this.isBluetoothOpen = true;
|
||||
this.bluetoothStatus = '已开启';
|
||||
ble.StartSearch();
|
||||
}).catch((err)=>{
|
||||
this.isBluetoothOpen = true;
|
||||
this.bluetoothStatus = '已开启';
|
||||
});
|
||||
// uni.openBluetoothAdapter({
|
||||
// success: (res) => {
|
||||
// this.isBluetoothOpen = true;
|
||||
// this.bluetoothStatus = '已开启';
|
||||
// console.log('蓝牙适配器初始化成功');
|
||||
// this.getBluetoothAdapterState();
|
||||
|
||||
// // 自动开始搜索设备
|
||||
// this.startSearch();
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// this.bluetoothStatus = '初始化失败';
|
||||
// console.log(`蓝牙适配器初始化失败: ${err.errMsg}`);
|
||||
// if (err.errCode === 10001) {
|
||||
// uni.onBluetoothAdapterStateChange((res) => {
|
||||
// if (res.available) {
|
||||
// this.isBluetoothOpen = true;
|
||||
// this.bluetoothStatus = '已开启';
|
||||
// console.log('蓝牙适配器已开启');
|
||||
// this.startSearch();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
// 获取蓝牙适配器状态
|
||||
@ -418,39 +430,46 @@
|
||||
this.deviceList = [];
|
||||
this.searchTips = '搜索中...';
|
||||
console.log('开始搜索蓝牙设备');
|
||||
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
services: ["0xFFE0"],
|
||||
allowDuplicatesKey: false,
|
||||
success: (res) => {
|
||||
console.log('开始搜索蓝牙设备成功');
|
||||
this.onDeviceFound();
|
||||
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
this.isSearching = false;
|
||||
this.searchTips = '搜索失败';
|
||||
console.log(`搜索蓝牙设备失败: ${err.errMsg}`);
|
||||
}
|
||||
ble.StartSearch().then(()=>{
|
||||
console.log('开始搜索蓝牙设备成功');
|
||||
}).catch((err)=>{
|
||||
this.isSearching = false;
|
||||
this.searchTips = '搜索失败';
|
||||
console.log(`搜索蓝牙设备失败: ${err.errMsg}`);
|
||||
});
|
||||
// uni.startBluetoothDevicesDiscovery({
|
||||
|
||||
// allowDuplicatesKey: false,
|
||||
// success: (res) => {
|
||||
// console.log('开始搜索蓝牙设备成功');
|
||||
// this.onDeviceFound();
|
||||
|
||||
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// this.isSearching = false;
|
||||
// this.searchTips = '搜索失败';
|
||||
// console.log(`搜索蓝牙设备失败: ${err.errMsg}`);
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
// 停止搜索蓝牙设备
|
||||
stopSearch() {
|
||||
this.isSearching = false;
|
||||
this.searchTips = this.deviceList.length > 0 ? '搜索完成' : '未发现蓝牙设备';
|
||||
|
||||
uni.stopBluetoothDevicesDiscovery({
|
||||
success: () => {
|
||||
console.log('停止搜索蓝牙设备');
|
||||
}
|
||||
});
|
||||
ble.StartSearch();
|
||||
// uni.stopBluetoothDevicesDiscovery({
|
||||
// success: () => {
|
||||
// console.log('停止搜索蓝牙设备');
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
// 监听发现新设备
|
||||
onDeviceFound() {
|
||||
uni.onBluetoothDeviceFound((res) => {
|
||||
onDeviceFound(res) {
|
||||
// uni.onBluetoothDeviceFound((res) => {
|
||||
// console.log("发现新设备",res);
|
||||
var device = res.devices[0];
|
||||
if (!device.name && !device.localName) return;
|
||||
// if ((device.name || device.localName) === this.targetDeviceName) {
|
||||
@ -467,24 +486,62 @@
|
||||
this.deviceList[index].RSSI = device.RSSI;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
// 如果找到目标设备,自动连接
|
||||
if ((device.name || device.localName) === this.targetDeviceName) {
|
||||
console.log(`发现目标设备: ${JSON.stringify(device)}`);
|
||||
this.connectDevice(device.deviceId, this.targetDeviceName,device);
|
||||
}
|
||||
});
|
||||
// });
|
||||
},
|
||||
|
||||
// 连接蓝牙设备
|
||||
connectDevice(deviceId, deviceName,device) {
|
||||
if (this.isConnected && this.connectedDeviceId === deviceId) return;
|
||||
|
||||
let gotoDetail=()=>{
|
||||
ble.StopSearch();
|
||||
uni.navigateTo({
|
||||
url:"/pages/6155/deviceDetail",
|
||||
success(res) {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: {deviceId:deviceId},
|
||||
deviceType: '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},fail(ex){
|
||||
console.log("跳转失败",ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.isConnected && this.connectedDeviceId === deviceId) {
|
||||
gotoDetail();
|
||||
return;
|
||||
};
|
||||
|
||||
this.isLoading = true;
|
||||
if(device){
|
||||
console.log("device=",device);
|
||||
}
|
||||
|
||||
let promise=null;
|
||||
if (deviceName == 'FB_Site_UART') {
|
||||
promise=ble.LinkBlue(deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
|
||||
'0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
|
||||
} else {
|
||||
promise=ble.LinkBlue(deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
|
||||
'0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
|
||||
}
|
||||
|
||||
promise.then(res=>{
|
||||
console.log("连接成功了");
|
||||
gotoDetail();
|
||||
this.isConnected=true;
|
||||
}).catch(err=>{
|
||||
console.log("连接失败了",err);
|
||||
this.isConnected=false;
|
||||
});
|
||||
return;
|
||||
console.log(`开始连接设备: ${deviceName}`);
|
||||
var these = this;
|
||||
uni.createBLEConnection({
|
||||
@ -502,16 +559,20 @@
|
||||
setTimeout(function() {
|
||||
uni.setBLEMTU({
|
||||
deviceId: deviceId,
|
||||
mtu: 1024,
|
||||
mtu: 512,
|
||||
success: (info) => {
|
||||
console.log("设置mtu成功",info)
|
||||
these.getDeviceServices(deviceId);
|
||||
},
|
||||
fail: (ex) => {
|
||||
console.log("设置mtu失败" + JSON.stringify(ex));
|
||||
these.getDeviceServices(deviceId);
|
||||
},finally(){
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
these.getDeviceServices(deviceId);
|
||||
|
||||
}, 2000)
|
||||
// 获取服务和特征值
|
||||
|
||||
@ -648,7 +709,7 @@
|
||||
deviceId: deviceId,
|
||||
success: (res) => {
|
||||
|
||||
these.addLog("发现服务" + JSON.stringify(res.services));
|
||||
console.log("发现服务" + JSON.stringify(res.services));
|
||||
if (res.services.length == 0) {
|
||||
setTimeout(function() {
|
||||
these.getDeviceServices(deviceId);
|
||||
@ -662,11 +723,11 @@
|
||||
});
|
||||
|
||||
if (targetService) {
|
||||
these.addLog(`找到目标服务: ${targetService.uuid}`);
|
||||
console.log(`找到目标服务: ${targetService.uuid}`);
|
||||
this.serviceId = targetService.uuid;
|
||||
this.getDeviceCharacteristics(deviceId, targetService.uuid);
|
||||
} else {
|
||||
these.addLog("没找到目标服务");
|
||||
console.log("没找到目标服务");
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
@ -684,7 +745,7 @@
|
||||
serviceId: serviceId,
|
||||
success: (res) => {
|
||||
console.log(`获取设备特征值成功,共发现 ${res.characteristics.length} 个特征值`);
|
||||
these.addLog(`获取设备成功:${JSON.stringify(res.characteristics)}`);
|
||||
console.log(`获取设备成功:${JSON.stringify(res.characteristics)}`);
|
||||
// 查找可写特征值
|
||||
var writeChar = res.characteristics.find(char => {
|
||||
return char.uuid.indexOf("FFE1") > -1 || char.uuid.indexOf(
|
||||
@ -818,7 +879,7 @@
|
||||
"续航时间:"+this.receiveData.time
|
||||
];
|
||||
this.logList=[];
|
||||
this.addLog(arr.join(","));
|
||||
console.log(arr.join(","));
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:',error);
|
||||
}
|
||||
@ -833,14 +894,14 @@
|
||||
let arr=hexs.split(' ');
|
||||
if(arr.length>=7){
|
||||
this.receiveData.macAddress=arr.slice(1,7).join(":");
|
||||
this.addLog("设备mac地址:"+this.receiveData.macAddress);
|
||||
console.log("设备mac地址:"+this.receiveData.macAddress);
|
||||
}else{
|
||||
|
||||
this.addLog("收到无效的数据");
|
||||
console.log("收到无效的数据");
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.addLog("收到无效的数据");
|
||||
console.log("收到无效的数据");
|
||||
|
||||
}
|
||||
}
|
||||
@ -929,7 +990,7 @@
|
||||
setMode(mode, type) {
|
||||
this.logList = [];
|
||||
if (!this.isConnected) {
|
||||
this.addLog("未连接设备")
|
||||
console.log("未连接设备")
|
||||
uni.showToast({
|
||||
title: '未连接设备',
|
||||
icon: 'none'
|
||||
@ -1195,10 +1256,33 @@
|
||||
processAndSendImageData(pixels) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 创建RGB565格式的像素数据
|
||||
var rgb565Data = this.convertToRGB565(pixels, 160, 80);
|
||||
// console.log("rgb565Data=,",rgb565Data);
|
||||
var arr = this.convertToRGB565(pixels, 160, 80);
|
||||
|
||||
var list = [];
|
||||
let index = 0; // 用于追踪arr的当前位置
|
||||
|
||||
// 外层循环:7个主要元素(i从1到7)
|
||||
for (let i = 1; i < 8; i++) {
|
||||
let secondLevel = [];
|
||||
// 中层循环:每个主要元素包含9个子数组(j从1到9)
|
||||
for (let j = 1; j < 10; j++) {
|
||||
// 确定当前子数组的长度:前8个是254,第9个是16
|
||||
let length = (j < 9) ? 248 : 128;
|
||||
let thirdLevel = [];
|
||||
|
||||
// 从arr中提取相应数量的元素
|
||||
for (let k = 0; k < length && index < arr.length; k++) {
|
||||
thirdLevel.push(arr[index]);
|
||||
index++;
|
||||
}
|
||||
|
||||
secondLevel.push(thirdLevel);
|
||||
}
|
||||
list.push(secondLevel);
|
||||
}
|
||||
|
||||
// 分包发送
|
||||
this.sendImagePackets(rgb565Data).then(resolve).catch(reject);
|
||||
this.sendImagePackets(list).then(resolve).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
@ -1221,8 +1305,11 @@
|
||||
var b = pixels[i + 2];
|
||||
|
||||
|
||||
//var rgb565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
var bgr565 = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
|
||||
// var rgb565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
|
||||
|
||||
var bgr565 = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
|
||||
|
||||
result[index++] = bgr565;
|
||||
}
|
||||
|
||||
@ -1239,68 +1326,61 @@
|
||||
// 总数据包数
|
||||
|
||||
let currentPacket = 1;
|
||||
let packetSize = 120;
|
||||
let mode = imageData.length % packetSize;
|
||||
let totalPackets = parseInt(imageData.length / packetSize) + (mode > 0 ? 1 : 0)
|
||||
|
||||
let totalPackets =7;
|
||||
let childPacket=1;
|
||||
let totalChildPacket=9;
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 100);
|
||||
this.totalPackets = totalPackets;
|
||||
this.totalPackets = 57;
|
||||
// 发送单个数据包
|
||||
var sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
if (currentPacket> totalPackets) {
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
var packetData = imageData[currentPacket-1][childPacket-1];
|
||||
if(packetData.length==0){
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var start = 0;
|
||||
var dataLength = 0;
|
||||
var bufferSize = 0;
|
||||
if (currentPacket == 1) {
|
||||
bufferSize = packetSize * 2 + 5;
|
||||
dataLength = packetSize * 2;
|
||||
start = 5;
|
||||
} else if (currentPacket == totalPackets) {
|
||||
bufferSize = mode > 0 ? (mode * 2) : (packetSize * 2);
|
||||
dataLength = bufferSize
|
||||
} else {
|
||||
bufferSize = packetSize * 2;
|
||||
dataLength = bufferSize;
|
||||
}
|
||||
// 创建数据包
|
||||
var startIndex = (currentPacket - 1) * packetSize;
|
||||
var endIndex = Math.min(startIndex + packetSize, imageData.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
var packetData = imageData.slice(startIndex,
|
||||
endIndex); // imageData.subarray(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
|
||||
|
||||
var buffer = new ArrayBuffer(bufferSize);
|
||||
var buffer = new ArrayBuffer(500);
|
||||
var dataView = new DataView(buffer);
|
||||
|
||||
if (currentPacket == 1) { //第一包要填充头部
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x70); // 帧头
|
||||
dataView.setUint8(1, 0x65); // 帧头
|
||||
dataView.setUint8(2, 0x0A); // 帧类型
|
||||
dataView.setUint16(3, dataLength, false); //包长度
|
||||
}
|
||||
dataView.setUint8(0, 0xFB); // 帧头
|
||||
dataView.setUint8(1, 0x09); // 帧头
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
dataView.setUint8(3, childPacket); //子包序号
|
||||
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
|
||||
dataView.setUint16(4 + i * 2, packetData[i], false); //本包数据,大端字节序
|
||||
}
|
||||
|
||||
if(packetData.length<248){
|
||||
for (var i = 4+packetData.length*2; i < 500; i++) {
|
||||
dataView.setUint8(i, 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
//发送数据包
|
||||
this.sendData(buffer).then(() => {
|
||||
// 更新进度
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) * totalPackets);
|
||||
|
||||
currentPacket++;
|
||||
this.currentPacket =childPacket+ (currentPacket-1)*totalChildPacket;
|
||||
this.progress = Math.round((this.currentPacket / this.totalPackets) * 100);
|
||||
if(childPacket==9){
|
||||
currentPacket++;
|
||||
childPacket=1;
|
||||
}else{
|
||||
childPacket++;
|
||||
}
|
||||
|
||||
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
}).catch(err => {
|
||||
@ -1332,7 +1412,7 @@
|
||||
title: "请稍候....",
|
||||
mask: true
|
||||
});
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: '开始发送文字'
|
||||
});
|
||||
@ -1346,7 +1426,7 @@
|
||||
let mode = rgbdata.length % packetSize; //最后一包的数量
|
||||
let cnt = parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 : 0); //总包数量
|
||||
let curr = 1; //当前包序号
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: '当前包' + curr
|
||||
});
|
||||
@ -1356,7 +1436,7 @@
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "正在向设备发送" + curr + "/" + cnt
|
||||
})
|
||||
@ -1372,13 +1452,13 @@
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
let startIndex = (curr - 1) * packetSize;
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "分片大小" + bufferSize
|
||||
})
|
||||
let endIndex = Math.min(startIndex + packetSize, rgbdata.length);
|
||||
if (startIndex > endIndex) {
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送完成"
|
||||
})
|
||||
@ -1386,7 +1466,7 @@
|
||||
}
|
||||
|
||||
let packetData = rgbdata.slice(startIndex, endIndex); //取一片数据发送
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "获取到分片"
|
||||
})
|
||||
@ -1396,8 +1476,6 @@
|
||||
dataView.setUint8(1, type);
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
|
||||
// dataView.setUint16(2, str.length, false);
|
||||
start = 4;
|
||||
}
|
||||
|
||||
@ -1406,7 +1484,7 @@
|
||||
}
|
||||
|
||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "数据准备就绪"
|
||||
})
|
||||
@ -1414,7 +1492,7 @@
|
||||
|
||||
//发送数据包
|
||||
this.sendData(buffer).then(() => {
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送成功,准备发送下一包"
|
||||
})
|
||||
@ -1422,7 +1500,7 @@
|
||||
setTimeout(sendNext, inteval);
|
||||
}).catch(err => {
|
||||
console.log("err=", err);
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "出现错误" + JSON.stringify(err)
|
||||
});
|
||||
@ -1438,7 +1516,7 @@
|
||||
sendNext();
|
||||
} catch (ex) {
|
||||
console.log("ex=", ex);
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "出现异常1" + JSON.stringify(ex)
|
||||
})
|
||||
@ -1450,12 +1528,12 @@
|
||||
|
||||
}
|
||||
|
||||
// this.addLog({
|
||||
// console.log({
|
||||
// date: Common.DateFormat(),
|
||||
// remark: '正在取模'
|
||||
// });
|
||||
var result = await this.$refs.textToHex.drawAndGetPixels();
|
||||
// this.addLog({
|
||||
// console.log({
|
||||
// date: Common.DateFormat(),
|
||||
// remark: '取模成功'
|
||||
// });
|
||||
@ -1464,6 +1542,19 @@
|
||||
});
|
||||
|
||||
|
||||
// console.log("result=",result);
|
||||
// var str1="00 00 0E 58 7C 4C 08 44 08 40 7F FE 08 60 08 64 0B 6C 7F 38 78 30 08 72 08 D2 0B 9E 38 0C 00 00 00 00 1F F8 18 08 1F F8 18 18 18 18 1F F8 00 00 7F FE 01 80 19 80 19 F8 3D 80 67 80 61 FE 00 00 00 00 01 80 01 80 3F FC 3F FC 21 84 21 84 21 84 21 84 3F FC 21 84 01 80 01 80 01 80 01 80 00 00 00 00 7F FE 7F FE 60 06 6F F6 61 86 61 86 6F E6 61 86 61 A6 61 A6 6F F6 60 06 7F FE 7F FE 00 00 00 00 01 80 01 80 01 80 01 80 01 80 01 80 03 C0 02 40 06 60 0C 30 0C 10 38 1C 70 0E 40 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
|
||||
// var str2="00 00 3F FC 3F 00 19 98 7F FE 7F FE 66 06 1F F8 04 00 0F F8 0F F8 1A 30 31 E0 73 F0 4E 1C 00 00 00 00 7F FE 7F FE 60 06 6F F6 61 86 61 86 6F E6 61 86 61 A6 61 A6 6F F6 60 06 7F FE 7F FE 00 00 00 00 01 00 3F F6 03 0C 01 18 7F FE 01 C0 03 80 1F F8 78 08 08 08 0F F8 08 08 0F F8 0F F8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
|
||||
// var str3="00 00 3F FC 3F FC 01 80 01 80 01 00 7F FE 03 80 03 C0 02 40 06 60 0C 30 18 18 30 0C 60 06 00 00 00 00 7F FE 7F FE 01 00 01 00 01 C0 01 E0 01 38 01 0C 01 00 01 00 01 00 01 00 01 00 01 00 00 00 00 00 33 00 13 00 1B 00 7F FC 7F FC 02 04 02 04 02 84 06 C4 04 64 0C 24 18 0C 30 0C 60 78 00 00 00 00 04 20 0C 20 08 30 18 18 10 18 31 0C 63 06 43 02 06 20 04 30 0C 10 18 18 3F F8 18 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
|
||||
|
||||
// let arr1=('0x'+(str1.split(' ').join(",0x"))).split(',');
|
||||
// let arr2=('0x'+(str2.split(' ').join(",0x"))).split(',');
|
||||
// let arr3=('0x'+(str3.split(' ').join(",0x"))).split(',');
|
||||
|
||||
// result=[arr1,arr2,arr3];
|
||||
|
||||
console.log("result=",result);
|
||||
|
||||
let h3dic = [0x06, 0x07, 0x08];
|
||||
let pros = [];
|
||||
let flag = true;
|
||||
@ -1475,7 +1566,7 @@
|
||||
|
||||
let width = str.length * 16;
|
||||
var rgb = result[i];
|
||||
this.addLog({
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: '开始发送第' + (i + 1)
|
||||
});
|
||||
@ -1509,39 +1600,62 @@
|
||||
|
||||
// 发送数据通用方法
|
||||
sendData(buffer) {
|
||||
this.addLog("设备就绪,正在握手");
|
||||
console.log("设备就绪,正在握手");
|
||||
return new Promise((resolve, reject) => {
|
||||
this.addLog("握手成功,正在发送");
|
||||
this.addLog("设备id:" + this.connectedDeviceId);
|
||||
this.addLog("服务id:" + this.serviceId);
|
||||
this.addLog("特征id:" + this.writeCharacteristicId);
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
characteristicId: this.writeCharacteristicId,
|
||||
writeType:plus.os.name=='Android'?'writeNoResponse':'write',
|
||||
value: buffer,
|
||||
success: () => {
|
||||
this.addLog({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送数据成功"
|
||||
})
|
||||
resolve();
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
this.addLog({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送数据失败" + JSON.stringify(err)
|
||||
})
|
||||
reject(err);
|
||||
},
|
||||
complete: () => {
|
||||
this.addLog({
|
||||
date: Common.DateFormat(),
|
||||
remark: "向设备写入数据完成"
|
||||
})
|
||||
console.log("握手成功,正在发送");
|
||||
console.log("设备id:" + this.connectedDeviceId);
|
||||
console.log("服务id:" + this.serviceId);
|
||||
console.log("特征id:" + this.writeCharacteristicId);
|
||||
let promise1=new Promise((succ,err)=>{
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
characteristicId: this.writeCharacteristicId,
|
||||
writeType:plus.os.name=='Android'?'writeNoResponse':'write',
|
||||
value: buffer,
|
||||
success: () => {
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送数据成功"
|
||||
})
|
||||
succ();
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "发送数据失败" + JSON.stringify(err)
|
||||
})
|
||||
err(err);
|
||||
},
|
||||
complete: () => {
|
||||
console.log({
|
||||
date: Common.DateFormat(),
|
||||
remark: "向设备写入数据完成"
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let promise2=new Promise((succ,err)=>{
|
||||
setTimeout(()=>{
|
||||
err({
|
||||
code: -1,
|
||||
errMsg: '超时了'
|
||||
});
|
||||
},50)
|
||||
})
|
||||
|
||||
Promise.race([promise1, promise2]).then(resolve).catch((ex) => {
|
||||
console.log("ex=", ex);
|
||||
if (ex.code == -1) {
|
||||
resolve(ex);
|
||||
} else {
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
}).finally(() => {
|
||||
//console.log("完成了")
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -449,7 +449,7 @@
|
||||
console.log("设置mtu失败" + JSON.stringify(ex));
|
||||
},
|
||||
complete() {
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@ -698,101 +698,224 @@
|
||||
uni.onBLECharacteristicValueChange((
|
||||
receive) => {
|
||||
|
||||
var bytesToHexString =function(bytes) {
|
||||
var bytesToHexString =
|
||||
function(bytes) {
|
||||
return bytes.map(
|
||||
byte =>byte.toString(16).padStart(2, '0')
|
||||
byte =>
|
||||
byte
|
||||
.toString(
|
||||
16)
|
||||
.padStart(
|
||||
2, '0')
|
||||
).join(' ')
|
||||
}
|
||||
|
||||
|
||||
var parseData = (bytes) => {
|
||||
if (bytes.length <7) {
|
||||
console.log('数据包长度不足,至少需要6个字节');
|
||||
var parseData = (
|
||||
bytes) => {
|
||||
if (bytes.length <
|
||||
7) {
|
||||
console.log(
|
||||
'数据包长度不足,至少需要6个字节'
|
||||
);
|
||||
return;
|
||||
}
|
||||
let date = new Date();
|
||||
this.receiveData.date =date.getHours() +":" + date.getMinutes() +":" + date.getSeconds();
|
||||
if(bytes[0]==0x55){
|
||||
let date =
|
||||
new Date();
|
||||
this.receiveData
|
||||
.date = date
|
||||
.getHours() +
|
||||
":" + date
|
||||
.getMinutes() +
|
||||
":" + date
|
||||
.getSeconds();
|
||||
if (bytes[0] ==
|
||||
0x55) {
|
||||
try {
|
||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||
let staticLevelByte = bytes[1];
|
||||
let staticLevelText = '未知';
|
||||
switch ( staticLevelByte ) {
|
||||
let staticLevelByte =
|
||||
bytes[
|
||||
1];
|
||||
let staticLevelText =
|
||||
'未知';
|
||||
switch (
|
||||
staticLevelByte
|
||||
) {
|
||||
case 0x65:
|
||||
staticLevelText = '高档';
|
||||
staticLevelText
|
||||
=
|
||||
'高档';
|
||||
break;
|
||||
case 0x66:
|
||||
staticLevelText = '中档';
|
||||
staticLevelText
|
||||
=
|
||||
'中档';
|
||||
break;
|
||||
case 0x67:
|
||||
staticLevelText = '低档';
|
||||
staticLevelText
|
||||
=
|
||||
'低档';
|
||||
break;
|
||||
case 0x68:
|
||||
staticLevelText = '关闭';
|
||||
staticLevelText
|
||||
=
|
||||
'关闭';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// 解析照明档位
|
||||
let lightingLevelByte = bytes[2];
|
||||
let lightingLevelText = lightingLevelByte === 0x6e ? '开启':'关闭';
|
||||
|
||||
let lightingLevelByte =
|
||||
bytes[
|
||||
2];
|
||||
let lightingLevelText =
|
||||
lightingLevelByte ===
|
||||
0x6e ?
|
||||
'开启' :
|
||||
'关闭';
|
||||
|
||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||
let lightingTime =(bytes[3] <<8) | bytes[4];
|
||||
|
||||
let lightingTime =
|
||||
(bytes[
|
||||
3] <<
|
||||
8
|
||||
) |
|
||||
bytes[
|
||||
4];
|
||||
|
||||
// 解析剩余电量
|
||||
let batteryLevelByte = bytes[5];
|
||||
let batteryLevelByte =
|
||||
bytes[
|
||||
5];
|
||||
// 电量百分比范围检查
|
||||
let batteryLevel = Math.max(0,Math.min(100, batteryLevelByte));
|
||||
|
||||
let warn=bytes[6];
|
||||
if(warn==0x00){
|
||||
warn='无预警';
|
||||
let batteryLevel =
|
||||
Math
|
||||
.max(0,
|
||||
Math
|
||||
.min(
|
||||
100,
|
||||
batteryLevelByte
|
||||
)
|
||||
);
|
||||
|
||||
let warn =
|
||||
bytes[
|
||||
6];
|
||||
if (warn ==
|
||||
0x00) {
|
||||
warn =
|
||||
'无预警';
|
||||
} else if (
|
||||
warn ==
|
||||
0x01) {
|
||||
warn =
|
||||
'弱预警';
|
||||
} else if (
|
||||
warn ==
|
||||
0x02) {
|
||||
warn =
|
||||
'中预警';
|
||||
} else if (
|
||||
warn ==
|
||||
0x03) {
|
||||
warn =
|
||||
'强预警';
|
||||
} else if (
|
||||
warn ==
|
||||
0x04) {
|
||||
warn =
|
||||
'非常强预警';
|
||||
}
|
||||
else if(warn==0x01){
|
||||
warn='弱预警';
|
||||
}
|
||||
else if(warn==0x02){
|
||||
warn='中预警';
|
||||
}
|
||||
else if(warn==0x03){
|
||||
warn='强预警';
|
||||
}
|
||||
else if(warn==0x04){
|
||||
warn='非常强预警';
|
||||
}
|
||||
console.log(warn)
|
||||
console.log('解析结果:', {
|
||||
staticLevel: staticLevelText,
|
||||
lightingLevel: lightingLevelText,
|
||||
lightingTime: `${lightingTime} 分钟`,
|
||||
batteryLevel: `${batteryLevel}%`
|
||||
});
|
||||
|
||||
this.receiveData.staticLevel =staticLevelText;
|
||||
this.receiveData.lightingLevel =lightingLevelText;
|
||||
this.receiveData.lightingTime =lightingTime +'分钟';
|
||||
this.receiveData.batteryLevel =batteryLevel +'%';
|
||||
this.receiveData.warnLevel=warn;
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:',error);
|
||||
console
|
||||
.log(
|
||||
warn
|
||||
)
|
||||
console
|
||||
.log(
|
||||
'解析结果:', {
|
||||
staticLevel: staticLevelText,
|
||||
lightingLevel: lightingLevelText,
|
||||
lightingTime: `${lightingTime} 分钟`,
|
||||
batteryLevel: `${batteryLevel}%`
|
||||
});
|
||||
|
||||
this.receiveData
|
||||
.staticLevel =
|
||||
staticLevelText;
|
||||
this.receiveData
|
||||
.lightingLevel =
|
||||
lightingLevelText;
|
||||
this.receiveData
|
||||
.lightingTime =
|
||||
lightingTime +
|
||||
'分钟';
|
||||
this.receiveData
|
||||
.batteryLevel =
|
||||
batteryLevel +
|
||||
'%';
|
||||
this.receiveData
|
||||
.warnLevel =
|
||||
warn;
|
||||
} catch (
|
||||
error) {
|
||||
console
|
||||
.log(
|
||||
'数据解析错误:',
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
else{
|
||||
try{
|
||||
let uint8Array = new Uint8Array(receive.value);
|
||||
let str = '';
|
||||
for (let i = 0; i < uint8Array.length; i++) {
|
||||
} else {
|
||||
try {
|
||||
let uint8Array =
|
||||
new Uint8Array(
|
||||
receive
|
||||
.value
|
||||
);
|
||||
let str =
|
||||
'';
|
||||
for (let i =
|
||||
0; i <
|
||||
uint8Array
|
||||
.length; i++
|
||||
) {
|
||||
// 将每个字节转换为对应的字符
|
||||
str += String.fromCharCode(uint8Array[i]);
|
||||
str +=
|
||||
String
|
||||
.fromCharCode(
|
||||
uint8Array[
|
||||
i
|
||||
]
|
||||
);
|
||||
}
|
||||
if(str.indexOf('mac address:')==0){
|
||||
this.receiveData.macAddress=str.split(':')[1];
|
||||
console.log("收到mac地址:",)
|
||||
}else{
|
||||
console.log("收到无法解析的字符串:",str)
|
||||
}
|
||||
}catch(ex){
|
||||
console.log("将数据转文本失败",ex);
|
||||
if (str
|
||||
.indexOf(
|
||||
'mac address:'
|
||||
) ==
|
||||
0) {
|
||||
this.receiveData
|
||||
.macAddress =
|
||||
str
|
||||
.split(
|
||||
':'
|
||||
)[
|
||||
1
|
||||
];
|
||||
console
|
||||
.log(
|
||||
"收到mac地址:",
|
||||
)
|
||||
} else {
|
||||
console
|
||||
.log(
|
||||
"收到无法解析的字符串:",
|
||||
str
|
||||
)
|
||||
}
|
||||
} catch (ex) {
|
||||
console
|
||||
.log(
|
||||
"将数据转文本失败",
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1885,15 +2008,18 @@
|
||||
.txt {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
.w50{
|
||||
|
||||
.w50 {
|
||||
width: 50%;
|
||||
color: #656363;
|
||||
font-size: 26prx;
|
||||
}
|
||||
.fleft{
|
||||
|
||||
.fleft {
|
||||
float: left;
|
||||
}
|
||||
.clear{
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
</style>
|
||||
@ -60,7 +60,7 @@
|
||||
</view>
|
||||
<view>重发包序号:{{reSendNumber}}</view>
|
||||
<view class="sending-progress" v-if="isSending">
|
||||
|
||||
|
||||
<view class="progress-bar">
|
||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
||||
</view>
|
||||
@ -230,7 +230,7 @@
|
||||
request,
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
var videoChannel=null;
|
||||
var videoChannel = null;
|
||||
var mqttClient = null;
|
||||
export default {
|
||||
data() {
|
||||
@ -303,7 +303,7 @@
|
||||
videoHeight: "",
|
||||
videoDuration: "",
|
||||
currentSOS: "",
|
||||
reSendNumber:null
|
||||
reSendNumber: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -678,51 +678,47 @@
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
let json=JSON.parse(str);
|
||||
if("staBlue_picture" in json){
|
||||
let json = JSON.parse(str);
|
||||
if ("staBlue_picture" in json) {
|
||||
//重发图片
|
||||
console.log("收到重新发送图片的命令");
|
||||
this.reSendNumber=json.staBlue_picture;
|
||||
setTimeout(()=>{
|
||||
this.sendImagePackets(this.rgb565Data,json.staBlue_picture);
|
||||
},0);
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
else if("staBlue_text" in json){
|
||||
this.reSendNumber = json.staBlue_picture;
|
||||
setTimeout(() => {
|
||||
this.sendImagePackets(this.rgb565Data, json.staBlue_picture);
|
||||
}, 0);
|
||||
|
||||
|
||||
return;
|
||||
} else if ("staBlue_text" in json) {
|
||||
//重发文本
|
||||
console.log("收到重新发送文本的命令");
|
||||
this.reSendNumber=json.staBlue_text;
|
||||
setTimeout(()=>{
|
||||
this.sendText(null,json.staBlue_text);
|
||||
},0)
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
else if("staBlue_vidio" in json){
|
||||
this.reSendNumber = json.staBlue_text;
|
||||
setTimeout(() => {
|
||||
this.sendText(null, json.staBlue_text);
|
||||
}, 0)
|
||||
|
||||
|
||||
return;
|
||||
} else if ("staBlue_vidio" in json) {
|
||||
//重发视频
|
||||
console.log("收到重新发送视频的命令");
|
||||
|
||||
|
||||
videoChannel.emit("ReSendVideo", {
|
||||
videoNo:json.staBlue_vidio
|
||||
videoNo: json.staBlue_vidio
|
||||
});
|
||||
|
||||
return ;
|
||||
}
|
||||
else if("staBlue" in json){
|
||||
if(json.staBlue=="finish"){
|
||||
|
||||
return;
|
||||
} else if ("staBlue" in json) {
|
||||
if (json.staBlue == "finish") {
|
||||
console.log("收到设备回复,全部传输完成");
|
||||
}
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
return;
|
||||
} else {
|
||||
console.log("无法解析该文本");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log("文本解析失败")
|
||||
}
|
||||
@ -1471,11 +1467,10 @@
|
||||
events: {
|
||||
ImgCutOver: function(data) {
|
||||
console.log("111111");
|
||||
console.log("data=", data.length);
|
||||
console.log("data=", data);
|
||||
these.rgb565Data = these.convertToRGB565(
|
||||
data);
|
||||
console.log("rgb565=", these.rgb565Data
|
||||
.length);
|
||||
data.piexls);
|
||||
console.log("rgb565=", these.rgb565Data);
|
||||
},
|
||||
ImgCutOver_Path: function(data) {
|
||||
these.tempImagePath = data;
|
||||
@ -1627,7 +1622,7 @@
|
||||
this.currentPacket = ReSendNo;
|
||||
this.currentPacket = ReSendNo;
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket=ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
// 发送单个数据包
|
||||
let sendNextPacket = () => {
|
||||
@ -1635,9 +1630,9 @@
|
||||
this.isSending = false;
|
||||
if (!ReSendNo) {
|
||||
this.bleSendComplete();
|
||||
}else{
|
||||
// this.reSendNumber="";
|
||||
}
|
||||
} else {
|
||||
// this.reSendNumber="";
|
||||
}
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
@ -1742,11 +1737,11 @@
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
if(ReSendNo){
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket();
|
||||
}else{
|
||||
HoldYouHand();
|
||||
} else {
|
||||
HoldYouHand();
|
||||
}
|
||||
|
||||
});
|
||||
@ -1877,7 +1872,7 @@
|
||||
console.log('文字发送完成');
|
||||
if (!ReSendNo) {
|
||||
this.bleSendComplete();
|
||||
}else{
|
||||
} else {
|
||||
// this.reSendNumber="";
|
||||
}
|
||||
|
||||
@ -2002,10 +1997,9 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
if(!ReSendNo){
|
||||
HoldYouHand();
|
||||
}
|
||||
else{
|
||||
if (!ReSendNo) {
|
||||
HoldYouHand();
|
||||
} else {
|
||||
sendNextPacket();
|
||||
}
|
||||
|
||||
@ -2017,14 +2011,14 @@
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.sendData(buffer).then(() => {
|
||||
console.log("完成指令发送成功");
|
||||
}).catch(err => {
|
||||
console.log("完成指令发送失败");
|
||||
});
|
||||
},500)
|
||||
|
||||
}, 500)
|
||||
|
||||
},
|
||||
// 将文字转换为GBK编码(使用第三方库或API)
|
||||
convertToGBK(text) {
|
||||
@ -2074,7 +2068,7 @@
|
||||
url: "/pages/BlueTooth/ModeSetting/VideoSend_670",
|
||||
success: (res) => {
|
||||
let channel = res.eventChannel;
|
||||
videoChannel=channel;
|
||||
videoChannel = channel;
|
||||
channel.emit("receiveDevice", {
|
||||
connectedDeviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
@ -2085,7 +2079,7 @@
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("出现异常,",ex);
|
||||
console.log("出现异常,", ex);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<canvas canvas-id="flashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
||||
|
||||
<f-video ref="compARef" :src="videoPath" :direction="-90" :autoplay="true" @shotVideoClick="shotVideoClick"
|
||||
:videoWidth="videoWidth" :videoHeight="videoHeight"></f-video>
|
||||
|
||||
|
||||
|
||||
|
||||
<view>
|
||||
重发包序号:{{reSendNumber}}
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>发送间隔</text>
|
||||
@ -13,7 +13,7 @@
|
||||
</view>
|
||||
<view>
|
||||
<button @click="checkVideo">选择视频</button>
|
||||
<!-- <button @click="CutImg">发送</button> -->
|
||||
|
||||
<button @click="uploadVideo">发送</button>
|
||||
</view>
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/utils/Common';
|
||||
<script>
|
||||
import Common from '@/utils/Common';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -51,7 +51,7 @@ import Common from '@/utils/Common';
|
||||
videoWidth: 320,
|
||||
videoHeight: 160,
|
||||
videoDuration: 2,
|
||||
|
||||
reSendNumber:null,
|
||||
hexArray: []
|
||||
|
||||
}
|
||||
@ -64,7 +64,17 @@ import Common from '@/utils/Common';
|
||||
this.serviceId = data.serviceId;
|
||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
||||
})
|
||||
});
|
||||
|
||||
eventChannel.on('ReSendVideo', (data) => {
|
||||
//重新发送某一包
|
||||
this.reSendNumber = data.videoNo;
|
||||
setTimeout(() => {
|
||||
this.shotVideoClick(this.hexArray, 'rgb565', data.videoNo);
|
||||
}, 0);
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
checkVideo: function() {
|
||||
@ -76,9 +86,12 @@ import Common from '@/utils/Common';
|
||||
success: (res) => {
|
||||
this.videoPath = res.tempFilePath;
|
||||
|
||||
|
||||
|
||||
|
||||
this.imgs = [];
|
||||
this.hexArray = [];
|
||||
this.$refs.compARef.base64 = [];
|
||||
|
||||
this.videoWidth = res.width;
|
||||
this.videoHeight = res.height;
|
||||
this.videoDuration = res.duration;
|
||||
@ -95,24 +108,24 @@ import Common from '@/utils/Common';
|
||||
return;
|
||||
|
||||
}
|
||||
if(!this.videoPath){
|
||||
if (!this.videoPath) {
|
||||
uni.showToast({
|
||||
title: "请选择视频",
|
||||
icon: 'fail'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log("正在上传视频");
|
||||
uni.showLoading({
|
||||
title: "上传中"
|
||||
});
|
||||
|
||||
let p2=new Promise((resolve,reject)=>{
|
||||
|
||||
let p2 = new Promise((resolve, reject) => {
|
||||
let start = new Date();
|
||||
console.log("Common.baseURL="+Common.baseURL);
|
||||
console.log("Common.baseURL=" + Common.baseURL);
|
||||
uni.uploadFile({
|
||||
url:Common.baseURL+'video/upload',
|
||||
url: Common.baseURL + 'video/upload',
|
||||
filePath: this.videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
@ -138,28 +151,28 @@ import Common from '@/utils/Common';
|
||||
uni.hideLoading();
|
||||
resolve(res);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
let p1=this.HoldYouHand();
|
||||
|
||||
Promise.all([p2,p1]).then((arr)=>{
|
||||
|
||||
if(arr[1]===true){
|
||||
let res=arr[0];
|
||||
|
||||
let p1 = this.HoldYouHand();
|
||||
|
||||
Promise.all([p2, p1]).then((arr) => {
|
||||
|
||||
if (arr[1] === true) {
|
||||
let res = arr[0];
|
||||
res = JSON.parse(res.data);
|
||||
|
||||
|
||||
if (res.data) {
|
||||
this.hexArray = res.data;
|
||||
uni.showLoading({
|
||||
title: "正在发送"
|
||||
});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
this.shotVideoClick(res.data, 'rgb565');
|
||||
}, 0)
|
||||
|
||||
|
||||
} else {
|
||||
console.log("res")
|
||||
uni.showModal({
|
||||
@ -167,24 +180,39 @@ import Common from '@/utils/Common';
|
||||
title: '错误'
|
||||
})
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
uni.showModal({
|
||||
content:"与设备握手失败了",
|
||||
title:"错误"
|
||||
content: "与设备握手失败了",
|
||||
title: "错误"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
shotVideoClick: function(array, type) {
|
||||
bleSendComplete() {
|
||||
var str = "transmit complete"; //握手的协议字符串
|
||||
let buffer = new ArrayBuffer(str.length);
|
||||
let dataView = new DataView(buffer);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.sendData(buffer).then(() => {
|
||||
console.log("完成指令发送成功");
|
||||
}).catch(err => {
|
||||
console.log("完成指令发送失败");
|
||||
});
|
||||
}, 3000)
|
||||
|
||||
},
|
||||
shotVideoClick: function(array, type, ReSendNo) {
|
||||
//console.log("处理视频完成", array);
|
||||
//console.log("type=" + type)
|
||||
//console.log("array=", array);
|
||||
this.imgs = array;
|
||||
|
||||
|
||||
|
||||
|
||||
var sendImagePackets = (imageData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -197,12 +225,25 @@ import Common from '@/utils/Common';
|
||||
const totalPackets = 1536;
|
||||
this.totalPackets = totalPackets;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
console.log("11111");
|
||||
this.progress = ReSendNo - 1;
|
||||
this.currentPacket = ReSendNo - 1;
|
||||
console.log("22222");
|
||||
|
||||
this.totalPackets = ReSendNo;
|
||||
console.log("11111=",ReSendNo);
|
||||
}
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
||||
console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
||||
if (currentPacket > totalPackets) {
|
||||
this.isSending = false;
|
||||
if (!ReSendNo) {
|
||||
this.bleSendComplete();
|
||||
} else {
|
||||
// this.reSendNumber="";
|
||||
}
|
||||
resolve();
|
||||
|
||||
return;
|
||||
@ -221,11 +262,11 @@ import Common from '@/utils/Common';
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
console.log("111111");
|
||||
const packetData = imageData.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 506; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
@ -256,11 +297,16 @@ import Common from '@/utils/Common';
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
this.sendData(buffer).then(() => {
|
||||
if(ReSendNo){
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
// 更新进度
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) *
|
||||
100);
|
||||
//console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
||||
console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
||||
|
||||
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
|
||||
currentPacket++;
|
||||
@ -277,8 +323,8 @@ import Common from '@/utils/Common';
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sendNextPacket();
|
||||
|
||||
@ -294,12 +340,13 @@ import Common from '@/utils/Common';
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff-s) / 60;
|
||||
let m = (diff - s) / 60;
|
||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.showToast({
|
||||
title: "发送完成,耗时:" + m + "分" + s + "秒",
|
||||
icon: 'success'
|
||||
})
|
||||
uni.showModal({
|
||||
content:"发送完成,耗时:" + m + "分" + s + "秒",
|
||||
title:"提示"
|
||||
});
|
||||
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
@ -312,17 +359,17 @@ import Common from '@/utils/Common';
|
||||
|
||||
},
|
||||
HoldYouHand() {
|
||||
|
||||
var promise=new Promise((resolve,reject)=>{
|
||||
try{
|
||||
let start=new Date();
|
||||
|
||||
var promise = new Promise((resolve, reject) => {
|
||||
try {
|
||||
let start = new Date();
|
||||
var str = "video transmit start"; //握手的协议字符串
|
||||
console.log("开始握手:"+str)
|
||||
|
||||
console.log("开始握手:" + str)
|
||||
|
||||
// 1. 创建 ArrayBuffer 和 DataView
|
||||
const buffer = new ArrayBuffer(str.length);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
@ -330,31 +377,31 @@ import Common from '@/utils/Common';
|
||||
//console.log("111111");
|
||||
this.sendData(buffer).then(() => {
|
||||
// 开始发送第一个包
|
||||
setTimeout(()=>{
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
|
||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
||||
|
||||
resolve(true);
|
||||
|
||||
console.log("握手成功并完成2200ms等待,耗时" + m + "分" + s + "秒");
|
||||
|
||||
resolve(true);
|
||||
}, 2200);
|
||||
|
||||
|
||||
}).catch(err => {
|
||||
//console.log("握手没有成功");
|
||||
reject(err);
|
||||
});
|
||||
}catch(ex){
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return promise;
|
||||
|
||||
|
||||
},
|
||||
sendData(buffer) {
|
||||
////console.log("deviceId=" + this.connectedDeviceId);
|
||||
@ -415,18 +462,8 @@ import Common from '@/utils/Common';
|
||||
promise.then(resolve).catch(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
CutImg: function() {
|
||||
if (this.imgs.length == 30) {
|
||||
this.shotVideoClick(this.imgs, 'img');
|
||||
return;
|
||||
}
|
||||
//console.log("开始处理视频")
|
||||
uni.showLoading({
|
||||
title: '开始处理'
|
||||
});
|
||||
this.$refs.compARef.shotVideoClick(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -469,4 +506,19 @@ import Common from '@/utils/Common';
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.splash-frame {
|
||||
height: 320rpx;
|
||||
width: 640rpx;
|
||||
border: 2rpx solid #409eff;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
.splash-frame image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<canvas canvas-id="flashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
||||
|
||||
|
||||
<view>
|
||||
<view>
|
||||
选择的视频:{{videoPath}}</view>
|
||||
@ -287,6 +285,11 @@ var mqttClient=null;
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
this.sendData(buffer).then(() => {
|
||||
if(ReSendNo){
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
// 更新进度
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) *
|
||||
@ -401,7 +404,7 @@ var mqttClient=null;
|
||||
}).catch(err => {
|
||||
console.log("完成指令发送失败");
|
||||
});
|
||||
},1500)
|
||||
},3000)
|
||||
|
||||
},
|
||||
sendData(buffer) {
|
||||
|
||||
@ -19,10 +19,10 @@
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY650',
|
||||
url: 'HBY650'
|
||||
},
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY650_1',
|
||||
url: 'HBY650_V1'
|
||||
},
|
||||
// {
|
||||
// name: '/pages/BlueTooth/ModeSetting/HBY650_1',
|
||||
// url: 'HBY650_V1'
|
||||
// },
|
||||
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY6155',
|
||||
@ -36,7 +36,10 @@
|
||||
name: "/pages/BlueTooth/ModeSetting/HBY670V1",
|
||||
url: 'HBY670'
|
||||
},
|
||||
|
||||
{
|
||||
name: "/pages/BlueTooth/ModeSetting/4877",
|
||||
url: '4877'
|
||||
},
|
||||
{
|
||||
name: '/pages/MapTest/MapTest',
|
||||
url: '地图测试'
|
||||
|
||||
BIN
static/fonts/PingFangBold.ttf
Normal file
BIN
static/fonts/PingFangBold.ttf
Normal file
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
|
||||
var isReady=false;var onReadyCallbacks=[];
|
||||
var isServiceReady=false;var onServiceReadyCallbacks=[];
|
||||
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"],"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.66","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":"发送信息"}},{"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":"报警"}},{"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":"呼叫"}}];
|
||||
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":""}}];
|
||||
__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}}}});
|
||||
|
||||
16249
unpackage/dist/dev/app-plus/app-service.js
vendored
16249
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
18850
unpackage/dist/dev/app-plus/app-view.js
vendored
18850
unpackage/dist/dev/app-plus/app-view.js
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/manifest.json
vendored
2
unpackage/dist/dev/app-plus/manifest.json
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/view.css
vendored
2
unpackage/dist/dev/app-plus/view.css
vendored
File diff suppressed because one or more lines are too long
4
unpackage/dist/dev/app-plus/view.umd.min.js
vendored
4
unpackage/dist/dev/app-plus/view.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -437,7 +437,7 @@ class BleHelper {
|
||||
|
||||
uni.onBLECharacteristicValueChange((receive) => {
|
||||
//订阅消息
|
||||
// console.log("收到订阅消息",receive);
|
||||
console.log("收到订阅消息",receive);
|
||||
let f=this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == receive.deviceId;
|
||||
})
|
||||
@ -458,6 +458,7 @@ class BleHelper {
|
||||
// 将每个字节转换为对应的字符
|
||||
str += String.fromCharCode(uint8Array[i]);
|
||||
}
|
||||
|
||||
let header = "mac address:";
|
||||
if (str.indexOf(header) == 0) { //650以文本传输mac
|
||||
|
||||
@ -466,7 +467,7 @@ class BleHelper {
|
||||
.deviceId) {
|
||||
v.macAddress = str.replace(
|
||||
header, "");
|
||||
// console.log("收到mac地址:", str)
|
||||
console.log("收到mac地址:", str)
|
||||
}
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey, this.data
|
||||
@ -474,8 +475,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);
|
||||
let mac = hexs.slice(1, 7).join(":")
|
||||
.toUpperCase();
|
||||
this.data.LinkedList.find((v) => {
|
||||
@ -489,8 +491,9 @@ class BleHelper {
|
||||
.data.LinkedList);
|
||||
}
|
||||
}
|
||||
console.log("str=",str);
|
||||
} catch (ex) {
|
||||
////console.log("将数据转文本失败", ex);
|
||||
console.log("将数据转文本失败", ex);
|
||||
}
|
||||
let recData = {
|
||||
deviceId: receive.deviceId,
|
||||
@ -500,7 +503,7 @@ 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) {
|
||||
@ -586,7 +589,7 @@ class BleHelper {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
services: [],
|
||||
allowDuplicatesKey: true,
|
||||
allowDuplicatesKey: false,
|
||||
success: (res) => {
|
||||
//console.log('开始搜索蓝牙设备成功');
|
||||
resolve(res);
|
||||
@ -667,7 +670,7 @@ class BleHelper {
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log("c=", c);
|
||||
// console.log("c=", c);
|
||||
let startSubScribe = (id, serviceId, characteristicId) => {
|
||||
|
||||
return new Promise((succ, err) => {
|
||||
@ -950,7 +953,7 @@ class BleHelper {
|
||||
console.log("正在连接" + deviceId);
|
||||
uni.createBLEConnection({
|
||||
deviceId: deviceId,
|
||||
timeout: 3000,
|
||||
timeout: 30000,
|
||||
success: (info) => {
|
||||
|
||||
console.log("新连接成功", this.data.LinkedList);
|
||||
@ -973,22 +976,27 @@ class BleHelper {
|
||||
.LinkedList);
|
||||
|
||||
let os = plus.os.name;
|
||||
if (os == 'android') {
|
||||
console.log("os=",os);
|
||||
if (os == 'Android') {
|
||||
uni.setBLEMTU({
|
||||
deviceId: deviceId,
|
||||
mtu: 512,
|
||||
success: (mtu) => {
|
||||
|
||||
////console.log("mtu设置成功");
|
||||
|
||||
console.log("mtu设置成功",mtu);
|
||||
resolve(true);
|
||||
},
|
||||
fail: () => {
|
||||
////console.log("mtu设置失败")
|
||||
console.log("mtu设置失败")
|
||||
resolve(true);
|
||||
},
|
||||
finally:()=>{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
resolve(true);
|
||||
|
||||
}else{
|
||||
resolve(true);
|
||||
}
|
||||
}).catch((ex) => {
|
||||
|
||||
reject(this.getError(ex));
|
||||
@ -1149,7 +1157,7 @@ class BleHelper {
|
||||
})); //没有找到指定设备
|
||||
return;
|
||||
}
|
||||
// console.log("device=", device);
|
||||
console.log("device=", device);
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: device.deviceId,
|
||||
serviceId: device.writeServiceId,
|
||||
@ -1181,7 +1189,7 @@ class BleHelper {
|
||||
}
|
||||
|
||||
Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => {
|
||||
console.log("ex=", ex);
|
||||
// console.log("ex=", ex);
|
||||
if (ex.code == -1) {
|
||||
resolve(ex);
|
||||
} else {
|
||||
@ -1244,7 +1252,7 @@ class BleHelper {
|
||||
let a = pixels[i + 3];
|
||||
|
||||
if (type == 'bgr') {
|
||||
result[index++] = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
|
||||
result[index++] = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
|
||||
} else {
|
||||
result[index++] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
const env = 'production'; //production development //开发of线上 改这里就行
|
||||
const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||
|
||||
Reference in New Issue
Block a user