-
Notifications
You must be signed in to change notification settings - Fork 77
Typos and some other things... #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ci.sh
Outdated
cargo +nightly fmt --check --manifest-path ./host/Cargo.toml | ||
cargo +nightly fmt --check --manifest-path ./host-macros/Cargo.toml | ||
|
||
cargo clippy --manifest-path ./host/Cargo.toml --features central,gatt,peripheral,scan,security |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting to raise these above the cargo batch
stuff. Reasoning: when people make changes, we often (?) don't run the cargo fmt
. Running these commands doesn't require any downloads, unlike the rest of the CI steps.
Added +nightly
. It doesn't harm on the CI (where nightly already is), but it makes the command more copy-pasteable for us users. Serves as a documentation that yes, cargo fmt
needs nightly, in this repo.
Added features to clippy
. The intention is that it's run with all features, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that didn't work out:
error: 'cargo-fmt' is not installed for the toolchain 'nightly-x86_64-unknown-linux-gnu'.
https://github.com/embassy-rs/trouble/actions/runs/18328070279/job/52197152861
ci.sh
Outdated
|
||
# Running tests requires some hardware, so we just check they compile. | ||
cargo test --manifest-path ./host/Cargo.toml --features central,gatt,peripheral,scan,security --no-run | ||
cargo test --manifest-path ./examples/tests/Cargo.toml --no-run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things going on here.. and the diff isn't too clear because lines moved to the top.
This helps:
-cargo test --manifest-path ./host/Cargo.toml --lib -- --nocapture
-cargo test --manifest-path ./host/Cargo.toml --no-run -- --nocapture
-cargo test --manifest-path ./examples/tests/Cargo.toml --no-run -- --nocapture
+cargo test --manifest-path ./host/Cargo.toml --features central,gatt,peripheral,scan,security --lib -- --nocapture
+
+# Running tests requires some hardware, so we just check they compile.
+cargo test --manifest-path ./host/Cargo.toml --features central,gatt,peripheral,scan,security --no-run
+cargo test --manifest-path ./examples/tests/Cargo.toml --no-run
- Added
features
to the testlib
run. This exposes tests that were dormant before. - Removed
-- --nocapture
from the--no-run
's. It's not needed there, since those lines only compile, don't run, and-- --nocapture
only affects execution of crates, I believe. - Added features to the
--no-run
's, as well. This means all tests get compiled, by the CI.
embassy-futures = "0.1.1" | ||
embassy-sync = { version = "0.7" } | ||
embassy-time = "0.5" | ||
#embedded-hal = "1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such comments were intended to be removed, before merging, in an earlier PR. Now's a good time.
#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"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, and below, I decided to prune the Cargo.toml
's a bit, without fully understanding what's going on.
If there's a comment, refering to a crate that's not in the [dependencies]
, such a comment may be stale, and can be let go. Note: there may be some reason that, say, embassy-time-driver
should remain here. I don't know. Only familiar with the ESP32 targets.
#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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. bt-hci
was not mentioned, otherwise, and nrf-*
within a rp-pico-...
file feel like a copy/paste.
host-macros/src/uuid.rs
Outdated
use syn::{parse::Result, spanned::Spanned, Expr}; | ||
use syn::parse::Result; | ||
use syn::spanned::Spanned; | ||
use syn::Expr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, cargo fmt
in CI was not applied to host-macros
. If it is, this needs to be reformatted.
heapless = "0.9" # "gatt", "security" need it | ||
trouble-host-macros = { path = "../host-macros", version = "0.3.0", optional = true } | ||
p256 = { version = "0.13.2", default-features = false, features = ["ecdh","arithmetic"], optional = true } | ||
rand = { version="0.8", default-features = false, optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. here I seem to have just moved the line above the rand_...
ones.
Most dependencies seem to be in alphabetical order, which I find very welcome. That's why. Can move back.
host/src/attribute_server.rs
Outdated
att_table: AttributeTable<'values, M, ATT_MAX>, | ||
cccd_tables: CccdTables<M, CCCD_MAX, CONN_MAX>, | ||
_p: PhantomData<P>, | ||
_p: PhantomData<P>, // Q: may we have a comment on the use of this? Ties 'PacketPool', somehow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to a journey I had, trying to understand the DefaultPacketPool
system.
I then decided it's not worth it.
//"last_handle_in_group for 0x{:0>4x?}, 0x{:0>2x?} 0x{:0>2x?}", // "Unknown display hint: '0>4x?' by IDE; does this not get tested? #TEMP | ||
trace!( | ||
"last_handle_in_group for 0x{:0>4x?}, 0x{:0>2x?} 0x{:0>2x?}", | ||
"last_handle_in_group for 0x{:04x}, 0x{:02x} 0x{:02x}", // not sure which is the intended format, here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My IDE (Rust Rover) showed:
Unknown display hint: '0>4x?'
It seems that's indeed an invalid combination (asked Copilot). What is the intended output - what should be here?
Also, shouldn't CI or something pick this up? I'm confused, please help. O:)
let response = &buffer[0..length]; | ||
#[cfg(false)] // bad format | ||
trace!(" 0x{:0>2x?}", response); | ||
trace!(" 0x{:02x}", response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..here, too
debug!("[l2cap][conn = {:?}] connection param update request: {:?}", conn, req); | ||
let interval_min: bt_hci::param::Duration<1_250> = bt_hci::param::Duration::from_u16(req.interval_min); | ||
let interva_max: bt_hci::param::Duration<1_250> = bt_hci::param::Duration::from_u16(req.interval_max); | ||
let interval_max: bt_hci::param::Duration<1_250> = bt_hci::param::Duration::from_u16(req.interval_max); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's interesting. It's a typo in a variable name. Now..
- the variable is not used, so it never mattered
- should the variable be used, see next diff
Kindly, it would also be great if unused variables were reported. Have I missed something - didn't get anything on the IDE or the CI output. What's really going on?
conn, | ||
ConnectionEvent::RequestConnectionParams { | ||
min_connection_interval: Duration::from_micros(interval_min.as_micros()), | ||
max_connection_interval: Duration::from_micros(interval_min.as_micros()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interval_min
used for both min and max - is that the intention, too?
+ ControllerCmdSync<LeSetScanEnable> | ||
+ ControllerCmdSync<LeSetExtScanEnable> | ||
+ for<'t> ControllerCmdSync<LeSetAdvEnable> | ||
+ ControllerCmdSync<LeSetAdvEnable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I belive, but am not 100% sure, that the for<'t>
is a no-op when 't
is not used on the same element.
host/src/scan.rs
Outdated
None | ||
} else { | ||
Some(Instant::now() + config.timeout.into()) | ||
Some(Instant::now() + config.timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flagged as unnecessary by - I think - clippy, due to the added features
in CI checks
|
||
/// Long duration, to disable the timer | ||
pub(crate) const TIMEOUT_DISABLE: Duration = Duration::from_secs(3600 * 24 * 365 * 10); // ~10 years | ||
// Workaround for Duration multiplication not being const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just cleanup. The const was used only as Instant::now() + ...
to get a time stamp far, far in the future. For this, we can use Instant::MAX
just as well.
host/src/security_manager/mod.rs
Outdated
.as_ref() | ||
.map(|x| x.timeout_at()) | ||
.unwrap_or(Instant::now() + constants::TIMEOUT_DISABLE); | ||
.unwrap_or(Instant::MAX /*no timeout*/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..here is one of the Instant::MAX
positions.
Should I remove the /*no timeout*
- it's kind of obvious.
//! Common types. | ||
/// Traits for conversion between types and their GATT representations | ||
#[cfg(feature = "gatt")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemed like we can make that conditional. I'm not trying to be meticulous about feature use, but it's generally pleasant not to need to see things (types, in this case) that's don't have to do with my app's setup.
It was a pleasure to make this PR. Hope you appreciate it as a mixed-bag approach... My main focus is in trying to learn the code, and make apps using BLE.
7b2fe87
to
e2627fd
Compare
This started when I was reading the sources and spotted some typos. Turns out, the IDE can find them all - so I did!
In the mean time, there are also other areas of improvement; this is a mixed bag kind of on purpose.
Some, few but some, places may indicate bugs, so please someone check out my comments before pushing this further.