蓝牙模块添加在web平台默认成功方便调试功能,4877功能完成
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
"name" : "星汉物联",
|
"name" : "星汉物联",
|
||||||
"appid" : "__UNI__A21EF43",
|
"appid" : "__UNI__A21EF43",
|
||||||
"description" : "设备管控",
|
"description" : "设备管控",
|
||||||
"versionName" : "1.0.3",
|
"versionName" : "1.0.5",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
|
|||||||
@ -2,23 +2,24 @@
|
|||||||
<view class="content contentBg">
|
<view class="content contentBg">
|
||||||
<view class="eq">
|
<view class="eq">
|
||||||
<view class="leftImg" @click.stop="previewImg(formData.img)">
|
<view class="leftImg" @click.stop="previewImg(formData.img)">
|
||||||
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" mode="aspectFit"></image>
|
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="rightTxt">
|
<view class="rightTxt">
|
||||||
<view class="row">
|
<view class="row">
|
||||||
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
|
||||||
<view class="txt">
|
<view class="txt">
|
||||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
<view class="bigTxt">{{formData.sta_battery}}%</view>
|
||||||
<view class="smallTxt">电量</view>
|
<view class="smallTxt">电量</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="row">
|
<view class="row">
|
||||||
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
|
||||||
<view class="txt">
|
<view class="txt">
|
||||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||||
<view class="smallTxt">续航时间</view>
|
<view class="smallTxt">续航时间</view>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="eqinfo">
|
<view class="eqinfo">
|
||||||
@ -36,12 +37,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
|
|
||||||
<view>设备强制报警中!</view>
|
|
||||||
<view class="netContent">
|
|
||||||
{{formData.warnTime}}s
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="lamp">
|
<view class="lamp">
|
||||||
@ -250,7 +246,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
|
pageHide: false,
|
||||||
Pop: {
|
Pop: {
|
||||||
showPop: false, //是否显示弹窗
|
showPop: false, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
@ -311,7 +307,7 @@
|
|||||||
},
|
},
|
||||||
formData: {
|
formData: {
|
||||||
img: '/static/images/4877/4877equip.png',
|
img: '/static/images/4877/4877equip.png',
|
||||||
sta_PowerPercent: '',
|
sta_battery: '',
|
||||||
xuhang: '',
|
xuhang: '',
|
||||||
blename: '',
|
blename: '',
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
@ -320,10 +316,14 @@
|
|||||||
statu: '',
|
statu: '',
|
||||||
macAddress: '',
|
macAddress: '',
|
||||||
bleStatu: false,
|
bleStatu: false,
|
||||||
sta_SOSType: '', //sos
|
sta_address: '',
|
||||||
sta_GroupType: '', //配组
|
sta_VoiceType: '',
|
||||||
sta_ArrowType: '', //箭头方向
|
sta_VoiceVolume: '',
|
||||||
warnTime:0
|
sta_LightType: '',
|
||||||
|
sta_LightFreq: '',
|
||||||
|
sta_LightDimmer: '',
|
||||||
|
sta_system: ''
|
||||||
|
|
||||||
},
|
},
|
||||||
dic: {
|
dic: {
|
||||||
SOS: [{
|
SOS: [{
|
||||||
@ -688,36 +688,58 @@
|
|||||||
return className;
|
return className;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log("收到设备的数据", receive)
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
let json = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||||
console.log("处理后的数据:", data);
|
|
||||||
if (data) {
|
|
||||||
let keys = Object.keys(data);
|
let key = 'sta_VoiceDate';
|
||||||
|
if (key in json) {
|
||||||
|
|
||||||
|
let val = json[key];
|
||||||
|
console.log("22222", val)
|
||||||
|
if (val === 'start') {
|
||||||
|
//开始发包
|
||||||
|
|
||||||
|
this.sendHex();
|
||||||
|
return;
|
||||||
|
} else if (val === 'finish') {
|
||||||
|
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: "发送完成"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
//重新发送某一包
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (val > this.audioData.packetCtn) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sendHex(val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let keys = Object.keys(json);
|
||||||
|
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
if (key in this.formData) {
|
if (key in this.formData) {
|
||||||
this.formData[key] = data[key];
|
this.formData[key] = json[key];
|
||||||
}
|
|
||||||
});
|
|
||||||
let msg = [];
|
|
||||||
if (data.sta_SOSType == 'sos') {
|
|
||||||
msg.push("设备声光报警中");
|
|
||||||
}
|
|
||||||
if (data.sta_PowerPercent <= 20) {
|
|
||||||
msg.push("设备电量低");
|
|
||||||
|
|
||||||
}
|
|
||||||
if (msg.length) {
|
|
||||||
msg = msg.join(",");
|
|
||||||
this.showMsg(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
these.setBleFormData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // 转换为字节数组
|
})
|
||||||
// const bytes = receive.bytes;
|
|
||||||
// parseData(bytes);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -754,7 +776,7 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
buttonTextColor: '#FFFFFFde',
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -826,7 +848,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
hideLoading(this);
|
||||||
let def = {
|
let def = {
|
||||||
showPop: true, //是否显示弹窗
|
showPop: true, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
<view class="content contentBg">
|
<view class="content contentBg">
|
||||||
<view class="eq">
|
<view class="eq">
|
||||||
<view class="leftImg" @click.stop="previewImg(formData.img)">
|
<view class="leftImg" @click.stop="previewImg(formData.img)">
|
||||||
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" mode="aspectFit"></image>
|
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="rightTxt">
|
<view class="rightTxt">
|
||||||
<view class="row">
|
<view class="row">
|
||||||
@ -36,7 +37,8 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
|
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'"
|
||||||
|
@click.stop="showUnWarn('sos_off')">
|
||||||
<view>设备强制报警中!</view>
|
<view>设备强制报警中!</view>
|
||||||
<view class="netContent">
|
<view class="netContent">
|
||||||
{{formData.warnTime}}s
|
{{formData.warnTime}}s
|
||||||
@ -47,7 +49,7 @@
|
|||||||
<view class="lamp">
|
<view class="lamp">
|
||||||
<view class="title">
|
<view class="title">
|
||||||
<text>SOS</text>
|
<text>SOS</text>
|
||||||
<view @click.stop="sosSetting({val:'sos_off'})">
|
<view @click.stop="sosSetting({val:'sos_off'},-1)">
|
||||||
<image class="img" src="/static/images/common/close.png" mode="aspectFit"></image>
|
<image class="img" src="/static/images/common/close.png" mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -250,7 +252,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
|
pageHide: false,
|
||||||
Pop: {
|
Pop: {
|
||||||
showPop: false, //是否显示弹窗
|
showPop: false, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
@ -398,11 +400,11 @@
|
|||||||
ble = BleTool.getBleTool();
|
ble = BleTool.getBleTool();
|
||||||
|
|
||||||
|
|
||||||
ble.addReceiveCallback(these.bleValueNotify, pagePath);
|
ble.addReceiveCallback(this.bleValueNotify, pagePath);
|
||||||
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
|
ble.addStateBreakCallback(this.bleStateBreak, pagePath);
|
||||||
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
|
ble.addStateRecoveryCallback(this.bleStateRecovry, pagePath);
|
||||||
ble.addDisposeCallback(these.deviceDispose, pagePath);
|
ble.addDisposeCallback(this.deviceDispose, pagePath);
|
||||||
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
|
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
|
||||||
|
|
||||||
|
|
||||||
let eventChannel = this.getOpenerEventChannel();
|
let eventChannel = this.getOpenerEventChannel();
|
||||||
@ -467,17 +469,16 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.formData.sta_ArrowType === val) {
|
if (this.formData.sta_ArrowType === val) {
|
||||||
this.formData.sta_ArrowType = 'arrow_off';
|
val = 'arrow_off';
|
||||||
} else {
|
|
||||||
this.formData.sta_ArrowType = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = {
|
var json = {
|
||||||
ins_ArrowType: this.formData.sta_ArrowType
|
ins_ArrowType: val
|
||||||
}
|
}
|
||||||
json = JSON.stringify(json);
|
json = JSON.stringify(json);
|
||||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
|
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||||
.catch(ex => {
|
this.formData.sta_ArrowType = val;
|
||||||
|
}).catch(ex => {
|
||||||
this.showMsg(ex.msg);
|
this.showMsg(ex.msg);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -534,6 +535,7 @@
|
|||||||
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
|
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
|
||||||
}
|
}
|
||||||
json = JSON.stringify(json);
|
json = JSON.stringify(json);
|
||||||
|
|
||||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||||
|
|
||||||
if (this.formData.sta_SOSType === item.val) {
|
if (this.formData.sta_SOSType === item.val) {
|
||||||
@ -688,6 +690,9 @@
|
|||||||
return className;
|
return className;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log("收到设备的数据", receive)
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||||
console.log("处理后的数据:", data);
|
console.log("处理后的数据:", data);
|
||||||
@ -754,7 +759,7 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
buttonTextColor: '#FFFFFFde',
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -826,7 +831,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
hideLoading(this);
|
||||||
let def = {
|
let def = {
|
||||||
showPop: true, //是否显示弹窗
|
showPop: true, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
|
|||||||
@ -516,6 +516,9 @@
|
|||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) {
|
bleValueNotify: function(receive, device, path, recArr) {
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.Status.pageHide) {
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -572,6 +575,7 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
// console.log("1111");
|
// console.log("1111");
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -1028,39 +1032,52 @@
|
|||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
|
||||||
hideLoading(this);
|
hideLoading(this);
|
||||||
let defaultCfg = {
|
let def = {
|
||||||
showHeader: false,
|
showPop: true, //是否显示弹窗
|
||||||
headerTxt: "",
|
|
||||||
showHeader: false,
|
|
||||||
showCancel: false,
|
|
||||||
borderColor: '#BBE600',
|
|
||||||
buttonBgColor: '#BBE600',
|
|
||||||
okCallback: null,
|
|
||||||
cancelCallback: null,
|
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
|
bgColor: '#383934bd',
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
textColor: '#ffffffde',
|
||||||
|
buttonBgColor: '#BBE600',
|
||||||
|
buttonTextColor: '#232323DE',
|
||||||
|
iconUrl: '',
|
||||||
|
message: '',
|
||||||
buttonText: '确定',
|
buttonText: '确定',
|
||||||
clickEvt: ''
|
clickEvt: '',
|
||||||
};
|
visiblePrompt: false,
|
||||||
if (!option) {
|
promptTitle: '',
|
||||||
|
modelValue: '',
|
||||||
|
visibleClose: false,
|
||||||
|
okCallback: null,
|
||||||
|
showSlot: false,
|
||||||
|
buttonCancelText: '',
|
||||||
|
showCancel: false,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
let keys = Object.keys(def);
|
||||||
let keys = Object.keys(option);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
|
||||||
this.Status.Pop[key] = option[key];
|
|
||||||
}
|
|
||||||
keys = Object.keys(defaultCfg);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
if (key in option) {
|
if (key in option) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.Status.Pop[key] = defaultCfg[key];
|
this.Status.Pop[key] = def[key];
|
||||||
|
}
|
||||||
|
if (option) {
|
||||||
|
keys = Object.keys(option);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
|
||||||
|
this.Status.Pop[key] = option[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Status.Pop.showPop = true;
|
if (!option.borderColor) {
|
||||||
|
option.borderColor = '#BBE600';
|
||||||
|
option.buttonBgColor = '#BBE600';
|
||||||
|
}
|
||||||
|
these.Status.Pop.showPop = true;
|
||||||
},
|
},
|
||||||
sendUsr() {
|
sendUsr() {
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
|
|||||||
@ -247,6 +247,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
|
pageHide: false,
|
||||||
showLightingSet: false,
|
showLightingSet: false,
|
||||||
showVolumeSet: false,
|
showVolumeSet: false,
|
||||||
Pop: {
|
Pop: {
|
||||||
@ -675,6 +676,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log("收到设备的数据", receive)
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath);
|
let data = recei.ReceiveData(receive, device, pagePath);
|
||||||
|
|
||||||
@ -717,13 +721,13 @@
|
|||||||
|
|
||||||
showBleUnConnect() {
|
showBleUnConnect() {
|
||||||
|
|
||||||
these.showPop({
|
this.showPop({
|
||||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
buttonTextColor: '#FFFFFFde',
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -797,6 +801,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
hideLoading(this);
|
||||||
let def = {
|
let def = {
|
||||||
showPop: true, //是否显示弹窗
|
showPop: true, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
@ -807,14 +812,16 @@
|
|||||||
buttonTextColor: '#232323DE',
|
buttonTextColor: '#232323DE',
|
||||||
iconUrl: '',
|
iconUrl: '',
|
||||||
message: '',
|
message: '',
|
||||||
buttonText: '',
|
buttonText: '确定',
|
||||||
clickEvt: '',
|
clickEvt: '',
|
||||||
visiblePrompt: false,
|
visiblePrompt: false,
|
||||||
promptTitle: '',
|
promptTitle: '',
|
||||||
modelValue: '',
|
modelValue: '',
|
||||||
visibleClose: false,
|
visibleClose: false,
|
||||||
okCallback: null,
|
okCallback: null,
|
||||||
showSlot: false
|
showSlot: false,
|
||||||
|
buttonCancelText: '',
|
||||||
|
showCancel: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys = Object.keys(def);
|
let keys = Object.keys(def);
|
||||||
@ -824,14 +831,14 @@
|
|||||||
if (key in option) {
|
if (key in option) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
these.Status.Pop[key] = def[key];
|
this.Status.Pop[key] = def[key];
|
||||||
}
|
}
|
||||||
if (option) {
|
if (option) {
|
||||||
keys = Object.keys(option);
|
keys = Object.keys(option);
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
|
|
||||||
these.Status.Pop[key] = option[key];
|
this.Status.Pop[key] = option[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -192,7 +192,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
|
pageHide: false,
|
||||||
Pop: {
|
Pop: {
|
||||||
showPop: false, //是否显示弹窗
|
showPop: false, //是否显示弹窗
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
@ -491,6 +491,9 @@
|
|||||||
return className;
|
return className;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log("收到设备的数据", receive)
|
console.log("收到设备的数据", receive)
|
||||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||||
|
|
||||||
@ -684,7 +687,7 @@ console.log("res=",res);
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
buttonTextColor: '#FFFFFFde',
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -1261,17 +1264,47 @@ console.log("res=",res);
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
hideLoading(this);
|
||||||
|
let def = {
|
||||||
|
showPop: true, //是否显示弹窗
|
||||||
|
popType: 'custom',
|
||||||
|
bgColor: '#383934bd',
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
textColor: '#ffffffde',
|
||||||
|
buttonBgColor: '#BBE600',
|
||||||
|
buttonTextColor: '#232323DE',
|
||||||
|
iconUrl: '',
|
||||||
|
message: '',
|
||||||
|
buttonText: '确定',
|
||||||
|
clickEvt: '',
|
||||||
|
visiblePrompt: false,
|
||||||
|
promptTitle: '',
|
||||||
|
modelValue: '',
|
||||||
|
visibleClose: false,
|
||||||
|
okCallback: null,
|
||||||
|
showSlot: false,
|
||||||
|
buttonCancelText: '',
|
||||||
|
showCancel: false,
|
||||||
|
}
|
||||||
|
|
||||||
if (!option) {
|
let keys = Object.keys(def);
|
||||||
option = {
|
|
||||||
a: 1
|
for (let i = 0; i < keys.length; i++) {
|
||||||
};
|
|
||||||
}
|
|
||||||
let keys = Object.keys(option);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
these.Status.Pop[key] = option[key];
|
if (key in option) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
this.Status.Pop[key] = def[key];
|
||||||
|
}
|
||||||
|
if (option) {
|
||||||
|
keys = Object.keys(option);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
|
||||||
|
this.Status.Pop[key] = option[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!option.borderColor) {
|
if (!option.borderColor) {
|
||||||
option.borderColor = '#BBE600';
|
option.borderColor = '#BBE600';
|
||||||
option.buttonBgColor = '#BBE600';
|
option.buttonBgColor = '#BBE600';
|
||||||
|
|||||||
@ -633,6 +633,7 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
|
buttonTextColor: '#232323de',
|
||||||
showCancel: true,
|
showCancel: true,
|
||||||
cancelCallback: () => {
|
cancelCallback: () => {
|
||||||
// this.closePop();
|
// this.closePop();
|
||||||
@ -984,7 +985,9 @@
|
|||||||
return receiveData;
|
return receiveData;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
let data = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||||
console.log("收到设备的数据", data)
|
console.log("收到设备的数据", data)
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -1433,7 +1436,8 @@
|
|||||||
this.Status.staticWarn.time = 0;
|
this.Status.staticWarn.time = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (these.formData.qzwarn && these.Status.staticWarn.inteval && these.Status.staticWarn.time) {
|
if (these.formData.qzwarn && these.Status.staticWarn.inteval && these.Status.staticWarn
|
||||||
|
.time) {
|
||||||
console.log("222222");
|
console.log("222222");
|
||||||
this.Status.Pop.okCallback = null;
|
this.Status.Pop.okCallback = null;
|
||||||
these.showQzWarn(sendRb);
|
these.showQzWarn(sendRb);
|
||||||
@ -2170,39 +2174,51 @@
|
|||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
hideLoading(this);
|
hideLoading(this);
|
||||||
let defaultCfg = {
|
let def = {
|
||||||
showHeader: false,
|
showPop: true, //是否显示弹窗
|
||||||
headerTxt: "",
|
|
||||||
showHeader: false,
|
|
||||||
showCancel: false,
|
|
||||||
borderColor: '#BBE600',
|
|
||||||
buttonBgColor: '#BBE600',
|
|
||||||
okCallback: null,
|
|
||||||
cancelCallback: null,
|
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
|
bgColor: '#383934bd',
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
textColor: '#ffffffde',
|
||||||
|
buttonBgColor: '#BBE600',
|
||||||
|
buttonTextColor: '#232323DE',
|
||||||
|
iconUrl: '',
|
||||||
|
message: '',
|
||||||
buttonText: '确定',
|
buttonText: '确定',
|
||||||
|
clickEvt: '',
|
||||||
|
visiblePrompt: false,
|
||||||
|
promptTitle: '',
|
||||||
|
modelValue: '',
|
||||||
|
visibleClose: false,
|
||||||
|
okCallback: null,
|
||||||
|
showSlot: false,
|
||||||
|
buttonCancelText: '',
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
buttonCancelText: '取消',
|
}
|
||||||
clickEvt: ''
|
|
||||||
};
|
|
||||||
if (!option) {
|
|
||||||
|
|
||||||
}
|
let keys = Object.keys(def);
|
||||||
let keys = Object.keys(option);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
|
||||||
this.Status.Pop[key] = option[key];
|
|
||||||
}
|
|
||||||
keys = Object.keys(defaultCfg);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
if (key in option) {
|
if (key in option) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.Status.Pop[key] = defaultCfg[key];
|
this.Status.Pop[key] = def[key];
|
||||||
|
}
|
||||||
|
if (option) {
|
||||||
|
keys = Object.keys(option);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
|
||||||
|
this.Status.Pop[key] = option[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Status.Pop.showPop = true;
|
if (!option.borderColor) {
|
||||||
|
option.borderColor = '#BBE600';
|
||||||
|
option.buttonBgColor = '#BBE600';
|
||||||
|
}
|
||||||
|
these.Status.Pop.showPop = true;
|
||||||
},
|
},
|
||||||
sendUsr: function(ReSendNo) {
|
sendUsr: function(ReSendNo) {
|
||||||
|
|
||||||
|
|||||||
@ -469,7 +469,9 @@
|
|||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path, recArr) {
|
bleValueNotify: function(receive, device, path, recArr) {
|
||||||
|
if (receive.deviceId !== this.formData.deviceId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.Status.pageHide) {
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -534,6 +536,7 @@
|
|||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText: '去连接',
|
buttonText: '去连接',
|
||||||
|
buttonTextColor: '#232323de',
|
||||||
okCallback: function() {
|
okCallback: function() {
|
||||||
console.log("1111");
|
console.log("1111");
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -992,39 +995,52 @@
|
|||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
showPop: function(option) {
|
||||||
|
|
||||||
hideLoading(this);
|
hideLoading(this);
|
||||||
let defaultCfg = {
|
let def = {
|
||||||
showHeader: false,
|
showPop: true, //是否显示弹窗
|
||||||
headerTxt: "",
|
|
||||||
showHeader: false,
|
|
||||||
showCancel: false,
|
|
||||||
borderColor: '#BBE600',
|
|
||||||
buttonBgColor: '#BBE600',
|
|
||||||
okCallback: null,
|
|
||||||
cancelCallback: null,
|
|
||||||
popType: 'custom',
|
popType: 'custom',
|
||||||
|
bgColor: '#383934bd',
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
textColor: '#ffffffde',
|
||||||
|
buttonBgColor: '#BBE600',
|
||||||
|
buttonTextColor: '#232323DE',
|
||||||
|
iconUrl: '',
|
||||||
|
message: '',
|
||||||
buttonText: '确定',
|
buttonText: '确定',
|
||||||
clickEvt: ''
|
clickEvt: '',
|
||||||
};
|
visiblePrompt: false,
|
||||||
if (!option) {
|
promptTitle: '',
|
||||||
|
modelValue: '',
|
||||||
|
visibleClose: false,
|
||||||
|
okCallback: null,
|
||||||
|
showSlot: false,
|
||||||
|
buttonCancelText: '',
|
||||||
|
showCancel: false,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
let keys = Object.keys(def);
|
||||||
let keys = Object.keys(option);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
|
||||||
this.Status.Pop[key] = option[key];
|
|
||||||
}
|
|
||||||
keys = Object.keys(defaultCfg);
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
if (key in option) {
|
if (key in option) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.Status.Pop[key] = defaultCfg[key];
|
this.Status.Pop[key] = def[key];
|
||||||
|
}
|
||||||
|
if (option) {
|
||||||
|
keys = Object.keys(option);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
|
||||||
|
this.Status.Pop[key] = option[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Status.Pop.showPop = true;
|
if (!option.borderColor) {
|
||||||
|
option.borderColor = '#BBE600';
|
||||||
|
option.buttonBgColor = '#BBE600';
|
||||||
|
}
|
||||||
|
these.Status.Pop.showPop = true;
|
||||||
},
|
},
|
||||||
sendUsr() {
|
sendUsr() {
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
|
|||||||
@ -156,14 +156,39 @@
|
|||||||
if (these.device.deviceId == receive.deviceId) {
|
if (these.device.deviceId == receive.deviceId) {
|
||||||
console.log("11111:", receive);
|
console.log("11111:", receive);
|
||||||
these.device.imei = f.imei;
|
these.device.imei = f.imei;
|
||||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
let flag=false;
|
||||||
|
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) {//6155 7305
|
||||||
if (f && f.macAddress) {
|
if (f && f.macAddress) {
|
||||||
|
flag=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(receive.str.indexOf('mac address:') == 0){//650 670
|
||||||
|
if (f && f.macAddress) {
|
||||||
|
flag=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
try{
|
||||||
|
let json=JSON.parse(receive.str);
|
||||||
|
let key = "sta_address";
|
||||||
|
if (key in json) {//100
|
||||||
|
if (f && f.macAddress) {
|
||||||
|
flag=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(err){
|
||||||
|
console.log("出现异常,",err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(flag){
|
||||||
these.device.macAddress = f.macAddress;
|
these.device.macAddress = f.macAddress;
|
||||||
console.log("222222");
|
console.log("222222");
|
||||||
these.Statu.isSearch = false;
|
these.Statu.isSearch = false;
|
||||||
these.initDevice();
|
these.initDevice();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, pagePath);
|
}, pagePath);
|
||||||
eventChannel = this.getOpenerEventChannel();
|
eventChannel = this.getOpenerEventChannel();
|
||||||
|
|||||||
@ -27,7 +27,8 @@
|
|||||||
|
|
||||||
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||||
<view class="leftImg ">
|
<view class="leftImg ">
|
||||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
|
||||||
|
mode="heightFix">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="centertxt ">
|
<view class="centertxt ">
|
||||||
@ -172,40 +173,47 @@
|
|||||||
let search = option.search;
|
let search = option.search;
|
||||||
these = this;
|
these = this;
|
||||||
eventChannel = this.getOpenerEventChannel();
|
eventChannel = this.getOpenerEventChannel();
|
||||||
// this.EquipMents = [{
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
// "RSSI": -55,
|
if (systemInfo.uniPlatform == 'web') {
|
||||||
// "advertisData": "",
|
|
||||||
// "advertisServiceUUIDs": [
|
|
||||||
// "0000FFE0-0000-1000-8000-00805F9B34FB"
|
|
||||||
// ],
|
|
||||||
// "deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
|
|
||||||
// "name": "HBY670-BF74EA",
|
|
||||||
// "linkStatu": false
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "RSSI": -61,
|
|
||||||
// "advertisData": "",
|
|
||||||
// "advertisServiceUUIDs": [
|
|
||||||
// "0000FFE0-0000-1000-8000-00805F9B34FB"
|
|
||||||
// ],
|
|
||||||
// "deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
|
|
||||||
// "name": "EF4651",
|
|
||||||
// "linkStatu": false,
|
|
||||||
// "isTarget": true
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "RSSI": -69,
|
|
||||||
// "advertisData": "",
|
|
||||||
// "advertisServiceUUIDs": [
|
|
||||||
// "0000FFE0-0000-1000-8000-00805F9B34FB"
|
|
||||||
// ],
|
|
||||||
// "deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
|
|
||||||
// "name": "4877-BF743D",
|
|
||||||
// "linkStatu": false
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
|
|
||||||
|
|
||||||
|
this.EquipMents = [{
|
||||||
|
"RSSI": -55,
|
||||||
|
"advertisData": "",
|
||||||
|
"advertisServiceUUIDs": [
|
||||||
|
"0000FFE0-0000-1000-8000-00805F9B34FB"
|
||||||
|
],
|
||||||
|
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
|
||||||
|
"name": "HBY670-BF74EA",
|
||||||
|
"linkStatu": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"RSSI": -61,
|
||||||
|
"advertisData": "",
|
||||||
|
"advertisServiceUUIDs": [
|
||||||
|
"0000FFE0-0000-1000-8000-00805F9B34FB"
|
||||||
|
],
|
||||||
|
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
|
||||||
|
"name": "EF4651",
|
||||||
|
"linkStatu": false,
|
||||||
|
"isTarget": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"RSSI": -69,
|
||||||
|
"advertisData": "",
|
||||||
|
"advertisServiceUUIDs": [
|
||||||
|
"0000FFE0-0000-1000-8000-00805F9B34FB"
|
||||||
|
],
|
||||||
|
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
|
||||||
|
"name": "4877-BF743D",
|
||||||
|
"linkStatu": false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
these.PairEquip = [this.EquipMents[0]];
|
||||||
|
return;
|
||||||
|
}
|
||||||
let StartSubsrib = () => {
|
let StartSubsrib = () => {
|
||||||
these.EquipMents = [];
|
these.EquipMents = [];
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
@ -941,4 +949,9 @@
|
|||||||
color: #232323;
|
color: #232323;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filterNone {
|
||||||
|
filter: none !important;
|
||||||
|
-webkit-filter: none !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -42,6 +42,9 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.OpenBlue().then(() => {
|
this.OpenBlue().then(() => {
|
||||||
@ -55,8 +58,8 @@ class BleHelper {
|
|||||||
discovering: false, //蓝牙是否正在搜索
|
discovering: false, //蓝牙是否正在搜索
|
||||||
searchList: [], //已搜索到的设备列表,
|
searchList: [], //已搜索到的设备列表,
|
||||||
isSubscribe: false, //是否开启了订阅
|
isSubscribe: false, //是否开启了订阅
|
||||||
LinkedList: linkedDevices //已连接的设备列表
|
LinkedList: linkedDevices, //已连接的设备列表
|
||||||
|
platform: systemInfo.uniPlatform
|
||||||
}
|
}
|
||||||
this.cfg = {
|
this.cfg = {
|
||||||
onDeviceFound: [], //发现新设备的事件
|
onDeviceFound: [], //发现新设备的事件
|
||||||
@ -169,7 +172,9 @@ class BleHelper {
|
|||||||
//连接所有已连接过的设备
|
//连接所有已连接过的设备
|
||||||
linkAllDevices() {
|
linkAllDevices() {
|
||||||
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
||||||
|
if(this.data.platform=='web'){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
||||||
let flag = false;
|
let flag = false;
|
||||||
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||||
@ -424,7 +429,12 @@ class BleHelper {
|
|||||||
|
|
||||||
//获取蓝牙适配器状态
|
//获取蓝牙适配器状态
|
||||||
CheckBlue() {
|
CheckBlue() {
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
return Promise.resolve({
|
||||||
|
available: true,
|
||||||
|
discovering: false
|
||||||
|
});
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.data.available) {
|
if (this.data.available) {
|
||||||
// console.log("蓝牙模块是可用状态");
|
// console.log("蓝牙模块是可用状态");
|
||||||
@ -463,6 +473,12 @@ class BleHelper {
|
|||||||
//打开蓝牙适配器
|
//打开蓝牙适配器
|
||||||
OpenBlue() {
|
OpenBlue() {
|
||||||
|
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
this.data.isOpenBlue = true;
|
||||||
|
this.data.available = true;
|
||||||
|
this.data.isSubscribe = true;
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
var init = () => {
|
var init = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.data.isOpenBlue) {
|
if (this.data.isOpenBlue) {
|
||||||
@ -678,6 +694,7 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let header = "mac address:";
|
let header = "mac address:";
|
||||||
|
let isUpdate = false;
|
||||||
if (str.indexOf(header) == 0) { //650以文本传输mac
|
if (str.indexOf(header) == 0) { //650以文本传输mac
|
||||||
console.log("str=", str);
|
console.log("str=", str);
|
||||||
this.data.LinkedList.find((v) => {
|
this.data.LinkedList.find((v) => {
|
||||||
@ -698,10 +715,11 @@ class BleHelper {
|
|||||||
.macAddress)
|
.macAddress)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateCache();
|
isUpdate = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str.indexOf('imei:') == 0) {
|
if (str.indexOf('imei:') == 0) { //670以此方式传输imei
|
||||||
let imei = str.split(':')[1];
|
let imei = str.split(':')[1];
|
||||||
|
|
||||||
|
|
||||||
@ -709,9 +727,10 @@ class BleHelper {
|
|||||||
if (v.deviceId == receive
|
if (v.deviceId == receive
|
||||||
.deviceId) {
|
.deviceId) {
|
||||||
v.imei = imei;
|
v.imei = imei;
|
||||||
|
isUpdate = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateCache();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,12 +744,43 @@ class BleHelper {
|
|||||||
if (v.deviceId == receive
|
if (v.deviceId == receive
|
||||||
.deviceId) {
|
.deviceId) {
|
||||||
v.macAddress = mac;
|
v.macAddress = mac;
|
||||||
// console.log("收到mac地址:", str)
|
isUpdate = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateCache();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let receivJson = JSON.parse(str);
|
||||||
|
let key = "sta_address"; //HBY100以此方式上传mac地址
|
||||||
|
if (key in receivJson) {
|
||||||
|
this.data.LinkedList.find((v) => {
|
||||||
|
if (v.deviceId == receive
|
||||||
|
.deviceId) {
|
||||||
|
let macStr = receivJson[
|
||||||
|
key];
|
||||||
|
if (macStr.includes(':')) {
|
||||||
|
v.macAddress = macStr;
|
||||||
|
} else {
|
||||||
|
v.macAddress = macStr
|
||||||
|
.replace(/(.{2})/g,
|
||||||
|
'$1:').slice(0,
|
||||||
|
-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
isUpdate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (convertException) {
|
||||||
|
console.error("文本无法转json", convertException)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUpdate) {
|
||||||
|
this.updateCache();
|
||||||
|
}
|
||||||
// console.log("str1=", str);
|
// console.log("str1=", str);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error("将数据转文本失败", ex);
|
console.error("将数据转文本失败", ex);
|
||||||
@ -811,6 +861,14 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
//关闭蓝牙适配器
|
//关闭蓝牙适配器
|
||||||
CloseBlue() {
|
CloseBlue() {
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
this.data.available = false;
|
||||||
|
this.data.discovering = false;
|
||||||
|
this.data.isOpenBlue = false;
|
||||||
|
this.data.searchList = [];
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.data.available = false;
|
this.data.available = false;
|
||||||
this.data.discovering = false;
|
this.data.discovering = false;
|
||||||
@ -842,6 +900,9 @@ class BleHelper {
|
|||||||
|
|
||||||
//开始搜索新设备
|
//开始搜索新设备
|
||||||
StartSearch() {
|
StartSearch() {
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
return Promise.resolve({});
|
||||||
|
}
|
||||||
this.data.searchList = [];
|
this.data.searchList = [];
|
||||||
var these = this;
|
var these = this;
|
||||||
//开始搜索
|
//开始搜索
|
||||||
@ -902,6 +963,9 @@ class BleHelper {
|
|||||||
|
|
||||||
//停止搜索
|
//停止搜索
|
||||||
StopSearch() {
|
StopSearch() {
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
let p1 = new Promise((resolve, reject) => {
|
let p1 = new Promise((resolve, reject) => {
|
||||||
uni.stopBluetoothDevicesDiscovery({
|
uni.stopBluetoothDevicesDiscovery({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -1341,7 +1405,9 @@ class BleHelper {
|
|||||||
|
|
||||||
//连接某个设备
|
//连接某个设备
|
||||||
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) {
|
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) {
|
||||||
|
if(this.data.platform=='web'){
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
if (maxRetries === undefined) {
|
if (maxRetries === undefined) {
|
||||||
maxRetries = 0; // 最大重试次数
|
maxRetries = 0; // 最大重试次数
|
||||||
}
|
}
|
||||||
@ -1519,7 +1585,8 @@ class BleHelper {
|
|||||||
_err(
|
_err(
|
||||||
ex
|
ex
|
||||||
); // MTU设置失败不影响连接成功
|
); // MTU设置失败不影响连接成功
|
||||||
},complete(){
|
},
|
||||||
|
complete() {
|
||||||
console.log("设置mtu完毕");
|
console.log("设置mtu完毕");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1528,6 +1595,9 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
//断开连接
|
//断开连接
|
||||||
disconnectDevice(deviceId) {
|
disconnectDevice(deviceId) {
|
||||||
|
if(this.data.platform=='web'){
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
var disconnect = (id) => {
|
var disconnect = (id) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.closeBLEConnection({
|
uni.closeBLEConnection({
|
||||||
@ -1631,7 +1701,9 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
//向蓝牙设备发送数据,如果没连接将自动连接后再发
|
//向蓝牙设备发送数据,如果没连接将自动连接后再发
|
||||||
sendData(deviceid, buffer, writeServiceId, wirteCharactId, ms) {
|
sendData(deviceid, buffer, writeServiceId, wirteCharactId, ms) {
|
||||||
|
if (this.data.platform == 'web') {
|
||||||
|
return Promise.resolve("h5平台默认成功");
|
||||||
|
}
|
||||||
// console.log("deviceid=" + deviceid + ",writeServiceId=" + writeServiceId + ",wirteCharactId=" +
|
// console.log("deviceid=" + deviceid + ",writeServiceId=" + writeServiceId + ",wirteCharactId=" +
|
||||||
// wirteCharactId + ",timeout=" + ms)
|
// wirteCharactId + ",timeout=" + ms)
|
||||||
if (ms === undefined) {
|
if (ms === undefined) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ class BleReceive {
|
|||||||
'/pages/650/HBY650': this.Receive_650.bind(this),
|
'/pages/650/HBY650': this.Receive_650.bind(this),
|
||||||
'/pages/670/HBY670': this.Receive_670.bind(this),
|
'/pages/670/HBY670': this.Receive_670.bind(this),
|
||||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||||
|
'/pages/100/HBY100': this.Receive_4877.bind(this)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +521,8 @@ class BleReceive {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -280,5 +280,33 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
|
},
|
||||||
|
//10进制转换为16进制字符串
|
||||||
|
decimalToHexLittleEndian(num, byteCount,revers) {
|
||||||
|
// 处理负数(如果需要支持负数,可先转为补码)
|
||||||
|
if (num < 0) {
|
||||||
|
num = 0xFFFFFFFF + num + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转为16进制,去除前缀0x,转为大写
|
||||||
|
let hex = num.toString(16).toUpperCase();
|
||||||
|
|
||||||
|
// 计算需要补充的0的数量,确保每个字节占2位
|
||||||
|
let padLength = (byteCount || Math.ceil(hex.length / 2) * 2) - hex.length;
|
||||||
|
if (padLength > 0) {
|
||||||
|
hex = '0'.repeat(padLength) + hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分割为字节数组(每2位一个字节)
|
||||||
|
const bytes = [];
|
||||||
|
for (let i = 0; i < hex.length; i += 2) {
|
||||||
|
bytes.push(hex.substr(i, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否反转字节顺序(低位在前)并拼接
|
||||||
|
if(revers){
|
||||||
|
return bytes.reverse().join('');
|
||||||
|
}
|
||||||
|
return bytes.join('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user