mirror of
https://github.com/agessaman/meshcore-packet-capture.git
synced 2026-04-20 23:23:37 +00:00
ble helper output improvements
This commit is contained in:
parent
42c347f5a6
commit
322b597906
2 changed files with 6 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue