670小问题修复

This commit is contained in:
liub
2025-09-23 16:57:31 +08:00
parent 2546287bb4
commit ab696c3076
7 changed files with 84 additions and 69 deletions

View File

@ -1,16 +1,17 @@
import receivTool from "@/utils/BleReceive.js"
var recei = null;
const serviceDic = [ //合作供应商的蓝牙主服务
{
"serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB",
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
},
{
"serviceId": "0000AE30-0000-1000-8000-00805F9B34FB",
"writeId": "0000AE03-0000-1000-8000-00805F9B34FB",
"notifyId": "0000AE02-0000-1000-8000-00805F9B34FB"
},
{
"serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB",
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
}
];
class BleHelper {
@ -39,7 +40,10 @@ class BleHelper {
}
setTimeout(() => {
this.linkAllDevices();
this.OpenBlue().then(()=>{
this.linkAllDevices();
});
}, 10);
this.data = {
isOpenBlue: false, //蓝牙模块是否开启
@ -185,7 +189,7 @@ class BleHelper {
key = new Date().getTime();
}
if (key) {
console.log("key=" + key);
// console.log("key=" + key);
let f = this.cfg.onDeviceFound.findIndex((v) => {
return v.key == key;
});
@ -366,6 +370,7 @@ class BleHelper {
return new Promise((resolve, reject) => {
if (this.data.available) {
console.log("蓝牙模块是可用状态");
resolve({
available: this.data.available,
discovering: this.data.discovering
@ -373,6 +378,7 @@ class BleHelper {
return;
}
if (!this.data.isOpenBlue) {
console.log("蓝牙模块未打开");
resolve({
available: false,
discovering: false
@ -381,12 +387,13 @@ class BleHelper {
}
uni.getBluetoothAdapterState({
success: (info) => {
console.log("蓝牙状态获取成功,",info)
this.data.available = info.available;
this.data.discovering = info.discovering;
resolve(info);
},
fail: (ex1) => {
////console.log("ex1", ex1);
console.log("蓝牙状态获取失败", ex1);
let res1 = {
available: false,
discovering: false
@ -472,7 +479,7 @@ class BleHelper {
});
uni.onBluetoothDeviceFound((devices) => {
// console.log("发现新设备:" + JSON.stringify(devices));
console.log("发现新设备:" + JSON.stringify(devices));
this.data.searchList = this.data.searchList.concat(
devices);
if (this.cfg.onDeviceFound) {
@ -706,8 +713,9 @@ class BleHelper {
// for (let i = 0; i < serviceIds.length; i++) {
// promises.push(RunSearch(serviceIds[i]));
// }
promises.push(RunSearch());
promises.push(RunSearch());
Promise.all(promises).then(resolve).catch(reject);
});

View File

@ -257,7 +257,7 @@ export default {
value: "42",
label: "SOS",
checked: false,
type: ['210', '6170', '670']
type: ['670']
}
]

View File

@ -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)