From 8c23a7a42d4edf8e39141a8ae2a577ad7b977904 Mon Sep 17 00:00:00 2001 From: mobilarte Date: Thu, 4 Apr 2024 02:25:19 +0200 Subject: [PATCH] Added missing DPT --- knx/dpt/types.go | 2 +- knx/dpt/types_registry.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/knx/dpt/types.go b/knx/dpt/types.go index 0292204..b92ef76 100644 --- a/knx/dpt/types.go +++ b/knx/dpt/types.go @@ -17,7 +17,7 @@ type DatapointValue interface { Unpack(data []byte) error } -// DatapointMeta gives meta information about a datapoint type. +// DatapointMeta gives meta information about a datapoint. type DatapointMeta interface { // Unit returns the unit of this datapoint type or empty string if it doesn't have a unit. Unit() string diff --git a/knx/dpt/types_registry.go b/knx/dpt/types_registry.go index 07a9596..77ed024 100644 --- a/knx/dpt/types_registry.go +++ b/knx/dpt/types_registry.go @@ -1,5 +1,5 @@ // Copyright 2020 Sven Rebhan. -// Copyright 2022 Martin Müller. +// Copyright 2024 Martin Müller. // Licensed under the MIT license which can be found in the LICENSE file. package dpt @@ -29,6 +29,9 @@ var dptTypes = map[string]Datapoint{ "1.017": new(DPT_1017), "1.018": new(DPT_1018), "1.019": new(DPT_1019), + "1.021": new(DPT_1021), + "1.022": new(DPT_1022), + "1.023": new(DPT_1023), "1.024": new(DPT_1024), "1.100": new(DPT_1100), @@ -255,10 +258,12 @@ func ListSupportedTypes() []string { return keys } -// Produce returns an uninitialized instance of the given datapoint name, e.g. "1.001". +// Produce returns an uninitialized instance, given the exact datapoint name. +// It returns a DPT_1001 for "1.001". func Produce(name string) (d Datapoint, ok bool) { // Lookup the given type and return a datapoint of that type. x, ok := dptTypes[name] + if ok { d_type := reflect.TypeOf(x).Elem() d = reflect.New(d_type).Interface().(Datapoint)