-
Notifications
You must be signed in to change notification settings - Fork 32
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
Implement async GATT event processing #200
Conversation
/test |
This looks much neater! |
/test |
Glad you like it! So, the options are now:
I think that covers most of it. It does feel a bit strange to pass the attribute server around perhaps, but I don't see any different solution that allows supporting no attribute server use cases. |
/test |
1 similar comment
/test |
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.
Love the new API, very clean! Nice to remove the extra layer of server()
indirection as well 👍
host-macros/src/server.rs
Outdated
self.server.table().set(characteristic, input) | ||
} | ||
|
||
#visibility fn deref(&self) -> &AttributeServer<'values, #mutex_type, _ATTRIBUTE_TABLE_SIZE> { |
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.
With the implementation of the Deref trait below you shouldn't need this method I think
} | ||
|
||
pub(crate) async fn send(&self, index: u8, pdu: Pdu<'d>) { | ||
let handle = self.with_mut(|state| state.connections[index as usize].handle.unwrap()); |
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.
Investigating why handle is an Option<>
type led me down a bit of a rabbit hole, but I can see now that when a "slot" in the connection storage is empty then its handle will be None
.
Obviously this is unrelated to this PR, but is there a reason for having the storage as type [ConnectionStorage; N]
which is initially filled with [ConnectionStorage::DISCONNECTED; N]
as opposed to making the storage of type [Option<ConnectionStorage>; N]
, so that when the slot is empty it just contains None
?
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.
It has some implications on stack/RAM usage because now you'd need to create a "big" ConnectionStorage when allocing, rather than just modifying one field. It's a while ago, so I don't have the numbers.
But it could be worth trying again, and measuring size change.
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.
Interesting, I'd have expected the compiler to optimise to modify-in-place if the array already exists, but maybe I'm not fully grasping the way it's used.
another thorough review from @petekubiak 🎸 |
I get easily carried away haha |
* Remove GattServer, processing now per connection * Allow processing GATT requests without attribute server * Allow processing GATT events before attribute server * Remove on_read, on_write callback
/test |
/test |
Issue #133, #163
Still very WIP, but the example should show what this will look like.
CC @jamessizeland, @petekubiak