-
Notifications
You must be signed in to change notification settings - Fork 26
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
Work on the Attribute module #99
base: main
Are you sure you want to change the base?
Conversation
@@ -24,45 +24,85 @@ pub const GENERIC_ATTRIBUTE_UUID16: Uuid = Uuid::Uuid16(0x1801u16.to_le_bytes()) | |||
|
|||
#[derive(Debug, Clone, Copy)] | |||
#[repr(u8)] | |||
/// An enum of possible characteristic properties | |||
/// | |||
/// Ref: BLUETOOTH CORE SPECIFICATION Version 6.0, Vol 3, Part G, Section 3.3.1.1 Characteristic Properties |
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 would like to propose this syntax for referencing Bluetooth core specification. This should help other devs cross reference things.
Oh, and I forgot to |
Next up I will try to document GattServer and stuff related to it. Then I will:
|
This doesn't give a big improvement in terms of LOC, but IMHO makes the code a lot more readable. I added docstrings where I could, but I might have missed some. Also, the AttributeTable now uses heapless::Vec instead of what was before. Should have no impact on the performance, since the previous implementation was basically the same. This also means that we have an actual iterator, so we can use for loops instead of while-next loops.
I have no idea how the |
I encountered similar error before, see #95 . But I'm not sure whether this is your case. There're some complex lifetime calculations. |
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.
Thanks for the PR! I've had a first look through it, but the general set of changes look good.
As for the lifetime issues, I think this is why I didn't use Vec originally, as it's lifetime would be shorter than the data that gets pushed to it which the compiler wouldn't accept. (Might be a way around it, maybe using some MaybeUninit trickery..)
#[repr(u8)] | ||
/// An enum of possible characteristic properties | ||
/// | ||
/// Ref: BLUETOOTH CORE SPECIFICATION Version 6.0, Vol 3, Part G, Section 3.3.1.1 Characteristic Properties |
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.
If we're going to refer to the speak, please use something like this, which makes it a lot easier to lookup and check:
https://github.com/embassy-rs/bt-hci/blob/main/src/event/le.rs#L182
pub struct Attribute<'d> { | ||
/// Attribute type UUID | ||
/// | ||
/// Do not mistake it with Characteristic UUID |
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'm not sure if this is entirely correct, every characteristic has a UUID, but there are different types, like the characteristic declaration or the characteristic value. This UUID can be either.
}, | ||
/// Last handle value in the group | ||
/// | ||
/// When a [`ServiceBuilder`] finishes building, it returns the handle for the service, but also |
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.
Sentence ends prematurely.
@@ -1,7 +1,7 @@ | |||
use crate::codec::{Decode, Encode, Error, Type}; | |||
|
|||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | |||
#[derive(Debug, PartialEq, Clone)] | |||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] |
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'd rather keep the uuid not Copy if possible, as it can easily explode memory usage if copied uncritically throughout the usage.
Currently a draft, any comments are welcome!