蓝牙开始、结束搜索添加状态判定

This commit is contained in:
liub
2025-10-30 11:10:57 +08:00
parent bd56ca997b
commit c39cbcb34d
11 changed files with 104 additions and 100 deletions

View File

@ -132,7 +132,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "",
"appid" : "wxe16dcf57e925a6b5",
"setting" : {
"urlCheck" : false
},

View File

@ -23,13 +23,14 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
@ -323,48 +324,39 @@
sta_LightFreq: '',
sta_LightDimmer: '',
sta_system: ''
},
dic: {
SOS: [{
text: '声光报警',
val: 'sos',
img: '/static/images/4877/sg.png',
activeImg: '/static/images/4877/sgActive.png'
sta_VoiceType: {
"0": '关闭',
"1": '消防',
"2": '公安',
"3": '交警',
"4": '市政',
"5": '应急',
"6": '医疗',
"7": '铁道',
"8": 'app语音',
},
{
text: '泛光照明',
val: 'fan',
img: '/static/images/4877/fan.png',
activeImg: '/static/images/4877/fanActive.png'
}
],
gropus: [{
text: '红配组',
val: 'red_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
sta_LightType: {
"0": '关闭',
"1": '红蓝闪',
"2": '红闪',
"3": '黄闪',
"4": '蓝闪',
"5": '红流水',
"6": '黄流水',
"7": '蓝流水'
},
{
text: '蓝配组',
val: 'blue_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '绿配组',
val: 'green_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '黄配组',
val: 'yellow_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
sta_system: {
"0": '关机',
"1": '仅充电',
"2": '开机未充电',
"3": '开机且充电'
}
]
},
device: {
id: "",

View File

@ -240,7 +240,7 @@
</view>
</view>
<!-- ======各个弹框类型======= -->
<CustomPopup :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm"
<CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" />
</view>
</view>

View File

@ -24,12 +24,12 @@
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
<text class="lbl">设备名称</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
@ -37,7 +37,7 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'"
<view class="warnnig" :class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view>
<view class="netContent">

View File

@ -22,18 +22,19 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">充电状态</text>
<text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -22,15 +22,15 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -24,11 +24,11 @@
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
@ -40,14 +40,14 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.iswarn?'':'displayNone'">
<view class="warnnig" :class="formData.iswarn?'':'displayNone'">
<view>警告!环境存在漏电电源</view>
<view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view>
<view :class="getWarnStyle(1)" class="net netone"></view>
<view :class="getWarnStyle(2)" class="net nettwo"></view>
<view :class="getWarnStyle(3)" class="net netsiri"></view>
<view :class="getWarnStyle(4)" class="net netfour"></view>
<view :class="getWarnStyle(5)" class="net netfive"></view>
</view>
</view>

View File

@ -33,6 +33,10 @@
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value valueFont">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
@ -69,17 +73,17 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'">
<view class="warnnig" :class="formData.staticWarn?'':'displayNone'">
<view>警告设备静止报警中</view>
<view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view>
<view :class="getWarnStyle(1)" class="net netone"></view>
<view :class="getWarnStyle(2)" class="net nettwo"></view>
<view :class="getWarnStyle(3)" class="net netsiri"></view>
<view :class="getWarnStyle(4)" class="net netfour"></view>
<view :class="getWarnStyle(5)" class="net netfive"></view>
</view>
</view>
<view class="warnnig" v-bind:class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
<view class="warnnig" :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
@click="CloseWarn(true)">
<view>设备强制报警中</view>
<view class="netContent">

View File

@ -22,18 +22,20 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">充电状态</text>
<text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>

View File

@ -20,7 +20,7 @@
<view class="deviceId">
设备IMEI:{{device.imei}}
</view>
<view class="bound" v-bind:class="boundStatu">
<view class="bound" :class="boundStatu">
{{Statu.boundRemark}}
</view>
</view>

View File

@ -511,9 +511,11 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => {
// console.log('蓝牙状态发生变化:' + JSON.stringify(state));
this.data.discovering = state.discovering;
if (this.data.available !== state.available) {
this.data.available = state.available;
this.data.discovering = state.discovering;
if (this.data.available && this.data
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
@ -870,10 +872,7 @@ class BleHelper {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
this.StopSearch();
@ -882,15 +881,19 @@ class BleHelper {
uni.closeBluetoothAdapter({
success: () => {
// console.log("蓝牙模块已关闭");
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
resolve();
},
fail: (ex) => {
console.error('无法关闭蓝牙模块:', ex);
ex = this.getError(ex);
reject(ex);
},
complete: () => {
resolve();
}
});
@ -963,7 +966,8 @@ class BleHelper {
//停止搜索
StopSearch() {
if (this.data.platform == 'web') {
if (this.data.platform == 'web' || !this.data.discovering) {
console.error("web平台或当前没有搜索,直接返回");
return Promise.resolve();
}
let p1 = new Promise((resolve, reject) => {
@ -1481,7 +1485,9 @@ class BleHelper {
// 处理 MTU 设置
if (plus.os.name === 'Android') {
this.setMtu(deviceId);
this.setMtu(deviceId).catch(ex=>{
console.error("mtu设置失败=",ex);
});
}
resolve(true);
@ -1579,12 +1585,11 @@ class BleHelper {
_succ(mtuRes);
},
fail: (ex) => {
console.error(
"mtu设置失败", ex);
ex = this.getError(ex);
_err(
ex
); // MTU设置失败不影响连接成功
);
},
complete() {
console.log("设置mtu完毕");