Skip to main content

Asynchronous implementation of the Frontier Silicon API

Project description

python-afsapi

Asynchronous Python implementation of the Frontier Silicon API

Runtime dependency: - aiohttp

Development workflow (uv + ruff):

uv sync --group dev
uv run ruff check .
uv run pytest -q

Device recording tests (pytest-recording)

The repository includes integration tests that can record and replay real responses from the development radio.

  • Tests are in tests/test_device_recordings.py (read calls) and tests/test_device_recordings_write.py (write calls with state restore).
  • Cassettes are stored under tests/cassettes/.
  • Device tests replay cassettes by default (pytest runs them with no live device access).
  • Live/recording runs require both AFSAPI_DEVICE_IP and AFSAPI_DEVICE_PIN.

Set device IP + PIN and record fresh cassettes:

AFSAPI_DEVICE_IP="192.168.1.183" AFSAPI_DEVICE_PIN="1234" uv run pytest tests/test_device_recordings.py tests/test_device_recordings_write.py --run-device-tests --record-mode=once -q

Re-record all cassettes:

AFSAPI_DEVICE_IP="192.168.1.183" AFSAPI_DEVICE_PIN="1234" uv run pytest tests/test_device_recordings.py tests/test_device_recordings_write.py --run-device-tests --record-mode=all -q

Run default tests without touching the device:

uv run pytest -q

Usage

import asyncio
from afsapi import AFSAPI

URL = 'http://192.168.1.XYZ:80/device'
PIN = 1234
TIMEOUT = 1 # in seconds

async def test():
    afsapi = await AFSAPI.create(URL, PIN, TIMEOUT)

    print(f'Set power succeeded? - {await afsapi.set_power(True)}' )
    print(f'Power on: {await afsapi.get_power()}')
    print(f'Friendly name: {await afsapi.get_friendly_name()}')

    for mode in await afsapi.get_modes():
        print(f'Available Mode: {mode}')
    print(f'Current Mode: {await afsapi.get_mode()}')

    for equaliser in await afsapi.get_equalisers():
        print(f'Equaliser: {equaliser}')

    print(f'EQ Preset: {await afsapi.get_eq_preset()}' )

    for preset in await afsapi.get_presets():
        print(f"Preset: {preset}")

    print(f'Set power succeeded? - {await afsapi.set_power(False)}')
    print(f'Set sleep succeeded? - {await afsapi.set_sleep(10)}')
    print(f'Sleep: {await afsapi.get_sleep()}')
    print(f'Get power {await afsapi.get_power()}' )


loop = asyncio.new_event_loop()
loop.run_until_complete(test())

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

afsapi-1.0.0.tar.gz (138.8 kB view details)

Uploaded Source

Built Distribution

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

afsapi-1.0.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file afsapi-1.0.0.tar.gz.

File metadata

  • Download URL: afsapi-1.0.0.tar.gz
  • Upload date:
  • Size: 138.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for afsapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bd05fd4c8573bafc4b2021b3aa49d11d44da99a52674d67beaf0a2513e7d868c
MD5 6cb9a214f3dcb5062679466989bf14f1
BLAKE2b-256 a722406e14278756d9892c996447564c2426e1d5fcaaebeb903cee0b2c867e3f

See more details on using hashes here.

File details

Details for the file afsapi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: afsapi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for afsapi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72a49d95c99c60dcd9d9cf0947263c497cca3556ba6e3a2ea82dea5442a3ca45
MD5 5a7dab5bf0f9056018cdc9ac05dcb5e8
BLAKE2b-256 2caec8540dab8a6c02d84b20185d7e91adaeda9e07d6ed87b7a1601b02e42b1c

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