mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 14:50:00 -07:00
Prioritize bleak over DBus for Flask compatibility
DBus/BlueZ requires a GLib main loop which Flask doesn't have. Reordered backend priority: bleak > hcitool > bluetoothctl > dbus Removed DBus option from UI since it won't work with Flask. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -270,18 +270,15 @@ def _check_capabilities_permission(caps: SystemCapabilities) -> None:
|
||||
|
||||
def _determine_recommended_backend(caps: SystemCapabilities) -> None:
|
||||
"""Determine the recommended scanning backend."""
|
||||
# Prefer DBus/BlueZ if available and working
|
||||
if caps.has_dbus and caps.has_bluez and caps.adapters:
|
||||
if not caps.is_soft_blocked and not caps.is_hard_blocked:
|
||||
caps.recommended_backend = 'dbus'
|
||||
return
|
||||
# NOTE: DBus/BlueZ requires a GLib main loop which Flask doesn't have.
|
||||
# For Flask applications, we prefer bleak or subprocess-based tools.
|
||||
|
||||
# Fallback to bleak (cross-platform)
|
||||
# Prefer bleak (cross-platform, works in Flask)
|
||||
if caps.has_bleak:
|
||||
caps.recommended_backend = 'bleak'
|
||||
return
|
||||
|
||||
# Fallback to hcitool (requires root)
|
||||
# Fallback to hcitool (requires root on Linux)
|
||||
if caps.has_hcitool and caps.is_root:
|
||||
caps.recommended_backend = 'hcitool'
|
||||
return
|
||||
@@ -291,6 +288,13 @@ def _determine_recommended_backend(caps: SystemCapabilities) -> None:
|
||||
caps.recommended_backend = 'bluetoothctl'
|
||||
return
|
||||
|
||||
# DBus is last resort - won't work properly with Flask but keep as option
|
||||
# for potential future use with a separate scanning daemon
|
||||
if caps.has_dbus and caps.has_bluez and caps.adapters:
|
||||
if not caps.is_soft_blocked and not caps.is_hard_blocked:
|
||||
caps.recommended_backend = 'dbus'
|
||||
return
|
||||
|
||||
caps.recommended_backend = 'none'
|
||||
if not caps.issues:
|
||||
caps.issues.append('No suitable Bluetooth scanning backend available')
|
||||
|
||||
Reference in New Issue
Block a user