MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / check_bluetooth_availability

Method check_bluetooth_availability

actions/ble.py:47–82  ·  view source on GitHub ↗

Check if Bluetooth is available on the system Returns: (available, message)

(self)

Source from the content-addressed store, hash-verified

45 return self.os_type == 'Linux'
46
47 def check_bluetooth_availability(self) -> Tuple[bool, str]:
48 """
49 Check if Bluetooth is available on the system
50 Returns: (available, message)
51 """
52 try:
53 if self._is_windows():
54 # Check Windows Bluetooth availability using PowerShell
55 ps_script = """
56 $adapters = Get-PnpDevice -Class Bluetooth -Status OK
57 if ($adapters) { Write-Output "Available" } else { Write-Output "NotFound" }
58 """
59 result = subprocess.run(['powershell', '-Command', ps_script],
60 capture_output=True, text=True, timeout=10)
61
62 if result.returncode == 0 and 'Available' in result.stdout:
63 return True, "Bluetooth available on Windows"
64 else:
65 return False, "No Bluetooth adapters found on Windows"
66 else:
67 # Linux/Unix method
68 result = subprocess.run(['bluetoothctl', '--version'],
69 capture_output=True, text=True, timeout=5)
70 if result.returncode == 0:
71 return True, "Bluetooth available"
72 else:
73 return False, "bluetoothctl not found or not working"
74 except FileNotFoundError:
75 if self._is_windows():
76 return False, "PowerShell not found"
77 else:
78 return False, "bluetoothctl command not found"
79 except subprocess.TimeoutExpired:
80 return False, "Bluetooth check command timed out"
81 except Exception as e:
82 return False, f"Error checking Bluetooth: {str(e)}"
83
84 def get_status(self) -> Dict[str, Any]:
85 """

Callers 4

diagnose_scanningMethod · 0.95
get_bluetooth_infoFunction · 0.95
executeMethod · 0.80
ble.pyFile · 0.80

Calls 2

_is_windowsMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected