代码仓库
bleRPC 由一个主 monorepo 和多个针对各支持语言的协议库包组成。
主仓库
tdaira/blerpc
包含固件、central 客户端、代码生成器和测试的主 monorepo
| 目录 | 描述 |
|---|---|
peripheral_fw/ | Zephyr peripheral 固件 (C) — nRF54L15 & EFR32xG22E |
peripheral_py/ | Python peripheral (bless) 用于角色反转测试 |
central_py/ | Python central 客户端 (bleak) + 集成测试 |
central_fw/ | Zephyr central 固件 (C) 用于设备间通信 |
central_android/ | Android central 应用 (Kotlin) 含测试运行器 |
central_ios/ | iOS central 应用 (Swift) 含测试运行器 |
central_flutter/ | Flutter central 应用 (Dart) 含测试运行器 |
central_rn/ | React Native central 应用 (TypeScript) 含测试运行器 |
proto/ | Protocol Buffers 定义(blerpc.proto) |
tools/generate-handlers/ | 代码生成器 (Go) — 为所有语言生成处理器和客户端 |
boards/ | 自定义板卡定义 (EFR32xG22E) |
docs/ | 附加文档(固件指南) |
协议库
平台无关的协议编码/解码库,以各语言的独立包发布。
blerpc-protocol
Python C
容器分割/重组、命令编码/解码,以及端到端加密(密钥交换 + AES-128-GCM)。Python 包可通过 pip 安装。C 实现(c/src/ + c/include/)用于嵌入式场景
pip install git+https://github.com/tdaira/blerpc-protocol.git
blerpc-protocol-swift
Swift
适用于 iOS 和 macOS 的 Swift Package。使用 Foundation 和 CryptoKit(Apple 平台框架)。支持 iOS 16+ 和 macOS 13+
// Swift Package Manager
.package(url: "https://github.com/tdaira/blerpc-protocol-swift", from: "0.5.0")
blerpc-protocol-kt
Kotlin
适用于 Android 的 Kotlin 库。发布到 GitHub Packages (Maven)
implementation("com.blerpc:blerpc-protocol-kt:0.5.0")
blerpc-protocol-dart
Dart
适用于 Flutter 的纯 Dart 库。发布到 pub.dev。使用 cryptography 包进行加密
blerpc_protocol: ^0.6.0
blerpc-protocol-rn
TypeScript
适用于 React Native 的 TypeScript 库。使用 @noble/ciphers、@noble/curves 和 @noble/hashes 进行加密(纯 JS,无原生依赖)
"@blerpc/protocol-rn": "file:../blerpc-protocol-rn"
架构概览
各仓库之间的关系:
bleRPC (monorepo)
+-----------------------------------------+
| |
| proto/blerpc.proto |
| | |
| v |
| tools/generate-handlers (Go) |
| | |
| +---> peripheral_fw/src/ |
| | generated_handlers.{c,h} |
| | |
| +---> central_py/blerpc/generated/ |
| | generated_client.py |
| | |
| +---> central_android/.../ |
| | GeneratedClient.kt |
| | |
| +---> central_ios/.../ |
| | GeneratedClient.swift |
| | |
| +---> central_flutter/.../ |
| | generated_client.dart |
| | |
| +---> central_rn/.../ |
| | GeneratedClient.ts |
| | |
| +---> central_fw/src/ |
| generated_client.{c,h} |
| |
+-----------------------------------------+
| | | | |
v v v v v
blerpc-protocol blerpc- blerpc- blerpc- blerpc-
(Python + C) protocol-kt proto- proto- proto-
swift dart rn
CI / CD
每个仓库都配有 GitHub Actions CI,在每次 push 和 pull request 时运行:
| 仓库 | CI 检查项 |
|---|---|
| blerpc | Python 测试 + ruff lint,C lint (clang-format),Go lint + build,iOS build,Android build,Flutter build |
| blerpc-protocol | Python 测试 + lint,C lint + 测试 |
| blerpc-protocol-swift | swift build,swift test,SwiftLint |
| blerpc-protocol-kt | Gradle test,ktlint |
| blerpc-protocol-dart | dart analyze,dart test,自动发布到 pub.dev |
许可证
所有 bleRPC 仓库均以 GNU 宽通用公共许可证 v3.0 (LGPL-3.0) 发布,并附带静态链接例外。您可以静态链接 bleRPC 库而无需提供可重链接的目标文件。详情请参阅各仓库中的 LICENSING_EXCEPTION 文件。