Skip to content
Snippets Groups Projects
Commit dfe1db87 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Refactoring in progress

parent 13457112
Branches
Tags
No related merge requests found
package main package main
import ( import (
"log/slog"
"strings" "strings"
"gitlab.imt-atlantique.fr/xaal/code/go/core/uuid" "gitlab.imt-atlantique.fr/xaal/code/go/core/uuid"
...@@ -52,11 +51,3 @@ func newXAALDevices(gw *Gateway, zDev *Z2MDevice) { ...@@ -52,11 +51,3 @@ func newXAALDevices(gw *Gateway, zDev *Z2MDevice) {
} }
} }
} }
// updateXAALDevice updates a device
func updateXAALDevice(zDev *Z2MDevice, payload map[string]interface{}) {
slog.Info("Updating device:", "name", zDev.FriendlyName)
for _, dev := range zDev.XAALDevices {
dev.update(payload)
}
}
...@@ -97,7 +97,6 @@ func (zDev *Z2MDevice) Sync() { ...@@ -97,7 +97,6 @@ func (zDev *Z2MDevice) Sync() {
func (l AccessLevel) String() string { func (l AccessLevel) String() string {
return [...]string{"--", "R", "W", "RW", "Err", "RN", "Err", "RWN"}[l] return [...]string{"--", "R", "W", "RW", "Err", "RN", "Err", "RWN"}[l]
// return fmt.Sprintf("%d", l)
} }
func (l AccessLevel) EnumIndex() int { func (l AccessLevel) EnumIndex() int {
...@@ -154,7 +153,11 @@ func (zDev *Z2MDevice) HandleMessage(msg MQTT.Message) { ...@@ -154,7 +153,11 @@ func (zDev *Z2MDevice) HandleMessage(msg MQTT.Message) {
if err != nil { if err != nil {
slog.Error("Error decoding JSON", "err", err) slog.Error("Error decoding JSON", "err", err)
} else { } else {
updateXAALDevice(zDev, data) slog.Info("Updating device:", "name", zDev.FriendlyName)
for _, dev := range zDev.XAALDevices {
dev.update(data)
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment