-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add support for L2CAP and refactor state management #32
Conversation
Signed-off-by: Ryan Tate <[email protected]>
Signed-off-by: Ryan Tate <[email protected]>
Signed-off-by: Ryan Tate <[email protected]>
Signed-off-by: Ryan Tate <[email protected]>
Signed-off-by: Ryan Tate <[email protected]>
Not sure how it was checked out as it is in .gitignore
This is a fairly large change; both the holder and the reader have been extended to support L2CAP. In service of this, the original flow has been refactored into more explicit state machines, and the L2CAP flow has been added to those state machines. Both the reader and holder have `useL2CAP` booleans; if either is `false`, the reader and holder will use the old flow to communicate. This should also mean that they will use the old flow when working with other readers or holders that do not support L2CAP. Some of this work (notably the `*Connection.swift` files) is derived from Paul Wilkinson's MIT-licensed L2Cap library: https://github.com/paulw11/L2Cap This repo is MIT-licensed as well, so the licenses are compatable. We aren't using the L2Cap library as-is for a variety of reasons, but the main reason is that the behaviour we need differs significantly from the behaviour L2Cap (the library) offers. There are a couple of places in this change that are hacking around impedence mismatches: - we seem to need to have `notify` on the L2CAP characteristic in order to propagate the PSM to central, though 18013-5 Annex A claims the only required property is `read` -- we're not out of spec, since we're offering an optional property, but it remains to be seen how that will interact with 3rd party centrals - 18013-5 specifies no framing for the request or response sent over the L2CAP stream, so we have to infer when the data has arrived from timing; this seems like a fragile method particularly if confronted by noisy radio environments
This needs an up-to-date version of |
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.
+1 for the use of an internal state machine!
Additional comments:
- Could you rebase your branch on the latest
main
to get rid of the commits from Add MDoc Reader support #22? - It looks like you ran
swift-format
on the codebase. Currently, we're usingSwiftLint
and it's unclear to me whether they can be used together, but after a quick test it looks like their default settings are incompatible. Regardless, I'm open to switching toswift-format
but it would need to happen in a separate PR and added to the CI. - Your mention of PSM reminded me of this project https://github.com/openwallet-foundation-labs/identity-credential (PR from a while ago, do you think you could look into it and see if we could test our implementation against it?
- Did you test the GATT flow to make sure it didn't break?
I'm doing that now.
I thought we were using swift-format, so I ran it, but it is quite invasive; it doesn't just change the layout, it also makes syntactic changes. I'm not advocating for its use.
I'll look into it.
I did; that's why there are the two |
iOS reader/holder now support L2CAP.
This is a fairly large change; both the holder and the reader have been extended to support L2CAP. In service of this, the original flow has been refactored into more explicit state machines, and the L2CAP flow has been added to those state machines.
Both the reader and holder have
useL2CAP
booleans; if either isfalse
, the reader and holder will use the old flow to communicate. This should also mean that they will use the old flow when working with other readers or holders that do not support L2CAP.Some of this work (notably the
*Connection.swift
files) is derived from Paul Wilkinson's MIT-licensed L2Cap library:https://github.com/paulw11/L2Cap
This repo is MIT-licensed as well, so the licenses are compatible.
We aren't using the L2Cap library as-is for a variety of reasons, but the main reason is that the behaviour we need differs significantly from the behaviour L2Cap (the library) offers.
There are a couple of places in this change that are hacking around impedance mismatches:
we seem to need to have
notify
on the L2CAP characteristic in order to propagate the PSM to central, though 18013-5 Annex A claims the only required property isread
-- we're not out of spec, since we're offering an optional property, but it remains to be seen how that will interact with 3rd party centrals18013-5 specifies no framing for the request or response sent over the L2CAP stream, so we have to infer when the data has arrived from timing; this seems like a fragile method particularly if confronted by noisy radio environments