From 2930b5049105084b762830801a4059f006d1d103 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Tue, 31 Aug 2021 12:52:49 +0100 Subject: [PATCH] Fix stats Hz to kHz conversion for Concentratord backend. --- .../backend/concentratord/concentratord.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/backend/concentratord/concentratord.go b/internal/backend/concentratord/concentratord.go index f271fd22..36d3742d 100644 --- a/internal/backend/concentratord/concentratord.go +++ b/internal/backend/concentratord/concentratord.go @@ -362,6 +362,7 @@ func (b *Backend) handleUplinkFrame(bb []byte) error { return nil } + // Hz to kHz loRaModInfo := pl.GetTxInfo().GetLoraModulationInfo() if loRaModInfo != nil { loRaModInfo.Bandwidth = loRaModInfo.Bandwidth / 1000 @@ -388,6 +389,24 @@ func (b *Backend) handleGatewayStats(bb []byte) error { var statsID uuid.UUID copy(statsID[:], pl.GetStatsId()) + // Hz to kHz + for i := range pl.RxPacketsPerModulation { + if mod := pl.RxPacketsPerModulation[i].GetModulation(); mod != nil { + if lora := mod.GetLora(); lora != nil { + lora.Bandwidth = lora.Bandwidth / 1000 + } + } + } + + // Hz to kHz + for i := range pl.TxPacketsPerModulation { + if mod := pl.TxPacketsPerModulation[i].GetModulation(); mod != nil { + if lora := mod.GetLora(); lora != nil { + lora.Bandwidth = lora.Bandwidth / 1000 + } + } + } + log.WithFields(log.Fields{ "stats_id": statsID, }).Info("backend/concentratord: stats event received")