Skip to content

Add unparse functions for DLL and ELL - #20

Merged
tudborg merged 2 commits into
mainfrom
tudborg/unparse-dll-and-ell
Jun 18, 2026
Merged

Add unparse functions for DLL and ELL#20
tudborg merged 2 commits into
mainfrom
tudborg/unparse-dll-and-ell

Conversation

@tudborg

@tudborg tudborg commented Jun 17, 2026

Copy link
Copy Markdown
Owner

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_ell to take input/output option sets and rebuild frames via new ELL.unparse/1 and DLL.unparse/1 flows.
  • Add encode/unparse support for ELL structures and WM-Bus DLL (plus identity encoding helpers).
  • Update/utilize tests for the new rekey_ell/3 behavior 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.

Comment thread lib/exmbus/parser/dll/wmbus.ex
Comment thread lib/exmbus/parser/ell.ex
Comment thread lib/exmbus/parser/dll/mbus.ex Outdated
Comment thread lib/exmbus/util.ex Outdated
Comment thread lib/exmbus/util.ex Outdated
@tudborg
tudborg force-pushed the tudborg/unparse-dll-and-ell branch from d5951ac to dffabf0 Compare June 18, 2026 08:09
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
tudborg force-pushed the tudborg/unparse-dll-and-ell branch from 4904520 to 1457925 Compare June 18, 2026 08:38
@tudborg
tudborg merged commit ac02c35 into main Jun 18, 2026
1 check passed
@tudborg
tudborg deleted the tudborg/unparse-dll-and-ell branch June 18, 2026 08:50
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.

2 participants