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

Method get_status

actions/ble.py:84–187  ·  view source on GitHub ↗

Get comprehensive Bluetooth status Returns detailed status information

(self)

Source from the content-addressed store, hash-verified

82 return False, f"Error checking Bluetooth: {str(e)}"
83
84 def get_status(self) -> Dict[str, Any]:
85 """
86 Get comprehensive Bluetooth status
87 Returns detailed status information
88 """
89 status = {
90 'enabled': False,
91 'discoverable': False,
92 'pairable': False,
93 'scanning': self.scan_active,
94 'address': None,
95 'name': None,
96 'class': None,
97 'powered': False,
98 'error': None,
99 'controller_info': {},
100 'os_type': self.os_type
101 }
102
103 try:
104 if self._is_windows():
105 # Windows-specific Bluetooth status check
106 ps_script = """
107 $adapters = Get-PnpDevice -Class Bluetooth -Status OK
108 if ($adapters) {
109 $adapter = $adapters | Select-Object -First 1
110 $info = @{
111 Name = $adapter.FriendlyName
112 Status = $adapter.Status
113 InstanceId = $adapter.InstanceId
114 }
115 Write-Output ($info | ConvertTo-Json)
116 }
117 """
118
119 result = subprocess.run(['powershell', '-NoProfile', '-Command', ps_script],
120 capture_output=True, text=True, timeout=10)
121
122 if result.returncode == 0 and result.stdout.strip():
123 try:
124 adapter_info = json.loads(result.stdout.strip())
125 status['enabled'] = adapter_info.get('Status', '').upper() == 'OK'
126 status['powered'] = status['enabled']
127 status['name'] = adapter_info.get('Name', 'Windows Bluetooth Adapter')
128 status['controller_info'] = adapter_info
129
130 self.logger.info(f"Windows Bluetooth adapter found: {status['name']}")
131 except json.JSONDecodeError:
132 status['enabled'] = True # Assume enabled if we got output
133 status['powered'] = True
134 else:
135 status['error'] = 'No Bluetooth adapter found on Windows'
136 self.logger.warning("No Bluetooth adapter available on Windows")
137
138 # Windows scanning status
139 status['scanning'] = self.scan_active
140
141 else:

Callers 6

power_onMethod · 0.95
start_scanMethod · 0.95
diagnose_scanningMethod · 0.95
get_bluetooth_infoFunction · 0.95
executeMethod · 0.45
ble.pyFile · 0.45

Calls 7

_is_windowsMethod · 0.95
_check_scan_statusMethod · 0.95
infoMethod · 0.80
warningMethod · 0.80
errorMethod · 0.80
runMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected