Add unparse functions for DLL and ELL - #20
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends Exmbus’ ability to reconstruct (unparse) WM-Bus frames by adding unparse/encode functions for ELL and DLL layers, and refactors Exmbus.Util.rekey_ell/3 to re-encrypt and rebuild frames (including optionally swapping the identification number during rekeying). It also adjusts WM-Bus length handling to avoid mutating the :length option in the parse context.
Changes:
- Refactor
Exmbus.Util.rekey_ellto take input/output option sets and rebuild frames via newELL.unparse/1andDLL.unparse/1flows. - Add encode/unparse support for ELL structures and WM-Bus DLL (plus identity encoding helpers).
- Update/utilize tests for the new
rekey_ell/3behavior and identification number swapping.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/util_test.exs | Updates tests to exercise rekey_ell/3, including identification swapping and optional length output. |
| lib/exmbus/util.ex | Refactors rekey_ell to parse → decrypt → mutate → encrypt → unparse, enabling identification swap and length output changes. |
| lib/exmbus/parser/identity.ex | Adds encode/1 to serialize identity blocks used by ELL receiver addressing. |
| lib/exmbus/parser/ell/unencrypted_with_receiver.ex | Adds encode/1 for the “unencrypted with receiver” ELL variant. |
| lib/exmbus/parser/ell.ex | Adds unparse/1 for ELL variants to prepend ELL headers back onto ctx.bin. |
| lib/exmbus/parser/dll/wmbus.ex | Refactors length handling, adds unparse/1, and introduces C-field encoding for WM-Bus DLL reconstruction. |
| lib/exmbus/parser/dll/mbus.ex | Adds an unparse/1 stub for M-Bus (currently raises). |
| lib/exmbus/parser/dll.ex | Adds unparse/1 routing to DLL-specific unparse implementations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tudborg
force-pushed
the
tudborg/unparse-dll-and-ell
branch
from
June 18, 2026 08:09
d5951ac to
dffabf0
Compare
This also adds ability to swap out the identification number when rekeying ELL. This also changes wmbus parsing length field checks such that it doesn't mutate the context length option. This also allows FormatFrame to/from header bytes (for storage)
tudborg
force-pushed
the
tudborg/unparse-dll-and-ell
branch
from
June 18, 2026 08:38
4904520 to
1457925
Compare
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.
This also adds ability to swap out the identification number when rekeying ELL.
This also changes wmbus parsing length field checks such that it doesn't mutate the context length option.
Skipped mbus unparsing for now, until I have a test case for it.