diff --git a/ble_scan_helper.py b/ble_scan_helper.py index b9d48a6..681bae0 100644 --- a/ble_scan_helper.py +++ b/ble_scan_helper.py @@ -14,7 +14,8 @@ from bleak.backends.scanner import AdvertisementData async def scan_ble_devices(): """Scan for MeshCore BLE devices using BleakScanner""" try: - print("Scanning for MeshCore BLE devices...", flush=True) + # Send status message to stderr so it doesn't interfere with JSON output + 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.""" @@ -29,7 +30,7 @@ async def scan_ble_devices(): devices = await BleakScanner.discover(timeout=10.0, detection_callback=match_meshcore_device) if not devices: - print("No MeshCore BLE devices found", flush=True) + print("No MeshCore BLE devices found", file=sys.stderr, flush=True) return [] # Format devices for the installer @@ -42,7 +43,7 @@ async def scan_ble_devices(): } formatted_devices.append(device_info) - # Output as JSON for the installer to parse + # Output as JSON for the installer to parse (stdout only) print(json.dumps(formatted_devices), flush=True) return formatted_devices diff --git a/install.sh b/install.sh index 2239116..40493b0 100755 --- a/install.sh +++ b/install.sh @@ -143,7 +143,7 @@ from bleak.backends.scanner import AdvertisementData async def scan_ble_devices(): """Scan for MeshCore BLE devices using BleakScanner""" try: - print("Scanning for MeshCore BLE devices...", flush=True) + 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.""" @@ -158,7 +158,7 @@ async def scan_ble_devices(): devices = await BleakScanner.discover(timeout=10.0, detection_callback=match_meshcore_device) if not devices: - print("No MeshCore BLE devices found", flush=True) + print("No MeshCore BLE devices found", file=sys.stderr, flush=True) return [] # Format devices for the installer