Get detailed information about a specific Bluetooth device Args: address: MAC address of the device Returns: Dictionary with detailed device information
(self, address: str)
| 947 | return diagnosis |
| 948 | |
| 949 | def _get_device_details(self, address: str) -> Dict[str, Any]: |
| 950 | """ |
| 951 | Get detailed information about a specific Bluetooth device |
| 952 | Args: |
| 953 | address: MAC address of the device |
| 954 | Returns: Dictionary with detailed device information |
| 955 | """ |
| 956 | details = {} |
| 957 | |
| 958 | try: |
| 959 | result = subprocess.run(['bluetoothctl', 'info', address], |
| 960 | capture_output=True, text=True, timeout=8) |
| 961 | |
| 962 | if result.returncode == 0: |
| 963 | info_output = result.stdout |
| 964 | |
| 965 | # Parse device information |
| 966 | for line in info_output.split('\n'): |
| 967 | line = line.strip() |
| 968 | |
| 969 | # Device name |
| 970 | if line.startswith('Name:'): |
| 971 | details['name'] = line.split(':', 1)[1].strip() |
| 972 | |
| 973 | # Device alias (friendly name, often more descriptive) |
| 974 | elif line.startswith('Alias:'): |
| 975 | alias = line.split(':', 1)[1].strip() |
| 976 | # Prefer alias over name if available |
| 977 | if alias and alias != details.get('name'): |
| 978 | details['alias'] = alias |
| 979 | # Use alias as the display name if it's more descriptive |
| 980 | if 'name' not in details or len(alias) > len(details['name']): |
| 981 | details['name'] = alias |
| 982 | |
| 983 | # RSSI (signal strength) |
| 984 | elif line.startswith('RSSI:'): |
| 985 | try: |
| 986 | details['rssi'] = int(line.split(':')[1].strip()) |
| 987 | except (ValueError, IndexError): |
| 988 | pass |
| 989 | |
| 990 | # Device class |
| 991 | elif line.startswith('Class:'): |
| 992 | details['device_class'] = line.split(':', 1)[1].strip() |
| 993 | |
| 994 | # Device type/icon |
| 995 | elif line.startswith('Icon:'): |
| 996 | details['device_type'] = line.split(':', 1)[1].strip() |
| 997 | |
| 998 | # Connection status |
| 999 | elif line.startswith('Connected:'): |
| 1000 | details['connected'] = 'yes' in line.lower() |
| 1001 | |
| 1002 | # Pairing status |
| 1003 | elif line.startswith('Paired:'): |
| 1004 | details['paired'] = 'yes' in line.lower() |
| 1005 | |
| 1006 | # Trust status |
no test coverage detected