Skip to main content

Async helper for Atlas Command's asset websocket gateway.

Project description

Atlas Asset WebSocket Client

Async helper that speaks the asset WebSocket contract (/ws/assets). The package manages the handshake, heartbeat cadence, telemetry helpers, command acknowledgements, and schema validation so asset OS projects stay in sync with Atlas Command without reimplementing the protocol.

Requirements

  • Python 3.9–3.12
  • websockets>=10
  • pydantic>=1.10

Install the package from PyPI:

pip install atlas-asset-websocket-client

During development inside this repository, install the editable package:

pip install -e Atlas_Command/connection_packages/atlas_asset_ws_client

Quickstart

import asyncio
from atlas_asset_ws_client import AssetWebSocketClient

URL = "ws://localhost:8000/ws/assets"
ASSET_ID = "asset-123"

async def connect(url: str):
    import websockets

    return await websockets.connect(url, ping_interval=20)

async def main() -> None:
    client = AssetWebSocketClient(URL, asset_id=ASSET_ID, connect=connect)
    async with client:
        ack = await client.handshake(
            {
                "firmware_version": "1.6.2",
                "capabilities": {"telemetry": True, "commands": True},
            }
        )
        print("Handshake ACK:", ack.payload)
        await client.send_heartbeat()
        await client.send_telemetry_update(
            {"latitude": 40.7128, "longitude": -74.0060, "altitude_m": 120}
        )

asyncio.run(main())

API Overview

  • Connection: connect(), close(), async with client: ...
  • Protocol helpers: handshake(), send_heartbeat(), send_telemetry_update(), request_command_queue(), complete_command(), send_settings_update(), create_track(), update_track(), create_geofeature(), update_geofeature(), delete_geofeature()
  • Schema helpers: atlas_asset_ws_client.schemas.AssetEnvelope and atlas_asset_ws_client.schemas.AssetMeta expose the same metadata contract used by Atlas Command.
  • Low-level helpers: send_json(), receive_json(), receive_envelope()

All helpers populate meta.asset_id, meta.stream, timestamps, and correlation_id defaults when omitted.

Custom Transport or Headers

Provide a custom connect(url: str) coroutine if you need TLS, headers, proxies, or token handling. The coroutine must return an object that implements send, recv, and close coroutines.

Operation Notes

  • Always call handshake() before sending other frames.
  • Honor the heartbeat cadence advertised in the handshake acknowledgement.
  • After reconnecting, redo the handshake and call request_command_queue() to restore queue state.
  • Supply deterministic correlation_id values to trace requests across services.

Schema Exports

The package re-exports the schema models used internally so you can import the envelope definitions without pulling in Atlas Command:

  • atlas_asset_ws_client.schemas.AssetEnvelope
  • atlas_asset_ws_client.schemas.AssetMeta

See Atlas_Command/docs/WEBSOCKET.md and Atlas_Command/docs/CLIENT_INTEGRATION.md for protocol references and integration tips.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atlas_asset_websocket_client-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atlas_asset_websocket_client-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file atlas_asset_websocket_client-0.1.1.tar.gz.

File metadata

File hashes

Hashes for atlas_asset_websocket_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 763307d6ba607cfc47726ac568b695e13a7e77a785d249953629805de1e37eec
MD5 d2e59cc30cae4747f47f154a865635d6
BLAKE2b-256 5135ab76e1f9eddfc7d7d09079a328384848860d5f610b8d5e5f0dbf69534c67

See more details on using hashes here.

File details

Details for the file atlas_asset_websocket_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for atlas_asset_websocket_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e31b3324cc61a9f0ce3b2f8e437bdb26bda4c53065321cb63205e482853d568
MD5 329c11bc5f25603c157e287cee92af41
BLAKE2b-256 ca6e5cc2d8fbdb3f80ba568333e85e2c636b94ef690ce134e3ab5d8fe07a5d93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page