Skip to main content

YOKONEX 设备扫描、连接、波形执行与状态输出依赖

Project description

yokonex-device

yokonex-device 是一个面向 YOKONEX 设备的独立 Python 仓库,负责:

  • 蓝牙设备扫描
  • 蓝牙连接与断开
  • 设备状态读取
  • EMS / Toy / GCQ 波形模型
  • 自定义波形与内置波形管理
  • 单设备 / 多设备波形执行
  • overlay 遥测数据输出

这个仓库刻意只保留设备层能力,不包含直播业务规则,例如:

  • 礼物档位
  • 价格区间映射
  • 弹幕关键词匹配
  • 直播事件分发
  • OBS 最近事件列表聚合

这些能力应放在业务项目中,由上层项目计算出目标波形后,再调用本仓库提供的接口。

仓库结构

yokonex-device/
  README.md
  pyproject.toml
  .gitignore
  docs/
    usage.md
  tests/
    test_bleak_runtime.py
    test_service.py
    test_storage.py
  yokonex_device/
    __init__.py
    models.py
    service.py
    storage.py
    ems_builtin_waveforms.py
    toy_builtin_waveforms.py
    gcq_toy_builtin_waveforms.py
    runtime/
      base.py
      bleak_runtime.py
      memory_runtime.py

安装

开发安装:

pip install -e .[dev]

普通安装:

pip install .

快速开始

from pathlib import Path

from yokonex_device import BluetoothService


service = BluetoothService.create_default(
    config_path=Path("config/bluetooth_settings.json"),
)

扫描与连接:

devices = await service.scan()
status = await service.connect(devices[0].device_id)
print(status.connected, status.device)

触发波形:

result = await service.trigger_waveform(
    event_type="manual_test",
    waveform_id="ems-preset-01",
)
print(result)

更多接入方式见 docs/usage.md

发布

构建:

python -m build

测试:

python -m pytest

上传到 PyPI:

python -m twine upload dist/*

也可以直接使用仓库内置的 GitHub Actions 发布工作流:

  • 给仓库打 tag,例如 v0.1.1
  • 推送 tag 到 GitHub
  • 工作流会先测试、构建,再通过 PyPI Trusted Publisher 发布

首次使用前需要在 PyPI 项目后台配置 Trusted Publisher,绑定:

  • owner: tzwgoo
  • repo: yokonex-device
  • workflow: .github/workflows/publish.yml

如果只想手动触发构建和发布,也可以在 GitHub Actions 页面使用 workflow_dispatch

与主仓库的关系

这个目录是从 Bililive-YOKONEX 中拆出的独立仓库骨架,适合作为新仓库初始化起点:

  1. 进入 standalone/yokonex-device
  2. 执行 git init
  3. 关联新的远端仓库
  4. 提交并推送

如果后续还需要从主仓库继续同步设备层能力,建议把同步边界控制在:

  • yokonex_device/
  • docs/usage.md
  • tests/test_bleak_runtime.py
  • 设备层专属测试

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

yokonex_device-0.1.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

yokonex_device-0.1.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file yokonex_device-0.1.0.tar.gz.

File metadata

  • Download URL: yokonex_device-0.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yokonex_device-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b9f4c4e931cf14f5a0535df5a748a230154a5f5fbd70feac92861766e2d7ba60
MD5 1754d7edc1be9c22b4e5d1f101df040e
BLAKE2b-256 12d09df06171784da3cd240a247e75d2dfad9697d4b070bfb83781db4d08a1a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for yokonex_device-0.1.0.tar.gz:

Publisher: publish.yml on tzwgoo/yokonex-device

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

File details

Details for the file yokonex_device-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yokonex_device-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yokonex_device-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a079c6a2a87c981ff17ab1f904462ff98cda4a78cf20e0585cba1bb164b85ac
MD5 2ca87e4b9cba9acad2c3b7b275a9bda6
BLAKE2b-256 1a70f1c3ab4f97848724b9ab604ced0ea8f29c6b5684731b797e86f80b2cd4db

See more details on using hashes here.

Provenance

The following attestation bundles were made for yokonex_device-0.1.0-py3-none-any.whl:

Publisher: publish.yml on tzwgoo/yokonex-device

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