From 535f4728ea111613fbec6e8c550f36b818c4ad07 Mon Sep 17 00:00:00 2001 From: liub Date: Mon, 18 Aug 2025 08:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=80=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/BleHelper.js | 16 ++++++++-------- utils/BleReceive.js | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 utils/BleReceive.js diff --git a/utils/BleHelper.js b/utils/BleHelper.js index 6fab1a5..5b62b7a 100644 --- a/utils/BleHelper.js +++ b/utils/BleHelper.js @@ -128,8 +128,8 @@ class BleHelper { } //设置发现新设备的回调 - addDeviceFound(callback) { - let key = this.getCurrentPagePath(); + addDeviceFound(callback,currKey) { + let key =currKey?currKey:this.getCurrentPagePath(); if (!key) { key = new Date().getTime(); } @@ -150,8 +150,8 @@ class BleHelper { } //移除发现新设备的回调 - removeDeviceFound() { - let key = this.getCurrentPagePath(); + removeDeviceFound(currKey) { + let key =currKey?currKey: this.getCurrentPagePath(); if (key) { console.log("key=" + key); @@ -170,8 +170,8 @@ class BleHelper { } //添加接收到数据的回调 - addReceiveCallback(callback) { - let key = this.getCurrentPagePath(); + addReceiveCallback(callback,currKey) { + let key =currKey?currKey: this.getCurrentPagePath(); if (!key) { key = new Date().getTime(); } @@ -193,8 +193,8 @@ class BleHelper { //设置接收到数据的回调 - removeReceiveCallback(ev) { - let key = this.getCurrentPagePath(); + removeReceiveCallback(ev,currKey) { + let key =currKey?currKey: this.getCurrentPagePath(); if (key) { console.log("key=" + key); let f = this.cfg.receivDataCallback.findIndex((v) => { diff --git a/utils/BleReceive.js b/utils/BleReceive.js new file mode 100644 index 0000000..0897802 --- /dev/null +++ b/utils/BleReceive.js @@ -0,0 +1,21 @@ + +class BleReceive { + constructor() { + this.StorageKey = "linkedDevices"; + } + + +} + + + +let instance = null; +export default { + getBleReceive: function(found, receive) { + if (!instance) { + instance = new BleReceive(); + + } + return instance; + } +} \ No newline at end of file