Skip to content

Conversation

@chrissuozzo
Copy link
Contributor

Issue
Closes #308

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! I love the idea of introducing a GattConnection type for simplifying the API. I've left some comments inline on what changes I'd like to see.

I think in general that we should the existing GattData, GattEvent, but move the attribute server specific 'process()' into the GattConnection and/or GattConnectionEvent, to keep supporting the 'direct reply' use case without the attribute server.

@chrissuozzo
Copy link
Contributor Author

Thanks for the feedback @lulf ! I think I've addressed everything. Two additional things have been tweaked:

  1. I realized that the connect() method is actually fallible if the connections_max parameter is not properly set, so this now returns a Result<(), Error> with a newly defined Error::ConnectionLimitReached. As such, GattConnection::new() -> Self is now GattConnection::try_new() -> Result<Self, Error> and with_attribute_server() returns the same.
  2. GattConnection::next() will now call-through to Connection::next() and process the GattData directly: so GattConnectionEvent::Gatt now wraps a Result<GattEvent, Error> instead of GattData. This makes the user code a little nicer (imo) and makes some sense, as when we are using a GattConnection we're putting the attribute server in charge of handling the protocol.

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks really good, thanks again @chrissuozzo!

@lulf
Copy link
Member

lulf commented Mar 5, 2025

/test

@lulf lulf merged commit cb8985e into embassy-rs:main Mar 5, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification issues

2 participants