This commit is contained in:
@ -19,7 +19,7 @@ type Z2MHandler struct {
|
||||
dbh *database.DatabaseHandle
|
||||
}
|
||||
|
||||
func parse(T any, payload string, variables *map[string]database.VariableType, attributes *map[string]interface{}) error {
|
||||
func parse(T any, payload string, variables *map[string]database.VariableType) error {
|
||||
observationType := reflect.TypeOf(T)
|
||||
observation := reflect.New(observationType).Interface()
|
||||
|
||||
@ -44,7 +44,6 @@ func parse(T any, payload string, variables *map[string]database.VariableType, a
|
||||
}
|
||||
}
|
||||
|
||||
(*attributes)["Status"] = "ok"
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -90,12 +89,15 @@ func (self *Z2MHandler) Handle(message handler.MessageT) {
|
||||
measurement.Attributes = make(map[string]interface{})
|
||||
err3 := parse(T,
|
||||
message.Payload,
|
||||
&(measurement.Values),
|
||||
&(measurement.Attributes))
|
||||
&(measurement.Values))
|
||||
if err3 != nil {
|
||||
self.Lost("Model parser failed", err3, message)
|
||||
return
|
||||
}
|
||||
|
||||
measurement.Attributes["Status"] = "ok"
|
||||
measurement.Attributes["DeviceId"] = deviceId
|
||||
measurement.Attributes["DeviceModel"] = device.DeviceType.ModelIdentifier
|
||||
log.Printf("Prepared measurement item: %s", measurement)
|
||||
self.dbh.StoreMeasurement(&measurement)
|
||||
self.S()
|
||||
|
Reference in New Issue
Block a user