diff --git a/miniprogram/services/ble/connection.js b/miniprogram/services/ble/connection.js index aad675b..1dad359 100644 --- a/miniprogram/services/ble/connection.js +++ b/miniprogram/services/ble/connection.js @@ -255,10 +255,11 @@ function startScan(callbacks) { var d = devices[i] var name = (d.name || '').toUpperCase() var localName = (d.localName || '').toUpperCase() + if (!name && !localName) continue console.log('[BLE] 发现设备:', d.name, '| localName:', d.localName, '| deviceId:', d.deviceId) var matched = false if (targetName) { - matched = name === targetName || localName === targetName + matched = name.indexOf(targetName) !== -1 || localName.indexOf(targetName) !== -1 } else { matched = localName.indexOf('JW_') !== -1 || name.indexOf('JW_') !== -1 || @@ -266,8 +267,8 @@ function startScan(callbacks) { name.indexOf('LIGHTMASK') !== -1 || localName.indexOf('LIGHTMASK') !== -1 || name.indexOf('SIMPLE PERIPHERAL') !== -1 || localName.indexOf('SIMPLE PERIPHERAL') !== -1 } + console.log('[BLE] 匹配结果:', matched, targetName ? '(精确:' + targetName + ')' : '(模糊)') if (matched) { - console.log('[BLE] 匹配成功:', d.name, '| localName:', d.localName, targetName ? '(精确匹配)' : '(模糊匹配)') wx.stopBluetoothDevicesDiscovery({}) if (callbacks.onFound) callbacks.onFound(d) connect(d.deviceId, callbacks)