Skip to content

Export dptlib#18

Open
evekto wants to merge 3 commits intoekarak:masterfrom
evekto:feature/export-dptlib
Open

Export dptlib#18
evekto wants to merge 3 commits intoekarak:masterfrom
evekto:feature/export-dptlib

Conversation

@evekto
Copy link

@evekto evekto commented Feb 5, 2026

This PR has 2 goals:

  • Remove dynamic imports so it's easier to integrate this lib into bundler-setups
  • Export dptlib so that binary KNX data can be encoded and decoded directly with buffers

Changes to the code are kept to a minimun, so that usage may not be very convenient but it works:

import { dptlib } from "knx";

const subtype = dptlib.DPT5.subtypes['001'];
const value = dptlib.fromBuffer(Buffer.from([0xff]), dptlib.DPT5, subtype)
console.log('decoded:', value, subtype.unit);

const apdu = {};
dptlib.populateAPDU(100, apdu, "DPT5.001")
console.log('encoded:', apdu.data);

This allows the library to be used in bundlers without friction.
This allows to parsing byte-arrays according to DPTs
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.

1 participant