bluebus 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bluebus-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +26 -0
- bluebus-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- bluebus-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +16 -0
- bluebus-0.1.0/.github/dependabot.yml +19 -0
- bluebus-0.1.0/.github/pull_request_template.md +9 -0
- bluebus-0.1.0/.github/workflows/capi-release.yml +84 -0
- bluebus-0.1.0/.github/workflows/ci.yml +93 -0
- bluebus-0.1.0/.github/workflows/codeql.yml +33 -0
- bluebus-0.1.0/.github/workflows/python.yml +107 -0
- bluebus-0.1.0/.github/workflows/scorecard.yml +34 -0
- bluebus-0.1.0/.gitignore +23 -0
- bluebus-0.1.0/CHANGELOG.md +145 -0
- bluebus-0.1.0/CODE_OF_CONDUCT.md +15 -0
- bluebus-0.1.0/CONTRIBUTING.md +35 -0
- bluebus-0.1.0/Cargo.lock +1147 -0
- bluebus-0.1.0/Cargo.toml +29 -0
- bluebus-0.1.0/LICENSE +21 -0
- bluebus-0.1.0/PKG-INFO +203 -0
- bluebus-0.1.0/README.md +511 -0
- bluebus-0.1.0/SECURITY.md +14 -0
- bluebus-0.1.0/examples/ble_e2e.rs +347 -0
- bluebus-0.1.0/examples/hardware_smoke.rs +315 -0
- bluebus-0.1.0/examples/mock_bluez.rs +274 -0
- bluebus-0.1.0/examples/virtual_e2e.rs +536 -0
- bluebus-0.1.0/pyproject.toml +43 -0
- bluebus-0.1.0/python/.gitignore +6 -0
- bluebus-0.1.0/python/Cargo.toml +20 -0
- bluebus-0.1.0/python/README.md +178 -0
- bluebus-0.1.0/python/bluebus/__init__.py +61 -0
- bluebus-0.1.0/python/bluebus/__init__.pyi +368 -0
- bluebus-0.1.0/python/bluebus/_callbacks.py +54 -0
- bluebus-0.1.0/python/bluebus/exceptions.py +44 -0
- bluebus-0.1.0/python/bluebus/py.typed +0 -0
- bluebus-0.1.0/python/examples/bench_scenario.py +127 -0
- bluebus-0.1.0/python/examples/e2e.py +259 -0
- bluebus-0.1.0/python/requirements-ci.in +5 -0
- bluebus-0.1.0/python/requirements-ci.txt +48 -0
- bluebus-0.1.0/python/src/central.rs +684 -0
- bluebus-0.1.0/python/src/errors.rs +72 -0
- bluebus-0.1.0/python/src/lib.rs +53 -0
- bluebus-0.1.0/python/src/peripheral.rs +531 -0
- bluebus-0.1.0/python/src/streams.rs +273 -0
- bluebus-0.1.0/python/src/types.rs +333 -0
- bluebus-0.1.0/python/tests/conftest.py +111 -0
- bluebus-0.1.0/python/tests/test_bluebus.py +614 -0
- bluebus-0.1.0/src/adapter.rs +323 -0
- bluebus-0.1.0/src/agent.rs +465 -0
- bluebus-0.1.0/src/agent_manager.rs +21 -0
- bluebus-0.1.0/src/ble/adapter.rs +430 -0
- bluebus-0.1.0/src/ble/agent.rs +93 -0
- bluebus-0.1.0/src/ble/device.rs +721 -0
- bluebus-0.1.0/src/ble/error.rs +114 -0
- bluebus-0.1.0/src/ble/info.rs +366 -0
- bluebus-0.1.0/src/ble/mod.rs +174 -0
- bluebus-0.1.0/src/ble/peripheral.rs +774 -0
- bluebus-0.1.0/src/ble/scan.rs +580 -0
- bluebus-0.1.0/src/ble/session.rs +220 -0
- bluebus-0.1.0/src/ble/uuid.rs +165 -0
- bluebus-0.1.0/src/cache.rs +253 -0
- bluebus-0.1.0/src/connection.rs +13 -0
- bluebus-0.1.0/src/device.rs +174 -0
- bluebus-0.1.0/src/gatt.rs +1027 -0
- bluebus-0.1.0/src/leadvertisement.rs +527 -0
- bluebus-0.1.0/src/lib.rs +98 -0
- bluebus-0.1.0/src/monitor.rs +246 -0
- bluebus-0.1.0/src/object_manager.rs +83 -0
- bluebus-0.1.0/src/object_server_ready.rs +26 -0
- bluebus-0.1.0/src/paths.rs +145 -0
- bluebus-0.1.0/tests/ble_api.rs +1138 -0
- bluebus-0.1.0/tests/bluez_mock.rs +1175 -0
- bluebus-0.1.0/tests/common/mod.rs +1368 -0
- bluebus-0.1.0/tests/compat_0_1_10.rs +194 -0
- bluebus-0.1.0/tests/system_bus_env.rs +41 -0
- bluebus-0.1.0/tools/btvirt/Dockerfile +13 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Something fails, hangs or behaves unexpectedly
|
|
3
|
+
labels: [bug]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: what
|
|
7
|
+
attributes:
|
|
8
|
+
label: What happened
|
|
9
|
+
description: What you expected, and what you got instead (error messages, logs).
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: repro
|
|
14
|
+
attributes:
|
|
15
|
+
label: Code to reproduce
|
|
16
|
+
description: The smallest code that shows the problem.
|
|
17
|
+
render: rust
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: input
|
|
21
|
+
id: version
|
|
22
|
+
attributes:
|
|
23
|
+
label: Versions and platform
|
|
24
|
+
placeholder: bluebus 0.1.11, BlueZ 5.72, Ubuntu 24.04, Intel AX211
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: A BlueZ feature, profile or API you'd like
|
|
3
|
+
labels: [enhancement]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: want
|
|
7
|
+
attributes:
|
|
8
|
+
label: What you'd like
|
|
9
|
+
description: The feature, and what you want to use it for.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: now
|
|
14
|
+
attributes:
|
|
15
|
+
label: What you do today
|
|
16
|
+
description: How you work around it now, if at all.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: cargo
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
groups:
|
|
8
|
+
cargo:
|
|
9
|
+
patterns: ["*"]
|
|
10
|
+
- package-ecosystem: github-actions
|
|
11
|
+
directory: /
|
|
12
|
+
schedule:
|
|
13
|
+
interval: weekly
|
|
14
|
+
groups:
|
|
15
|
+
actions:
|
|
16
|
+
patterns: ["*"]
|
|
17
|
+
ignore:
|
|
18
|
+
# Its tags name Rust toolchains (the MSRV pin), not action versions.
|
|
19
|
+
- dependency-name: dtolnay/rust-toolchain
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## What and why
|
|
2
|
+
|
|
3
|
+
<!-- What does this change, and why? Link the issue if there is one. -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] `cargo fmt`, `cargo clippy --all-targets -- -D warnings` and `cargo test` pass
|
|
8
|
+
- [ ] Tests added or updated
|
|
9
|
+
- [ ] `CHANGELOG.md` updated (for user-visible changes)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Prebuilt C/C++ libraries (capi/): pushed tags `c-v*` build the shared and
|
|
2
|
+
# static library for Linux x86_64 and aarch64 (glibc), test them against the
|
|
3
|
+
# mock BlueZ, and attach archives (include/, lib/ with the CMake package and
|
|
4
|
+
# pkg-config file, README, LICENSE) to the GitHub release of the tag.
|
|
5
|
+
name: C/C++ libraries
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["c-v*"]
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
env:
|
|
16
|
+
CARGO_TERM_COLOR: always
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
include:
|
|
24
|
+
- { os: ubuntu-22.04, name: linux-x86_64 }
|
|
25
|
+
- { os: ubuntu-22.04-arm, name: linux-aarch64 }
|
|
26
|
+
runs-on: ${{ matrix.os }}
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
29
|
+
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
|
|
30
|
+
with:
|
|
31
|
+
toolchain: stable
|
|
32
|
+
- name: Install dbus-daemon (for the tests)
|
|
33
|
+
run: command -v dbus-daemon || (sudo apt-get update && sudo apt-get install -y dbus)
|
|
34
|
+
- name: Build, test and install with CMake
|
|
35
|
+
run: |
|
|
36
|
+
d="$PWD/bluebus-c-${{ matrix.name }}"
|
|
37
|
+
cmake -S capi -B build -DCMAKE_BUILD_TYPE=Release -DBLUEBUS_TESTS=ON -DCMAKE_INSTALL_PREFIX="$d"
|
|
38
|
+
cmake --build build -j "$(nproc)"
|
|
39
|
+
ctest --test-dir build --output-on-failure
|
|
40
|
+
cmake --install build
|
|
41
|
+
strip --strip-unneeded "$d/lib/libbluebus.so"
|
|
42
|
+
cp capi/README.md LICENSE "$d/"
|
|
43
|
+
- name: Check the archive (CMake package, pkg-config, static and shared)
|
|
44
|
+
run: |
|
|
45
|
+
d="$PWD/bluebus-c-${{ matrix.name }}"
|
|
46
|
+
mkdir smoke
|
|
47
|
+
cat > smoke/CMakeLists.txt <<'CMAKE'
|
|
48
|
+
cmake_minimum_required(VERSION 3.16)
|
|
49
|
+
project(smoke C CXX)
|
|
50
|
+
find_package(bluebus 0.1 REQUIRED)
|
|
51
|
+
add_executable(scan ../capi/examples/scan.c)
|
|
52
|
+
target_link_libraries(scan PRIVATE bluebus::bluebus)
|
|
53
|
+
add_executable(central ../capi/examples/central.cpp)
|
|
54
|
+
set_target_properties(central PROPERTIES CXX_STANDARD 17)
|
|
55
|
+
target_link_libraries(central PRIVATE bluebus::static)
|
|
56
|
+
CMAKE
|
|
57
|
+
cmake -S smoke -B smoke/build -DCMAKE_PREFIX_PATH="$d"
|
|
58
|
+
cmake --build smoke/build
|
|
59
|
+
PKG_CONFIG_PATH="$d/lib/pkgconfig" pkg-config --cflags --libs bluebus
|
|
60
|
+
cc -std=c99 capi/examples/peripheral.c $(PKG_CONFIG_PATH="$d/lib/pkgconfig" pkg-config --cflags --libs bluebus) -o smoke/peripheral
|
|
61
|
+
tar czf "bluebus-c-${{ matrix.name }}.tar.gz" "bluebus-c-${{ matrix.name }}"
|
|
62
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
63
|
+
with:
|
|
64
|
+
name: bluebus-c-${{ matrix.name }}
|
|
65
|
+
path: bluebus-c-${{ matrix.name }}.tar.gz
|
|
66
|
+
|
|
67
|
+
release:
|
|
68
|
+
permissions:
|
|
69
|
+
contents: write
|
|
70
|
+
needs: build
|
|
71
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
72
|
+
runs-on: ubuntu-latest
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
75
|
+
with:
|
|
76
|
+
path: dist
|
|
77
|
+
merge-multiple: true
|
|
78
|
+
- name: Attach to the release
|
|
79
|
+
env:
|
|
80
|
+
GH_TOKEN: ${{ github.token }}
|
|
81
|
+
run: |
|
|
82
|
+
gh release view "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|
|
83
|
+
|| gh release create "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" --title "C/C++ libraries $GITHUB_REF_NAME" --notes "Prebuilt bluebus C/C++ libraries for Linux (see capi/README.md)."
|
|
84
|
+
gh release upload "$GITHUB_REF_NAME" dist/* -R "$GITHUB_REPOSITORY" --clobber
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
CARGO_TERM_COLOR: always
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
18
|
+
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
|
|
19
|
+
with:
|
|
20
|
+
toolchain: stable
|
|
21
|
+
components: clippy, rustfmt
|
|
22
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
23
|
+
- name: Check formatting
|
|
24
|
+
run: cargo fmt --all -- --check
|
|
25
|
+
- name: Clippy
|
|
26
|
+
run: cargo clippy --all-targets -- -D warnings
|
|
27
|
+
- name: Tests (unit, mock BlueZ integration, doc, README)
|
|
28
|
+
run: cargo test --verbose
|
|
29
|
+
- name: Docs
|
|
30
|
+
run: cargo doc --no-deps
|
|
31
|
+
env:
|
|
32
|
+
RUSTDOCFLAGS: -D warnings
|
|
33
|
+
|
|
34
|
+
semver:
|
|
35
|
+
# The bluebus crate must stay backward compatible with the last release
|
|
36
|
+
# on crates.io (python/ and capi/ are not published there).
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
40
|
+
- uses: obi1kenobi/cargo-semver-checks-action@6b69fcf40e9b5fb17adeb57e4b6ecd020649a239 # v2.9
|
|
41
|
+
with:
|
|
42
|
+
package: bluebus
|
|
43
|
+
|
|
44
|
+
msrv:
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
48
|
+
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
|
|
49
|
+
with:
|
|
50
|
+
toolchain: "1.89"
|
|
51
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
52
|
+
- name: Build and test on the minimum supported Rust version
|
|
53
|
+
run: cargo test
|
|
54
|
+
|
|
55
|
+
c-api:
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
59
|
+
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
|
|
60
|
+
with:
|
|
61
|
+
toolchain: stable
|
|
62
|
+
components: clippy
|
|
63
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
64
|
+
- name: Clippy (bluebus-c)
|
|
65
|
+
run: cargo clippy -p bluebus-c --all-targets -- -D warnings
|
|
66
|
+
- name: Rust tests of the C API (mock BlueZ, header, C/C++ programs)
|
|
67
|
+
run: cargo test -p bluebus-c --verbose
|
|
68
|
+
- name: CMake configure and build (library, tests, examples)
|
|
69
|
+
run: |
|
|
70
|
+
cmake -S capi -B build-capi -DBLUEBUS_TESTS=ON -DCMAKE_INSTALL_PREFIX="$PWD/install-capi"
|
|
71
|
+
cmake --build build-capi -j "$(nproc)"
|
|
72
|
+
- name: CTest (C and C++ tests against the mock BlueZ)
|
|
73
|
+
run: ctest --test-dir build-capi --output-on-failure
|
|
74
|
+
- name: Install, then build against the CMake package and pkg-config
|
|
75
|
+
run: |
|
|
76
|
+
cmake --install build-capi
|
|
77
|
+
mkdir consumer
|
|
78
|
+
cat > consumer/CMakeLists.txt <<'CMAKE'
|
|
79
|
+
cmake_minimum_required(VERSION 3.16)
|
|
80
|
+
project(consumer C CXX)
|
|
81
|
+
find_package(bluebus 0.1 REQUIRED)
|
|
82
|
+
add_executable(scan ../capi/examples/scan.c)
|
|
83
|
+
target_link_libraries(scan PRIVATE bluebus::bluebus)
|
|
84
|
+
add_executable(central ../capi/examples/central.cpp)
|
|
85
|
+
set_target_properties(central PROPERTIES CXX_STANDARD 17)
|
|
86
|
+
target_link_libraries(central PRIVATE bluebus::static)
|
|
87
|
+
CMAKE
|
|
88
|
+
cmake -S consumer -B consumer/build -DCMAKE_PREFIX_PATH="$PWD/install-capi"
|
|
89
|
+
cmake --build consumer/build
|
|
90
|
+
export PKG_CONFIG_PATH="$PWD/install-capi/lib/pkgconfig"
|
|
91
|
+
cc -std=c99 capi/examples/peripheral.c $(pkg-config --cflags --libs bluebus) -o consumer/peripheral
|
|
92
|
+
cc -std=c99 capi/examples/scan.c $(pkg-config --cflags bluebus) install-capi/lib/libbluebus.a \
|
|
93
|
+
$(pkg-config --libs-only-l --static bluebus | sed 's/-lbluebus//') -o consumer/scan-static
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CodeQL
|
|
2
|
+
# Static security analysis of the Rust and workflow code.
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: "17 4 * * 1"
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
analyze:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
security-events: write
|
|
19
|
+
contents: read
|
|
20
|
+
actions: read
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
language: [rust, actions]
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
27
|
+
- uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
28
|
+
with:
|
|
29
|
+
languages: ${{ matrix.language }}
|
|
30
|
+
build-mode: none
|
|
31
|
+
- uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
32
|
+
with:
|
|
33
|
+
category: "/language:${{ matrix.language }}"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
name: Python package
|
|
2
|
+
# Tests the Python bindings (python/) against the mock BlueZ on every push;
|
|
3
|
+
# on a tag `py-vX.Y.Z` builds Linux wheels (abi3: one wheel per
|
|
4
|
+
# architecture for Python 3.9+) and an sdist and publishes them to PyPI
|
|
5
|
+
# (trusted publishing: add this repository, this workflow and the `pypi`
|
|
6
|
+
# environment as a publisher of the `bluebus` project on PyPI once).
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
# Branch pushes run the tests when these paths change; tags build wheels
|
|
10
|
+
# (path filters do not apply to tags).
|
|
11
|
+
branches: ["**"]
|
|
12
|
+
paths:
|
|
13
|
+
- "python/**"
|
|
14
|
+
- "src/**"
|
|
15
|
+
- "Cargo.toml"
|
|
16
|
+
- "examples/mock_bluez.rs"
|
|
17
|
+
- "tests/common/**"
|
|
18
|
+
- ".github/workflows/python.yml"
|
|
19
|
+
tags: ["py-v*"]
|
|
20
|
+
pull_request:
|
|
21
|
+
paths:
|
|
22
|
+
- "python/**"
|
|
23
|
+
- "src/**"
|
|
24
|
+
- "Cargo.toml"
|
|
25
|
+
- "examples/mock_bluez.rs"
|
|
26
|
+
- "tests/common/**"
|
|
27
|
+
- ".github/workflows/python.yml"
|
|
28
|
+
|
|
29
|
+
permissions:
|
|
30
|
+
contents: read
|
|
31
|
+
|
|
32
|
+
env:
|
|
33
|
+
CARGO_TERM_COLOR: always
|
|
34
|
+
|
|
35
|
+
jobs:
|
|
36
|
+
test:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
40
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.12"
|
|
43
|
+
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
|
|
44
|
+
with:
|
|
45
|
+
toolchain: stable
|
|
46
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
47
|
+
- name: Build the mock BlueZ
|
|
48
|
+
run: cargo build --example mock_bluez
|
|
49
|
+
- name: Build and test
|
|
50
|
+
working-directory: python
|
|
51
|
+
env:
|
|
52
|
+
BLUEBUS_MOCK: ${{ github.workspace }}/target/debug/examples/mock_bluez
|
|
53
|
+
run: |
|
|
54
|
+
python -m venv .venv
|
|
55
|
+
.venv/bin/pip install --require-hashes -r requirements-ci.txt
|
|
56
|
+
.venv/bin/maturin develop --release
|
|
57
|
+
.venv/bin/python -m pytest -q tests
|
|
58
|
+
|
|
59
|
+
wheels:
|
|
60
|
+
if: startsWith(github.ref, 'refs/tags/py-v')
|
|
61
|
+
needs: test
|
|
62
|
+
strategy:
|
|
63
|
+
matrix:
|
|
64
|
+
target: [x86_64, aarch64]
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
68
|
+
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
|
|
69
|
+
with:
|
|
70
|
+
working-directory: python
|
|
71
|
+
target: ${{ matrix.target }}
|
|
72
|
+
args: --release --out dist
|
|
73
|
+
manylinux: auto
|
|
74
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
75
|
+
with:
|
|
76
|
+
name: wheels-linux-${{ matrix.target }}
|
|
77
|
+
path: python/dist
|
|
78
|
+
|
|
79
|
+
sdist:
|
|
80
|
+
if: startsWith(github.ref, 'refs/tags/py-v')
|
|
81
|
+
needs: test
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
85
|
+
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
|
|
86
|
+
with:
|
|
87
|
+
working-directory: python
|
|
88
|
+
command: sdist
|
|
89
|
+
args: --out dist
|
|
90
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
91
|
+
with:
|
|
92
|
+
name: sdist
|
|
93
|
+
path: python/dist
|
|
94
|
+
|
|
95
|
+
publish:
|
|
96
|
+
if: startsWith(github.ref, 'refs/tags/py-v')
|
|
97
|
+
needs: [wheels, sdist]
|
|
98
|
+
runs-on: ubuntu-latest
|
|
99
|
+
environment: pypi
|
|
100
|
+
permissions:
|
|
101
|
+
id-token: write
|
|
102
|
+
steps:
|
|
103
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
104
|
+
with:
|
|
105
|
+
path: dist
|
|
106
|
+
merge-multiple: true
|
|
107
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: OpenSSF Scorecard
|
|
2
|
+
# Supply-chain security checks; results feed the Scorecard badge in the README.
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: "29 5 * * 1"
|
|
8
|
+
branch_protection_rule:
|
|
9
|
+
|
|
10
|
+
permissions: read-all
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
analysis:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
security-events: write
|
|
17
|
+
id-token: write
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
- uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
|
|
23
|
+
with:
|
|
24
|
+
results_file: results.sarif
|
|
25
|
+
results_format: sarif
|
|
26
|
+
publish_results: true
|
|
27
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
28
|
+
with:
|
|
29
|
+
name: SARIF file
|
|
30
|
+
path: results.sarif
|
|
31
|
+
retention-days: 5
|
|
32
|
+
- uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
33
|
+
with:
|
|
34
|
+
sarif_file: results.sarif
|
bluebus-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated by Cargo
|
|
2
|
+
# will have compiled files and executables
|
|
3
|
+
debug/
|
|
4
|
+
target/
|
|
5
|
+
|
|
6
|
+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
7
|
+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
8
|
+
Cargo.lock
|
|
9
|
+
|
|
10
|
+
# These are backup files generated by rustfmt
|
|
11
|
+
**/*.rs.bk
|
|
12
|
+
|
|
13
|
+
# MSVC Windows builds of rustc generate these, which store debugging information
|
|
14
|
+
*.pdb
|
|
15
|
+
|
|
16
|
+
# RustRover
|
|
17
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
18
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
19
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
20
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
21
|
+
#.idea/
|
|
22
|
+
# Claude Code worktrees
|
|
23
|
+
.claude/
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.12 — 2026-11-24
|
|
4
|
+
|
|
5
|
+
Additive only; backward compatible with 0.1.11 and 0.1.10. The Python
|
|
6
|
+
package `bluebus` 0.1.0 and the C/C++ libraries `c-v0.1.0` are released
|
|
7
|
+
with it.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`bluebus::ble`: a high-level, easy API** (not re-exported at the crate
|
|
11
|
+
root, where `Adapter`/`Device` are the zbus proxies). Cloneable,
|
|
12
|
+
`Send + Sync + 'static` handles with plain-data results and a single
|
|
13
|
+
`ble::Error` (`Bus`, `Timeout`, `NotFound`, `InvalidArgument`):
|
|
14
|
+
- `Session` (`new`, `with_connection`, `adapters`, `adapter`,
|
|
15
|
+
`default_adapter`, `set_agent`, `remove_agent`);
|
|
16
|
+
- `Adapter` (`power_on`/`power_off`, `scan`, `scan_stream` with a guard that
|
|
17
|
+
stops discovery on drop, `find_device`, `device`, `devices`,
|
|
18
|
+
`remove_device`, `peripheral`) and the `ScanFilter` builder (transport,
|
|
19
|
+
exact/prefix name, address, service UUIDs, minimum RSSI, duplicate data);
|
|
20
|
+
- `Device` (`connect` waiting for `ServicesResolved`, `disconnect`, `pair`,
|
|
21
|
+
`trust`, `services`, `read`/`write` with `WriteType`, `notifications`
|
|
22
|
+
stream that stops on drop and is shared between subscribers,
|
|
23
|
+
`read_descriptor`/`write_descriptor`, `battery_level`, `rssi`, `info`);
|
|
24
|
+
the GATT database is cached per connection and refreshed when stale;
|
|
25
|
+
- `PeripheralBuilder` → `Peripheral`: GATT services, characteristics
|
|
26
|
+
(flags, initial value, write callback, read-only descriptors) and an
|
|
27
|
+
advertisement on unique object paths, with `set_value`, `notify`,
|
|
28
|
+
`value`, `is_notifying` and `stop` (also best effort on drop);
|
|
29
|
+
- `AutoAcceptAgent`, `PasskeyAgent`; `normalize_uuid` (16/32/128-bit forms).
|
|
30
|
+
- `examples/ble_e2e.rs`: the virtual-controller end-to-end test written with
|
|
31
|
+
`bluebus::ble` only.
|
|
32
|
+
- `characteristic_notifications_acquired`: notifications through BlueZ'
|
|
33
|
+
`AcquireNotify` socket instead of D-Bus signals. 5 000 notifications
|
|
34
|
+
arrive in ~85 ms instead of ~420 ms and cost ~7 ms of CPU instead of ~70 ms
|
|
35
|
+
(virtual controllers, see `benchmarks/`).
|
|
36
|
+
|
|
37
|
+
- **Python bindings** (`python/`, PyPI package `bluebus`, crate
|
|
38
|
+
`bluebus-python` in a new cargo workspace; the `bluebus` package itself is
|
|
39
|
+
unchanged): PyO3 + `pyo3-async-runtimes` (tokio), abi3 wheels for Python
|
|
40
|
+
3.9+, Linux only. Every I/O method returns an asyncio awaitable:
|
|
41
|
+
`Session` (`await Session.new()` / `await Session()`, `adapters`,
|
|
42
|
+
`adapter`, `set_agent("auto" | passkey=…)`), `Adapter` (`scan`,
|
|
43
|
+
`scan_stream` async iterator, `find_device`, …), `Device` (`connected()`
|
|
44
|
+
async context manager, `read`/`write`, `notifications` async iterator,
|
|
45
|
+
`services`, `pair`, …) and the peripheral builders (`Service`,
|
|
46
|
+
`Characteristic` with `on_write` callbacks run on the event loop,
|
|
47
|
+
`Advertisement`, `Peripheral`). Read-only `DeviceInfo`/`ServiceInfo`/…
|
|
48
|
+
data classes, type stubs (`py.typed`) and the exceptions `BluebusError`,
|
|
49
|
+
`BluebusTimeout` (a `TimeoutError`), `NotFound`, `InvalidArgument` and
|
|
50
|
+
`DBusError` (`.name`). Tested with pytest against the mock BlueZ;
|
|
51
|
+
`python/examples/e2e.py` mirrors `ble_e2e.rs`; CI in
|
|
52
|
+
`.github/workflows/python.yml` (PyPI trusted publishing on `py-v*` tags).
|
|
53
|
+
- `examples/mock_bluez.rs`: the mock `org.bluez` of the test suite as a
|
|
54
|
+
standalone process (prints the private bus address, takes commands on
|
|
55
|
+
stdin) for tests in other languages.
|
|
56
|
+
|
|
57
|
+
- **C and C++ API** (`capi/`, crate `bluebus-c` 0.1.0, library `libbluebus`
|
|
58
|
+
shared and static; the repository is now a cargo workspace, the `bluebus`
|
|
59
|
+
package is unchanged): blocking, thread-safe C functions over
|
|
60
|
+
`bluebus::ble` in `capi/include/bluebus.h` (opaque handles for session,
|
|
61
|
+
adapter, device, scan, notifications, peripheral builder and peripheral;
|
|
62
|
+
`bluebus_status` codes with thread-local `bluebus_last_error` /
|
|
63
|
+
`bluebus_last_dbus_error_name`; scanning blocking or with callbacks,
|
|
64
|
+
connect, pair, trust, GATT read/write/descriptors, flattened service
|
|
65
|
+
list, notifications as callbacks or pulled with a timeout, a peripheral
|
|
66
|
+
builder with write callbacks, auto-accept and passkey agents), plus the
|
|
67
|
+
header-only C++17 wrapper `bluebus.hpp`. Panics never cross the C
|
|
68
|
+
boundary. CMake project exporting `bluebus::bluebus` (also as an
|
|
69
|
+
installed, relocatable `find_package` config), pkg-config `bluebus.pc`,
|
|
70
|
+
examples `scan.c`, `peripheral.c` and `central.cpp`, tests against the
|
|
71
|
+
mock BlueZ from Rust, C and C++, a `c-api` CI job and a `c-v*` release
|
|
72
|
+
workflow with prebuilt Linux x86_64 and aarch64 archives.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
- CI checks the `bluebus` crate with `cargo semver-checks` against the
|
|
76
|
+
last crates.io release.
|
|
77
|
+
- Minimum supported Rust version is now declared (`rust-version = "1.89"`)
|
|
78
|
+
and checked in CI; the current dependency versions need 1.89.
|
|
79
|
+
- zbus runs on the tokio runtime (`features = ["tokio"]`) instead of its own
|
|
80
|
+
async-io executor thread: about 35 % less CPU for GATT reads and writes.
|
|
81
|
+
bluebus already required tokio. The `*ProxyBlocking` types of 0.1.11 stay
|
|
82
|
+
(zbus `blocking-api` feature).
|
|
83
|
+
- `characteristic_notifications` reads the notified value straight from the
|
|
84
|
+
D-Bus message (about 15 % less CPU per notification), with the general
|
|
85
|
+
decoder as fallback.
|
|
86
|
+
- `gatt_characteristic_proxy` caches properties lazily: proxies used only to
|
|
87
|
+
read, write or receive notifications no longer re-parse every
|
|
88
|
+
notification into the property cache.
|
|
89
|
+
|
|
90
|
+
## 0.1.11
|
|
91
|
+
|
|
92
|
+
Backward compatible with 0.1.10 (verified with `cargo semver-checks` and
|
|
93
|
+
`tests/compat_0_1_10.rs`). Several features that could not work before now
|
|
94
|
+
do; their D-Bus side changed accordingly.
|
|
95
|
+
|
|
96
|
+
### Fixed
|
|
97
|
+
- **GATT server could not be registered.** `GattService`/`GattCharacteristic`
|
|
98
|
+
exported their properties as D-Bus *methods*, used `s` instead of `o` for
|
|
99
|
+
object paths, and there was no `RegisterApplication`/`ObjectManager`.
|
|
100
|
+
Properties are now real properties with BlueZ' names and signatures, and
|
|
101
|
+
`register_gatt_application[_at]` registers the application.
|
|
102
|
+
- **`Agent` could not be registered**: it did not implement `org.bluez.Agent1`.
|
|
103
|
+
It now implements the new `AgentHandler` trait; `register_agent` exports
|
|
104
|
+
and registers it. PINs/passkeys are no longer printed to stdout.
|
|
105
|
+
- **`unregister_advertisement` always failed**: wrong method name
|
|
106
|
+
(`UnRegisterAdvertisement`) and a string instead of an object path; the
|
|
107
|
+
exported object was also left behind, so registering again failed.
|
|
108
|
+
- **Advertisement property names**: `ServiceUuids`/`SolicitUuids` were not
|
|
109
|
+
recognised by BlueZ, so service UUIDs were never advertised. Unset optional
|
|
110
|
+
properties were exported as empty values (an empty `SecondaryChannel` is
|
|
111
|
+
rejected by BlueZ); they are now omitted. Advertisements were only
|
|
112
|
+
configurable through `Default`; added `new` + `with_*` builders.
|
|
113
|
+
- **GATT client property names**: `uuid()` (`Uuid`), `mtu()` (`Mtu`) always
|
|
114
|
+
failed; they now read `UUID`/`MTU`. Added `service_path`, `device_path`,
|
|
115
|
+
`include_paths` with the correct object-path types.
|
|
116
|
+
- **Monitor dead-locked** on the first property change (a read guard was held
|
|
117
|
+
while taking the write lock), spun at 100 % CPU when the bus closed, reported
|
|
118
|
+
a device as removed when only e.g. `Battery1` was removed, ignored devices
|
|
119
|
+
that existed before it started, tracked only 3 properties, and leaked one
|
|
120
|
+
task per device. Rewritten with a single subscription.
|
|
121
|
+
- `print_avaiable_devices` printed every object; it now prints devices only.
|
|
122
|
+
- Mutex poisoning in the path globals no longer panics.
|
|
123
|
+
- Race in zbus' object server start-up that could make the first agent /
|
|
124
|
+
GATT / advertisement registration hang forever.
|
|
125
|
+
- README and crate-level examples did not compile.
|
|
126
|
+
|
|
127
|
+
### Added
|
|
128
|
+
- Adapter: discovery filter (+ typed `DiscoveryFilter`), `GetDiscoveryFilters`,
|
|
129
|
+
`ConnectDevice`, timeouts, pairable, UUIDs, roles, …; `adapter_proxy`,
|
|
130
|
+
`list_adapters`, `set_adapter_powered`.
|
|
131
|
+
- Device: `ConnectProfile`/`DisconnectProfile`, alias, RSSI, TX power,
|
|
132
|
+
manufacturer/service/advertising data, appearance, icon, bonded, wake
|
|
133
|
+
allowed, …; `Battery1`; `device_proxy`, `device_path`,
|
|
134
|
+
`address_from_device_path`, `advertising_bytes`.
|
|
135
|
+
- GATT: descriptors (client and server), `AcquireWrite`/`AcquireNotify`/
|
|
136
|
+
`Confirm`, `discover_gatt_database`, `characteristic_notifications` (every
|
|
137
|
+
notification, in order), offset-aware read/write, write callbacks,
|
|
138
|
+
`notify_characteristic_value`, `GattManager1Proxy`.
|
|
139
|
+
- `LEAdvertisingManager1Proxy`, `register_advertisement_at`.
|
|
140
|
+
- `list_devices_with_connection`, `list_adapter_devices[_with_paths]`,
|
|
141
|
+
`DeviceInfo::from_properties`, `Monitor::run`, `Monitor::devices`.
|
|
142
|
+
- Mock-BlueZ integration tests, hardware smoke test, virtual end-to-end test.
|
|
143
|
+
|
|
144
|
+
### Deprecated
|
|
145
|
+
- `print_avaiable_devices` → `print_available_devices`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Code of conduct
|
|
2
|
+
|
|
3
|
+
This project adopts the
|
|
4
|
+
[Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
|
|
5
|
+
|
|
6
|
+
In short: be respectful and constructive, assume good intent, and keep
|
|
7
|
+
discussion about the work. Harassment, insults and personal attacks are not
|
|
8
|
+
accepted in issues, pull requests or any other project space.
|
|
9
|
+
|
|
10
|
+
## Reporting
|
|
11
|
+
|
|
12
|
+
Report unacceptable behavior privately to the maintainer through
|
|
13
|
+
[GitHub](https://github.com/sameteraslan). Reports are handled confidentially.
|
|
14
|
+
Maintainers may remove comments, close threads or block participants who
|
|
15
|
+
break these rules.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing to bluebus
|
|
2
|
+
|
|
3
|
+
Bug reports, questions and pull requests are welcome.
|
|
4
|
+
|
|
5
|
+
## Reporting a bug
|
|
6
|
+
|
|
7
|
+
Open an [issue](https://github.com/bluebus-rs/bluebus/issues/new/choose)
|
|
8
|
+
with the smallest code that shows the problem, your bluebus and BlueZ
|
|
9
|
+
versions (`bluetoothctl --version`) and the adapter you use. Output of
|
|
10
|
+
`btmon` or `RUST_LOG=trace` helps for anything timing related.
|
|
11
|
+
|
|
12
|
+
## Pull requests
|
|
13
|
+
|
|
14
|
+
`main` is protected: every change goes through a pull request from a fork,
|
|
15
|
+
and the CI checks must pass before it is merged.
|
|
16
|
+
|
|
17
|
+
1. Fork the repository and create a branch.
|
|
18
|
+
2. Make the change, with a test for it. Most features can be tested
|
|
19
|
+
against the mock BlueZ service in `tests/common` (no Bluetooth hardware
|
|
20
|
+
needed, only `dbus-daemon`).
|
|
21
|
+
3. Run:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
cargo fmt --all
|
|
25
|
+
cargo clippy --all-targets -- -D warnings
|
|
26
|
+
cargo test
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
4. For changes to what is sent to BlueZ, please also run the end-to-end
|
|
30
|
+
test between two virtual controllers (see "Testing" in the README).
|
|
31
|
+
5. Add a line to `CHANGELOG.md` for user-visible changes, and open the
|
|
32
|
+
pull request.
|
|
33
|
+
|
|
34
|
+
bluebus follows semantic versioning; `cargo semver-checks` should report no
|
|
35
|
+
breaking changes for a minor release.
|