Skip to content

Commit

Permalink
refactor: change api and support varying scan buffer sizes (#241)
Browse files Browse the repository at this point in the history
* refactor: change api and support varying scan buffer sizes

* Add Scanner type which wraps the central to provide scan features
* Make scanner buffer configurable size in order to handle large number
  of reports.
* Only add valid advertising reports to scan buffer.
  • Loading branch information
lulf authored Jan 16, 2025
1 parent 3f63c23 commit a447556
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 378 deletions.
2 changes: 1 addition & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ cargo batch \

cargo fmt --check --manifest-path ./host/Cargo.toml
cargo clippy --manifest-path ./host/Cargo.toml --features gatt,peripheral,central
cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture
cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture
4 changes: 2 additions & 2 deletions examples/esp32/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/nrf-sdc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 8 additions & 31 deletions examples/rp-pico-2-w/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ edition = "2021"
resolver = "2"

[dependencies]
embassy-executor = { version = "0.6.1", default-features = false, features = ["task-arena-size-98304", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
embassy-time = { version = "0.4.0", default-features = false, features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.2.0", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info"] }
embassy-executor = { version = "0.7", default-features = false, features = ["task-arena-size-98304", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
embassy-time = { version = "0.4", default-features = false, features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.3", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info"] }
embassy-futures = "0.1.1"
embassy-sync = { version = "0.6.1", features = ["defmt"] }
embassy-sync = { version = "0.6", features = ["defmt"] }

futures = { version = "0.3", default-features = false, features = ["async-await"]}
bt-hci = { version = "0.2.0", default-features = false, features = ["defmt"] }
trouble-example-apps= { version = "0.1.0", path = "../apps", features = ["defmt"] }
cyw43 = { version = "0.2.0", features = ["defmt", "firmware-logs", "bluetooth"] }
cyw43-pio = { version = "0.2.0", features = ["defmt"] }
cyw43 = { version = "0.3", features = ["defmt", "firmware-logs", "bluetooth"] }
cyw43-pio = { version = "0.3", features = ["defmt"] }

defmt = "0.3"
defmt-rtt = "0.4.0"

cortex-m = { version = "0.7.6" }
cortex-m-rt = "0.7.0"
cortex-m = { version = "0.7" }
cortex-m-rt = "0.7"
panic-probe = { version = "0.3", features = ["print-defmt"] }
static_cell = "2"
portable-atomic = { version = "1.5", features = ["critical-section"] }
Expand All @@ -34,26 +34,3 @@ skip-cyw43-firmware = []

[profile.release]
debug = 2

[patch.crates-io]
embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-rp = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-futures = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
cyw43 = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }
cyw43-pio = { git = "https://github.com/embassy-rs/embassy.git", rev = "e68efc2d7cdea195aec112ecb61231e148a282c2" }

#embassy-executor = {path = "../../../embassy/embassy-executor"}
#embassy-nrf = {path = "../../../embassy/embassy-nrf"}
#embassy-sync = {path = "../../../embassy/embassy-sync"}
#embassy-futures = {path = "../../../embassy/embassy-futures"}
#embassy-time = {path = "../../../embassy/embassy-time"}
#embassy-time-driver = {path = "../../../embassy/embassy-time-driver"}
#embassy-embedded-hal = {path = "../../../embassy/embassy-embedded-hal"}
#embassy-hal-internal = {path = "../../../embassy/embassy-hal-internal"}
#nrf-sdc = { path = "../../../nrf-sdc/nrf-sdc" }
#nrf-mpsl = { path = "../../../nrf-sdc/nrf-mpsl" }
#bt-hci = { path = "../../../bt-hci" }
4 changes: 2 additions & 2 deletions examples/rp-pico-w/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/serial-hci/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/serial-hci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
env_logger = "0.10.0"
log = "0.4"
embedded-io-adapters = { version = "0.6.1", features = ["tokio-1"] }
embassy-sync = { version = "0.6.0", features = ["log"] }
embassy-sync = { version = "0.6", features = ["log"] }
embassy-time = { version = "0.4", features = ["log", "std", "generic-queue-8"] }
critical-section = { version = "1.1", features = ["std"] }
tokio = { version = "1", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resolver = "2"
[dependencies]
bt-hci = { version = "0.2", features = ["embassy-time", "uuid"] }
embedded-io = { version = "0.6" }
embassy-sync = "0.6"
embassy-sync = "0.6.2"
embassy-time = "0.4"
embassy-futures = "0.1"
futures = { version = "0.3", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions host/src/advertise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ pub struct AdStructureIter<'d> {
impl<'d> AdStructureIter<'d> {
fn read(&mut self) -> Result<AdStructure<'d>, codec::Error> {
let len: u8 = self.cursor.read()?;
if len < 2 {
return Err(codec::Error::InvalidValue);
}
let code: u8 = self.cursor.read()?;
let data = self.cursor.slice(len as usize - 1)?;
match code {
Expand Down
Loading

0 comments on commit a447556

Please sign in to comment.