fix(device): 修复设备切换连接订阅累积与自动重连,连接后更新缓存
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6ffda3f3f3
commit
f750d15150
@@ -94,6 +94,7 @@ class LeFuService {
|
||||
*/
|
||||
startScan(): void {
|
||||
console.log(TAG, 'startScan()')
|
||||
this._intentionalConnect = true
|
||||
plugin.Blue.setDeviceSetting(DEVICE_SETTINGS)
|
||||
this._subscribeBus()
|
||||
plugin.Blue.start(DEVICE_SETTINGS.map(s => s.deviceName), false)
|
||||
@@ -185,11 +186,9 @@ class LeFuService {
|
||||
}
|
||||
return
|
||||
}
|
||||
// 蓝牙就绪:如有缓存设备且非主动断开,尝试重连
|
||||
// 蓝牙就绪:非主动操作(意外断开)且有缓存设备时自动重连,主动扫描/连接期间不重连
|
||||
if (res === plugin.BLUE_STATE.READY) {
|
||||
if (this._intentionalConnect) {
|
||||
this._intentionalConnect = false
|
||||
} else if (this._lastRawDevice && !this._activeProtocol) {
|
||||
if (!this._intentionalConnect && this._lastRawDevice && !this._activeProtocol && this._onDevicesListCbs.size === 0) {
|
||||
this._stopReconnectTimer()
|
||||
wx.openBluetoothAdapter({
|
||||
success: () => this.connect(this._lastRawDevice!),
|
||||
|
||||
Reference in New Issue
Block a user