device-manager.app.api.device_websocket ======================================= .. py:module:: device-manager.app.api.device_websocket .. autoapi-nested-parse:: Device websocket connection. This module defines the WebSocket endpoints for managing devices. It includes functionalities for: - Device registration and status updates via WebSocket. - Listening for commands from devices. Copyright (C) 2023, BRAIN-LINK UG (haftungsbeschränkt). All Rights Reserved. SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-ScanHub-Commercial Attributes ---------- .. autoapisummary:: device-manager.app.api.device_websocket.LOG_CALL_DELIMITER device-manager.app.api.device_websocket.DATA_LAKE_DIR device-manager.app.api.device_websocket.oauth2_scheme device-manager.app.api.device_websocket.router device-manager.app.api.device_websocket.dict_id_websocket device-manager.app.api.device_websocket.dict_id_parameters Functions --------- .. autoapisummary:: device-manager.app.api.device_websocket.start_scan_via_websocket device-manager.app.api.device_websocket.connection_with_valid_id_and_token device-manager.app.api.device_websocket.websocket_endpoint device-manager.app.api.device_websocket.handle_register device-manager.app.api.device_websocket.handle_status_update device-manager.app.api.device_websocket.handle_file_transfer device-manager.app.api.device_websocket._pick_result_type Module Contents --------------- .. py:data:: LOG_CALL_DELIMITER :value: '-------------------------------------------------------------------------------' .. py:data:: DATA_LAKE_DIR .. py:data:: oauth2_scheme .. py:data:: router .. py:data:: dict_id_websocket :type: Dict[uuid.UUID, fastapi.WebSocket] .. py:data:: dict_id_parameters :type: dict[uuid.UUID, dict] .. py:function:: start_scan_via_websocket(task: scanhub_libraries.models.AcquisitionTaskOut, access_token: Annotated[str, Depends(oauth2_scheme)]) :async: Start a scan via a websocket that was already opened by the device. Parameters ---------- device_task Details of the scan and the device to scan on. .. py:function:: connection_with_valid_id_and_token(websocket: fastapi.WebSocket) -> uuid.UUID :async: Check if the given device_id and device_token belong to an existing device in the database. .. py:function:: websocket_endpoint(websocket: fastapi.WebSocket) :async: Websocket endpoint for device communication. Args ---- websocket (WebSocket): The WebSocket connection object. device_id (UUID): The device_id. .. py:function:: handle_register(websocket: fastapi.WebSocket, message: dict, device_id: uuid.UUID) -> None :async: Handle device registration. .. py:function:: handle_status_update(websocket: fastapi.WebSocket, message: dict, device_id: uuid.UUID) -> None :async: Handle device status updates. .. py:function:: handle_file_transfer(websocket: fastapi.WebSocket, header: dict, device_id: uuid.UUID) -> None :async: Handle file transfer from device to server. .. py:function:: _pick_result_type(filename: str) Map extensions to enum.