Skip to main content
Glama
by danroblewis

disconnect_g1_device

Terminate the active BLE connection to a G1 device, clean up resources, stop the heartbeat mechanism, and reset connection state. Returns disconnection status and device details.

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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "title": "disconnect_g1_deviceArguments", "type": "object" }

Implementation Reference

  • Main tool handler for disconnect_g1_device. Validates connection, calls ble_manager.disconnect(), and returns status.
    @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)}" }
  • Core disconnect implementation in NordicBLEUARTManager class. Stops monitoring task, disconnects BLE client, and resets all connection state variables.
    async def disconnect(self): """Disconnect from the current device""" # Stop connection monitoring if self.connection_monitor_task: self.connection_monitor_task.cancel() self.connection_monitor_task = None if self.client and self.is_connected: try: await self.client.disconnect() logger.info("Disconnected from device") except Exception as e: logger.error(f"Error during disconnect: {e}") # Always clean up state self.is_connected = False self.client = None self.uart_service = None self.tx_characteristic = None self.rx_characteristic = None self.target_device = None self.connection_start_time = None self.last_activity_time = None self.last_heartbeat = None self.reconnect_attempts = 0
  • mcp_server.py:187-187 (registration)
    @server.tool() decorator registers the disconnect_g1_device function with the FastMCP server.
    @server.tool()

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danroblewis/g1_uart_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server