Skip to content

Commit

Permalink
Added missing DPT
Browse files Browse the repository at this point in the history
  • Loading branch information
mobilarte committed Apr 4, 2024
1 parent a683fb7 commit 8c23a7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion knx/dpt/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions knx/dpt/types_registry.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8c23a7a

Please sign in to comment.