From 3999c7ee93b5324a035e4cb42fecc86719bdb87a Mon Sep 17 00:00:00 2001 From: Frostie314159 <83869240+Frostie314159@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:28:50 +0100 Subject: [PATCH 1/6] Adding workflow again. --- .github/workflows/rust.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..6259302 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,27 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup + run: | + sudo apt install -y bluez libbluetooth-dev + sudo sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service + sudo systemctl daemon-reload + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose From d46fc5818ba6fc6745cc360ecdef2238d9ddd037 Mon Sep 17 00:00:00 2001 From: Frostie314159 Date: Thu, 29 Dec 2022 05:43:44 +0100 Subject: [PATCH 2/6] Added dbus to action. --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6259302..24ea71b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup run: | - sudo apt install -y bluez libbluetooth-dev + sudo apt install -y bluez libbluetooth-dev dbus sudo sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service sudo systemctl daemon-reload - name: Build From 0932d194f3037daaee1e2baa775226672a07f977 Mon Sep 17 00:00:00 2001 From: Frostie314159 Date: Thu, 29 Dec 2022 05:49:08 +0100 Subject: [PATCH 3/6] Added libdbus-1-dev to action. --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 24ea71b..de6371e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup run: | - sudo apt install -y bluez libbluetooth-dev dbus + sudo apt install -y bluez libbluetooth-dev dbus libdbus-1-dev sudo sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service sudo systemctl daemon-reload - name: Build From f83e38a52b4da7855d675c05ed9532c3439e0a13 Mon Sep 17 00:00:00 2001 From: Frostie314159 Date: Thu, 29 Dec 2022 06:01:35 +0100 Subject: [PATCH 4/6] Switched actions rust-channel to nightly. --- .github/workflows/rust.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index de6371e..600b1e9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,7 +13,9 @@ jobs: build: runs-on: ubuntu-latest - + strategy: + matrix: + rust-channel: [ 'nightly' ] steps: - uses: actions/checkout@v3 - name: Setup From 2252b59970510616205c0dfce235649de9d266f2 Mon Sep 17 00:00:00 2001 From: Frostie314159 Date: Thu, 29 Dec 2022 06:48:17 +0100 Subject: [PATCH 5/6] Fixed compilation error. --- .github/workflows/rust.yml | 3 --- Cargo.toml | 4 ++-- src/advertisement.rs | 6 +++--- src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 600b1e9..1c5eefd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,9 +13,6 @@ jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - rust-channel: [ 'nightly' ] steps: - uses: actions/checkout@v3 - name: Setup diff --git a/Cargo.toml b/Cargo.toml index 72d1034..7e26fb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ bluer = { version = "0.15.3", features = [ ] } config = "0.13.2" tokio = { version = "1.22.0", features = ["full"] } -async-trait = { version = "0.1.58", optional = true } +async-trait = "0.1.58" sha2 = "0.10.6" uuid = { version = "1.2.2", features = ["v4"] } sudo = "0.6.0" @@ -27,7 +27,7 @@ clap = { version = "4.0.29", optional = true } [features] default = [] # AFIT = async_fn_in_trait -disable_afit = ["dep:async-trait"] +enable_afit = [] cli = ["dep:clap"] [[bin]] diff --git a/src/advertisement.rs b/src/advertisement.rs index cf49bb6..485b4be 100644 --- a/src/advertisement.rs +++ b/src/advertisement.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use std::net::{Ipv4Addr, Ipv6Addr}; use std::{collections::BTreeMap, error::Error, time::Duration}; -#[cfg(feature = "disable_afit")] +#[cfg(not(feature = "disable_afit"))] use async_trait::async_trait; use bluer::adv::{Advertisement, AdvertisementHandle, Type}; use bluer::{Device, Address}; @@ -13,12 +13,12 @@ use crate::util::set_device_addr; const APPLE_MAGIC: u16 = 0x4c; -pub trait AdvertisableData: Clone + PartialEq + Debug { +pub trait AdvertisableData: Clone + PartialEq + Debug + Sync { fn octets(&self) -> Vec; } // If the user opted out of using "async_fn_in_trait", use the crate async-trait instead. -#[cfg_attr(feature = "disable_afit", async_trait)] +#[cfg_attr(not(feature = "disable_afit"), async_trait)] /// Any kind of advertisement. pub trait Advertisable { /// Advertisement-specific: validate user supplied data. diff --git a/src/lib.rs b/src/lib.rs index f34a289..a2a3671 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![allow(incomplete_features)] // opt-out of using the unstable feature "async_fn_in_trait". See https://github.com/rust-lang/rust/issues/91611. -#![cfg_attr(not(feature = "disable_afit"), feature(async_fn_in_trait))] +#![cfg_attr(feature = "enable_afit", feature(async_fn_in_trait))] mod util; pub mod advertisement; pub mod session; \ No newline at end of file From 66c5dc532febb5d703719bf97bcee622b44c9de6 Mon Sep 17 00:00:00 2001 From: Frostie314159 Date: Thu, 19 Jan 2023 19:03:20 +0100 Subject: [PATCH 6/6] Reexported bluer. --- Cargo.lock | 2 +- Cargo.toml | 2 +- Dockerfile | 7 +++++++ src/lib.rs | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/Cargo.lock b/Cargo.lock index e1f85b6..42661ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ dependencies = [ [[package]] name = "apple-ble" -version = "0.2.1" +version = "0.2.2" dependencies = [ "async-trait", "bluer", diff --git a/Cargo.toml b/Cargo.toml index 7e26fb6..12ae853 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apple-ble" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "A library for interfacing with apple devices via BLE." license = "MIT AND Apache-2.0" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd5dffe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM rust:1.66 + +RUN apt-get update +RUN apt-get install -y bluez libbluetooth-dev dbus libdbus-1-dev +RUN sed 's/^\(ExecStart.*\)/\1 --enable-testing/' /etc/systemd/system/bluetooth.target.wants/bluetooth.service + +COPY . . diff --git a/src/lib.rs b/src/lib.rs index a2a3671..cd9950d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,4 +3,5 @@ #![cfg_attr(feature = "enable_afit", feature(async_fn_in_trait))] mod util; pub mod advertisement; -pub mod session; \ No newline at end of file +pub mod session; +pub use bluer; \ No newline at end of file