feat(052): runtime-neutral KNX connector - #252
Open
lxsaah wants to merge 4 commits into
Open
Conversation
- Updated the KNX connector usage in examples and tests to utilize the new `KnxConnector::tokio` method instead of the deprecated `KnxConnector::new`. - Removed the `tokio_client.rs` file as it is no longer needed with the new connector structure. - Adjusted the `lib.rs` file to reflect the new connector organization and removed platform-specific implementations. - Updated tests to ensure compatibility with the new connector API. - Added static buffers and channels for the Embassy adapter in the embassy example.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wave B of design 052, third and last connector. The adapter owns the UDP socket and the clock; this crate owns the tunnelling protocol.
tokio_client.rs(632) andembassy_client.rs(473) are gone, along with the wholeTokio*/Embassy*alias set. OneKnxConnector<B, D, N>wires both runtimes onto theclient::connection_taskthat landed in wave A.With this, all three connectors carry zero runtime modules and zero
unsafe impls.Breaking
KnxConnector::new(binder, delay, gateway_url, &CHANNELS)— generic over core'sDatagramBinderandDelay.KnxConnector::tokio(gateway_url)on a host: supplies the Tokio transports and its channels, so a caller needs only the URL.with_command_queue_sizebecomes the const genericN. Anembassy_sync::Channelis sized at compile time — an MCU allocates it in astatic, where the size must be a constant.KnxConnectorBuilder,KnxConnectorImpland theTokio*/Embassy*aliases are gone.Updated in-tree:
aimdb-codegen, both KNX demos, andtopic_provider_tests.Worth a look in review
The channels are a caller-supplied
&'static Channels<N>. Both the connection task and the pumps are spawned as'staticfutures, so the channels must outlive the connector. An MCU supplies them from aStaticCell;KnxConnector::tokioleaks one pair at build — bounded, once per process, matching design 037's allocate-at-build model, but a deliberate leak worth seeing.D1 moved into this PR.
codegen-driftruns inmake check, andaimdb-codegenemittedKnxConnector::new(&knx_gateway)— a signature that no longer exists.KnxConnector::tokioexists so the generated line stays one call rather than adapter types plus astatic; codegen changed by one word and no re-baseline was needed (✓ Codegen output compiles against the workspace).aimdb-tokio-adapterbecomes atokio-runtimedependency, the same relaxation taken for the serial connector — the adapter owns the datagram socket on both runtimes rather than the connector duplicating it.Two adapter binders gained
Clone.TokioUdpBinderandEmbassyUdpBindercould not be held by aConnectorBuilder, which clones its transport per build. That is the third wave-A type to need this after the TCP dialers — the traits were right, but their composition into a builder was untested. Worth a compile-time assertion in core.Verification
make checkclean: 2 017 tests, 0 failures, all stages includingcodegen-drift.Note
Touches
examples/embassy-knx-connector-demo/src/main.rs, which #251 also edits (itsSerialServerline). Whichever merges second needs a rebase there.