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

Method get_paired_devices

actions/ble.py:1205–1245  ·  view source on GitHub ↗

Get list of paired Bluetooth devices Returns: Dictionary of paired devices keyed by MAC address

(self)

Source from the content-addressed store, hash-verified

1203 return False, f"Error disconnecting from {address}: {str(e)}"
1204
1205 def get_paired_devices(self) -> Dict[str, Dict[str, Any]]:
1206 """
1207 Get list of paired Bluetooth devices
1208 Returns: Dictionary of paired devices keyed by MAC address
1209 """
1210 paired_devices = {}
1211
1212 try:
1213 if self._is_windows():
1214 # Get paired devices from Windows using the same method but filter for paired
1215 all_devices = self._get_windows_bluetooth_devices()
1216 paired_devices = {addr: dev for addr, dev in all_devices.items() if dev.get('paired', False)}
1217 self.logger.info(f"Found {len(paired_devices)} paired devices on Windows")
1218 return paired_devices
1219
1220 # Linux method
1221 result = subprocess.run(['bluetoothctl', 'paired-devices'],
1222 capture_output=True, text=True, timeout=10)
1223
1224 if result.returncode == 0:
1225 for line in result.stdout.strip().split('\n'):
1226 if line.startswith('Device '):
1227 parts = line.split(None, 2)
1228 if len(parts) >= 2:
1229 address = parts[1]
1230 name = parts[2] if len(parts) > 2 else 'Unknown Device'
1231
1232 # Get detailed info
1233 device_info = self._get_device_details(address)
1234 device_info.update({
1235 'address': address,
1236 'name': name,
1237 'paired': True
1238 })
1239
1240 paired_devices[address] = device_info
1241
1242 except Exception as e:
1243 self.logger.error(f"Error getting paired devices: {e}")
1244
1245 return paired_devices
1246
1247 def scan_for_time(self, duration: int) -> Dict[str, Dict[str, Any]]:
1248 """

Callers 2

diagnose_scanningMethod · 0.95
get_bluetooth_infoFunction · 0.95

Calls 9

_is_windowsMethod · 0.95
_get_device_detailsMethod · 0.95
infoMethod · 0.80
errorMethod · 0.80
itemsMethod · 0.45
getMethod · 0.45
runMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected