增加102J蓝牙协议待设备验证

This commit is contained in:
微微一笑
2026-04-17 09:45:02 +08:00
parent c6a33832d4
commit 736f24839f
4 changed files with 384 additions and 47 deletions

View File

@ -159,7 +159,7 @@
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" :showSlot="Status.Pop.showSlot">
<view v-if="Status.ShowEditChannel" class="popup-prompt">
<text class="popup-prompt-title">修改信道</text>
<input class="popup-prompt-input" type="number" placeholder="1-125的整数"
<input class="popup-prompt-input" type="number" placeholder="1-80的整数"
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.ins_Channel" />
</view>
@ -199,7 +199,15 @@
showPop,
MsgInfo
} from '@/utils/MsgPops.js'
const pagePath = "/pages/102/HBY102";
import {
encodeChannelSet,
encodeOnline,
encodeRadarFromUiKey,
encodeWarningLightFromLedKey,
encodeQueryOnlineCount,
encodeQueryPower
} from '@/api/102J/hby102jBleProtocol.js'
const pagePath = "/pages/102J/HBY102J";
var ble = null;
var these = null;
@ -298,7 +306,7 @@
callback: this.gotoShare
}
],
title: 'HBY102'
title: 'HBY102J'
},
apiType: ''
@ -411,7 +419,7 @@
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "/pages/650/HBY650",
detailPageUrl: "/pages/102J/HBY102J",
showConfirm: false
},
groupDevices: [],
@ -488,6 +496,9 @@
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
setTimeout(() => {
these.send102jCmd(encodeQueryPower());
}, 300);
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
@ -513,6 +524,9 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
setTimeout(() => {
these.send102jCmd(encodeQueryPower());
}, 300);
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
@ -561,6 +575,15 @@
}
},
methods: {
send102jCmd(hexArr) {
let f = this.getDevice();
if (!f) {
return Promise.reject({
msg: '未连接蓝牙'
});
}
return ble.sendHexs(f.deviceId, hexArr, f.writeServiceId, f.wirteCharactId, 30);
},
onChannelChanging() {
let f = this.getDevice();
@ -572,17 +595,20 @@
// #endif
let regex = /^([1-9]|[1-7][0-9]|80)$/;
if (!regex.test(this.formData.ins_Channel)) {
if (!regex.test(String(this.formData.ins_Channel))) {
uni.showModal({
title: '提示',
content: '只能输入1-80整数'
});
return;
}
var buffer = {
ins_Channel: this.formData.ins_Channel
}
ble.sendString(f.deviceId, buffer);
const ch = Number(this.formData.ins_Channel);
this.send102jCmd(encodeChannelSet(ch)).catch((ex) => {
uni.showModal({
title: '错误',
content: ex.msg || '发送失败'
});
});
},
ShowChannelEdit() {
@ -644,10 +670,7 @@
if (ble) {
let buffer = {
ins_Quantity: "query"
};
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.send102jCmd(encodeQueryOnlineCount()).then(() => {
setTimeout(() => {
this.getWarns();
}, 1500);
@ -738,7 +761,7 @@
},
success: (res) => {
let json = {
persissonType: '102'
persissonType: '102J'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
@ -813,12 +836,9 @@
val = 'E49_off';
}
let task = () => {
let json = {
ins_Online: val
}
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
.then(res => {
const on = val === 'E49_on';
this.send102jCmd(encodeOnline(on))
.then(() => {
this.formData.sta_Online = val;
these.setBleFormData();
})
@ -889,13 +909,8 @@
}
let task = () => {
let promise = new Promise((resolve, reject) => {
let json = {
ins_RadarType: val
}
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
.then(res => {
debugger;
this.send102jCmd(encodeRadarFromUiKey(val))
.then(() => {
this.formData.sta_RadarType = val;
this.Status.BottomMenu.activeIndex = index;
these.setBleFormData();
@ -972,14 +987,9 @@
deviceId: '12345'
}
// #endif
debugger;
let task = (val) => {
let promise = new Promise((resolve, reject) => {
let json = {
ins_LedType: val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.send102jCmd(encodeWarningLightFromLedKey(val)).then(() => {
this.formData.sta_LedType = val;
these.setBleFormData();
resolve();
@ -1094,11 +1104,18 @@
text: "蓝牙恢复可用,正在连接设备"
});
this.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => {
const lf = these.getDevice();
const linkP = lf
? ble.LinkBlue(these.formData.deviceId, lf.writeServiceId, lf.wirteCharactId, lf.notifyCharactId)
: ble.LinkBlue(these.formData.deviceId);
linkP.then(() => {
these.formData.bleStatu = true;
updateLoading(these, {
text: '连接成功'
});
setTimeout(() => {
these.send102jCmd(encodeQueryPower());
}, 300);
}).catch(ex => {
these.formData.bleStatu = 'err';
updateLoading(these, {
@ -1136,6 +1153,9 @@
this.getWarns();
}, 500);
if (json && json.bytes) {
return;
}
let active = -1;
let f = this.Status.BottomMenu.menuItems.find((item, index) => {