disconnect_g1_device
Disconnect from a connected G1 Bluetooth device to close the BLE connection, stop the heartbeat mechanism, and free up resources.
Instructions
Disconnect from the current G1 device.
Returns:
Dict[str, Any]: JSON response with disconnection status including:
- result: "success" or "error"
- disconnected: Boolean indicating disconnection state
- device_name: Name of previously connected device (if successful)
- error: Error message if disconnection failed
Note:
This closes the BLE connection to the currently connected device,
cleans up resources, stops the heartbeat mechanism, and resets connection state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server.py:187-224 (handler)The handler function decorated with @server.tool(), implementing the disconnect_g1_device tool. It handles disconnection logic using the global ble_manager instance.@server.tool() async def disconnect_g1_device() -> Dict[str, Any]: """Disconnect from the current G1 device. Returns: Dict[str, Any]: JSON response with disconnection status including: - result: "success" or "error" - disconnected: Boolean indicating disconnection state - device_name: Name of previously connected device (if successful) - error: Error message if disconnection failed Note: This closes the BLE connection to the currently connected device, cleans up resources, stops the heartbeat mechanism, and resets connection state. """ if not ble_manager.is_connected: return { "result": "error", "disconnected": False, "error": "Not connected to any device" } device_name = ble_manager.target_device.name if ble_manager.target_device else "Unknown" try: await ble_manager.disconnect() return { "result": "success", "disconnected": True, "device_name": device_name } except Exception as e: logger.error(f"Disconnection failed: {e}") return { "result": "error", "disconnected": False, "error": f"Disconnection failed: {str(e)}" }