From bc3c056c8dccab38dbfdf78b24c4b1905b06216f Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 30 May 2026 13:53:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(mp):=20=E5=8F=AA=E5=9C=A8=20connection:true?= =?UTF-8?q?=20=E6=9C=80=E7=BB=88=E5=9B=9E=E8=B0=83=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=BF=87=E6=97=A9?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=97=A0=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 连接回调触发 4 次(createBLEConnection → services → characteristics → connection:true), errno:0 在第一次回调就匹配了条件,导致认证指令在特征值订阅完成前发送, BLE 通知通道未建立,认证响应无法送达。 修正:仅 result.connection === true 时触发认证流程, 这是 SDK 合并接口的最终就绪信号。 --- apps/miniprogram/native/pkg-veepoo/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/miniprogram/native/pkg-veepoo/index.js b/apps/miniprogram/native/pkg-veepoo/index.js index b65e15c..3d363c9 100644 --- a/apps/miniprogram/native/pkg-veepoo/index.js +++ b/apps/miniprogram/native/pkg-veepoo/index.js @@ -183,8 +183,10 @@ Page({ // eslint-disable-next-line no-undef console.log('[veepoo-native] 连接回调:', JSON.stringify(result)); - // 按官方 Demo 检查 connection:true,同时兼容 errno:0 / errCode:0 - if (result.connection === true || result.errno === 0 || result.errCode === 0) { + // 只响应最终回调(connection:true),忽略中间阶段(services/characteristics/errno:0) + // 连接回调会触发多次:createBLEConnection → services → characteristics → connection:true + // 认证必须在特征值订阅完成后发送 + if (result.connection === true) { self._connected = true; self._connecting = false; self.setData({