mirror of
https://github.com/smittix/intercept.git
synced 2026-07-05 16:18:12 -07:00
Merge pull request #227 from smittix/fix/meshcore-ble-scan-500
fix(meshcore): fix BLE scan 500 and allow scan before connect
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ def ports():
|
|||||||
def ble_scan():
|
def ble_scan():
|
||||||
if not is_meshcore_available():
|
if not is_meshcore_available():
|
||||||
return api_error("meshcore not installed", 503)
|
return api_error("meshcore not installed", 503)
|
||||||
devices = _client().scan_ble_sync()
|
devices = _client().scan_ble()
|
||||||
return jsonify({"devices": devices})
|
return jsonify({"devices": devices})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -413,10 +413,19 @@ class MeshcoreClient:
|
|||||||
self._worker.request_traceroute(node_id)
|
self._worker.request_traceroute(node_id)
|
||||||
|
|
||||||
def scan_ble(self) -> list[dict]:
|
def scan_ble(self) -> list[dict]:
|
||||||
"""Scan for BLE MeshCore devices; returns list of found device dicts."""
|
"""Scan for BLE MeshCore devices; works with or without an active connection."""
|
||||||
if self._worker:
|
if self._worker:
|
||||||
return self._worker.scan_ble_sync()
|
return self._worker.scan_ble_sync()
|
||||||
return []
|
# No worker yet — run a one-shot scan directly
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from utils.meshcore_client import _scan_ble
|
||||||
|
|
||||||
|
try:
|
||||||
|
return asyncio.run(_scan_ble())
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning("BLE scan failed: %s", exc)
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
_client: MeshcoreClient | None = None
|
_client: MeshcoreClient | None = None
|
||||||
|
|||||||
Reference in New Issue
Block a user