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

Method disconnect_device

actions/ble.py:1179–1203  ·  view source on GitHub ↗

Disconnect from a Bluetooth device Args: address: MAC address of the device to disconnect Returns: (success, message)

(self, address: str)

Source from the content-addressed store, hash-verified

1177 return False, f"Error connecting to {address}: {str(e)}"
1178
1179 def disconnect_device(self, address: str) -> Tuple[bool, str]:
1180 """
1181 Disconnect from a Bluetooth device
1182 Args:
1183 address: MAC address of the device to disconnect
1184 Returns: (success, message)
1185 """
1186 try:
1187 self.logger.info(f"Disconnecting from device {address}...")
1188 result = subprocess.run(['bluetoothctl', 'disconnect', address],
1189 capture_output=True, text=True, timeout=15)
1190
1191 if result.returncode == 0:
1192 self.logger.info(f"Successfully disconnected from {address}")
1193 return True, f"Successfully disconnected from {address}"
1194 else:
1195 error_msg = result.stderr.strip() or f'Failed to disconnect from {address}'
1196 self.logger.error(f"Failed to disconnect from {address}: {error_msg}")
1197 return False, error_msg
1198
1199 except subprocess.TimeoutExpired:
1200 return False, f"Disconnect from {address} timed out"
1201 except Exception as e:
1202 self.logger.error(f"Error disconnecting from {address}: {e}")
1203 return False, f"Error disconnecting from {address}: {str(e)}"
1204
1205 def get_paired_devices(self) -> Dict[str, Dict[str, Any]]:
1206 """

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80
errorMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected