device-manager.app.api.device_websocket#

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#

Functions#

start_scan_via_websocket(task, access_token)

Start a scan via a websocket that was already opened by the device.

connection_with_valid_id_and_token(→ uuid.UUID)

Check if the given device_id and device_token belong to an existing device in the database.

websocket_endpoint(websocket)

Websocket endpoint for device communication.

handle_register(→ None)

Handle device registration.

handle_status_update(→ None)

Handle device status updates.

handle_file_transfer(→ None)

Handle file transfer from device to server.

_pick_result_type(filename)

Map extensions to enum.

Module Contents#

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: Dict[uuid.UUID, fastapi.WebSocket]#
device-manager.app.api.device_websocket.dict_id_parameters: dict[uuid.UUID, dict]#
async device-manager.app.api.device_websocket.start_scan_via_websocket(task: scanhub_libraries.models.AcquisitionTaskOut, access_token: Annotated[str, Depends(oauth2_scheme)])#

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.

async device-manager.app.api.device_websocket.connection_with_valid_id_and_token(websocket: fastapi.WebSocket) uuid.UUID#

Check if the given device_id and device_token belong to an existing device in the database.

async device-manager.app.api.device_websocket.websocket_endpoint(websocket: fastapi.WebSocket)#

Websocket endpoint for device communication.

Args#

websocket (WebSocket): The WebSocket connection object. device_id (UUID): The device_id.

async device-manager.app.api.device_websocket.handle_register(websocket: fastapi.WebSocket, message: dict, device_id: uuid.UUID) None#

Handle device registration.

async device-manager.app.api.device_websocket.handle_status_update(websocket: fastapi.WebSocket, message: dict, device_id: uuid.UUID) None#

Handle device status updates.

async device-manager.app.api.device_websocket.handle_file_transfer(websocket: fastapi.WebSocket, header: dict, device_id: uuid.UUID) None#

Handle file transfer from device to server.

device-manager.app.api.device_websocket._pick_result_type(filename: str)#

Map extensions to enum.