Skip to main content

Asyncio implementation of the Spinel protocol for OpenThread RCPs

Project description

aiospinel

An asyncio implementation of the Spinel protocol used to communicate with OpenThread RCPs over a serial connection.

Installation

pip install aiospinel

Usage

This library exports an SpinelProtocol asyncio protocol object.

import asyncio

import serialx

from aiospinel import CommandID, PropertyID, ResetReason, SpinelProtocol


async def main() -> None:
    loop = asyncio.get_running_loop()
    _, protocol = await serialx.create_serial_connection(
        loop=loop,
        protocol_factory=SpinelProtocol,
        url="/dev/ttyUSB0",
        baudrate=460800,
    )
    await protocol.wait_until_connected()

    try:
        await protocol.reset(ResetReason.STACK)

        rsp = await protocol.send_command(
            CommandID.PROP_VALUE_GET,
            PropertyID.HWADDR.serialize(),
        )
        prop_id, hwaddr = PropertyID.deserialize(rsp.data)
        assert prop_id == PropertyID.HWADDR

        print("Hardware address:", hwaddr.hex())
    finally:
        await protocol.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

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

aiospinel-1.2.0.tar.gz (59.9 kB view details)

Uploaded Source

Built Distribution

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

aiospinel-1.2.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file aiospinel-1.2.0.tar.gz.

File metadata

  • Download URL: aiospinel-1.2.0.tar.gz
  • Upload date:
  • Size: 59.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for aiospinel-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b71a771583a767cb57ff4f6cfa560f1ec22eef1496c790436daf80e808442075
MD5 296b05016fa8744adf7a96103f923979
BLAKE2b-256 c7963ee10d7cc34f6b764b617714f9777a16a0b13ce4b63d832f06c93534432c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiospinel-1.2.0.tar.gz:

Publisher: publish-to-pypi.yml on home-assistant-libs/aiospinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiospinel-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: aiospinel-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for aiospinel-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84824074101bff1ea7186fc541fdd6d39c1a8cda354252f0b80289944f5ef5ca
MD5 4db67593adeaa3ae706aa7c3f4c39442
BLAKE2b-256 b89e239584868623787832574d4530ee3a8e7af4b61ef42370934e6e034aeae2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiospinel-1.2.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on home-assistant-libs/aiospinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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