diff --git a/ble_pairing_helper.py b/ble_pairing_helper.py index e409d6d..372b7ad 100644 --- a/ble_pairing_helper.py +++ b/ble_pairing_helper.py @@ -273,9 +273,8 @@ async def attempt_pairing_linux(address, name, pin): }), flush=True) return False - # Trust the device - child.sendline(f'trust {address}') - child.expect('trust succeeded') + # Note: We don't set 'trust' to avoid automatic reconnection + # The device will be paired but won't automatically reconnect child.sendline('quit') child.close() diff --git a/install.sh b/install.sh index 77df670..4d8bae3 100755 --- a/install.sh +++ b/install.sh @@ -145,17 +145,21 @@ async def scan_ble_devices(): try: print("Scanning for MeshCore BLE devices...", file=sys.stderr, flush=True) - def match_meshcore_device(device: BLEDevice, advertisement_data: AdvertisementData): - """Filter to match MeshCore devices.""" - if advertisement_data.local_name and advertisement_data.local_name.startswith("MeshCore"): - return True - # Also check for T1000 devices - if advertisement_data.local_name and "T1000" in advertisement_data.local_name: - return True - return False + # Scan for all devices first, then filter + devices = await BleakScanner.discover(timeout=10.0) - # Scan for devices - devices = await BleakScanner.discover(timeout=10.0, detection_callback=match_meshcore_device) + # Filter to only MeshCore devices + meshcore_devices = [] + for device in devices: + if device.name: + # Check for MeshCore-* or Meshcore-* devices + if device.name.startswith("MeshCore-") or device.name.startswith("Meshcore-"): + meshcore_devices.append(device) + # Also check for T1000 devices + elif "T1000" in device.name: + meshcore_devices.append(device) + + devices = meshcore_devices if not devices: print("No MeshCore BLE devices found", file=sys.stderr, flush=True)