diff --git a/.idea/claudeCodeTabState.xml b/.idea/claudeCodeTabState.xml index 14424ed..faec8fa 100644 --- a/.idea/claudeCodeTabState.xml +++ b/.idea/claudeCodeTabState.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/miniprogram/lefu/service.ts b/miniprogram/lefu/service.ts index 4d73db0..0689abf 100644 --- a/miniprogram/lefu/service.ts +++ b/miniprogram/lefu/service.ts @@ -83,6 +83,7 @@ class LeFuService { private readonly _maxReconnect = 3 private _reconnectTimer: number | null = null private _keepAliveTimer: number | null = null + private _lastRawDevice: RawDevice | null = null private _onDevicesListCb: ((devices: ScannedDevice[]) => void) | null = null private _onConnectStateCb: ((state: string) => void) | null = null @@ -181,6 +182,7 @@ class LeFuService { plugin.bus.subscribe('deviceWillDisconnect', () => { console.warn(TAG, 'bus[deviceWillDisconnect],intentionalConnect:', this._intentionalConnect) + this._activeProtocol = null this._stopKeepAlive() this._onDisconnectedCb?.() if (!this._intentionalConnect) { @@ -191,6 +193,7 @@ class LeFuService { connect(rawDevice: RawDevice): void { console.log(TAG, 'connect():', rawDevice.name) + this._lastRawDevice = rawDevice this._intentionalConnect = true this._stopKeepAlive() this._stopReconnectTimer() @@ -331,15 +334,19 @@ class LeFuService { private _doReconnect(): void { if (this._reconnectCount >= this._maxReconnect) { console.warn(TAG, '重连次数已达上限') + this._onDisconnectedCb?.() + return + } + if (!this._lastRawDevice) { + console.warn(TAG, '无缓存设备,放弃重连') return } this._reconnectCount++ console.log(TAG, `_doReconnect 第 ${this._reconnectCount} 次`) this._stopReconnectTimer() this._reconnectTimer = setTimeout(() => { - plugin.Blue.disconnect((res: any) => { - if (res?.errCode === 0) plugin.Blue.startBluetoothDevicesDiscovery() - }) + plugin.Blue.clearProtocol() + plugin.Blue.createBLEConnection(this._lastRawDevice!) }, 2000) } diff --git a/miniprogram/pages/equipmentMember/equipmentMember.ts b/miniprogram/pages/equipmentMember/equipmentMember.ts index c86d488..7c13627 100644 --- a/miniprogram/pages/equipmentMember/equipmentMember.ts +++ b/miniprogram/pages/equipmentMember/equipmentMember.ts @@ -130,6 +130,12 @@ Page({ memberList: [] as MemberDisplay[], }, + // 当前子页 addMember 未注册任何 SDK 回调,不会覆盖本页回调槽位,故无需 onShow 兜底。 + // 若未来子页新增 onDeviceConnect / onDisconnected 注册,需启用以下 onShow 同步连接状态。 + // onShow() { + // this.setData({ connected: lefuService.isConnected }) + // }, + onLoad() { const deviceInfo = lefuService.deviceInfo this.setData({ diff --git a/project.private.config.json b/project.private.config.json index 357d19c..f907d6c 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,5 +1,5 @@ { - "libVersion": "2.32.3", + "libVersion": "3.15.2", "projectname": "bodyWeight", "setting": { "urlCheck": false, @@ -14,7 +14,7 @@ "useLanDebug": false, "showES6CompileOption": false, "compileHotReLoad": true, - "bigPackageSizeSupport": false, + "bigPackageSizeSupport": true, "checkInvalidKey": true, "ignoreDevUnusedFiles": true }