disable logging in ttn
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2023-12-27 12:14:05 +01:00
parent 5e94782575
commit b6132afb11

View File

@ -2,7 +2,7 @@ package ttn
import (
"fmt"
"log"
//"log"
"time"
"encoding/json"
"udi/config"
@ -86,7 +86,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
}
func (self *TTNHandler) Handle(message handler.MessageT) {
log.Printf("Handler TTN %d processing %s -> %s", self.Id, message.Topic, message.Payload)
//log.Printf("Handler TTN %d processing %s -> %s", self.Id, message.Topic, message.Payload)
var measurement database.Measurement
measurement.Time = time.Now()
@ -97,7 +97,7 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
self.Lost("Error when unmarshaling message", err, message)
return
}
log.Printf("Parsed message: %s", uplinkMessage)
//log.Printf("Parsed message: %s", uplinkMessage)
var attributes attributes
attributes.DeviceId = uplinkMessage.EndDeviceIds.DeviceId
@ -107,11 +107,11 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
attributes.FrmPayload = uplinkMessage.UplinkMessage.FrmPayload
attributes.ConsumedAirtime = uplinkMessage.UplinkMessage.ConsumedAirtime
for _, rxm := range uplinkMessage.UplinkMessage.RxMetadata {
log.Printf("RXM: %s", rxm)
//log.Printf("RXM: %s", rxm)
g := gatewayAttributes { GatewayId: rxm.GatewayIds.GatewayId, Rssi: rxm.Rssi, Snr: rxm.Snr }
attributes.Gateways = append(attributes.Gateways, g)
}
log.Printf("Attributes: %s", attributes)
//log.Printf("Attributes: %s", attributes)
measurement.Attributes = map[string]interface{} {
"DeviceId": attributes.DeviceId,
"ApplicationId": attributes.ApplicationId,
@ -122,7 +122,7 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
"ConsumedAirtime": attributes.ConsumedAirtime,
}
log.Printf("ApplicationId: %s, DeviceId: %s", attributes.ApplicationId, attributes.DeviceId)
//log.Printf("ApplicationId: %s, DeviceId: %s", attributes.ApplicationId, attributes.DeviceId)
device, err2 := self.dbh.GetDeviceByLabelAndApplication(attributes.ApplicationId, attributes.DeviceId)
if err2 != nil {
self.Lost("Error when loading device", err2, message)
@ -132,7 +132,7 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
measurement.Device = attributes.DeviceId
measurement.Attributes["DeviceType"] = device.DeviceType.ModelIdentifier
log.Printf("DeviceLabel: %s, DeviceType: %s", device.Label, device.DeviceType.ModelIdentifier)
//log.Printf("DeviceLabel: %s, DeviceType: %s", device.Label, device.DeviceType.ModelIdentifier)
var parser func(int, []byte, string, *map[string]database.VariableType, *database.Device) error
switch device.DeviceType.ModelIdentifier {
@ -161,7 +161,7 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
self.Lost("Model parser failed", err3, message)
return
}
log.Printf("Prepared measurement item: %s", measurement)
//log.Printf("Prepared measurement item: %s", measurement)
self.dbh.StoreMeasurement(&measurement)
self.S()
}