brocaar / chirpstack-network-server

ChirpStack Network Server is an open-source LoRaWAN network-server.
https://www.chirpstack.io
MIT License
1.48k stars 545 forks source link

Uplink history initialization problem #587

Closed HyeonHo-Jung closed 2 years ago

HyeonHo-Jung commented 2 years ago

Hello

I was looking through the ADR code and had a question.

Here is the getMaxSNR function part in the code of path "chirpstack-network-server/internal/adr/default.go"

I was able to check the contents by putting the fmt.Println(m.MaxSNR) function.

func (h *DefaultHandler) getMaxSNR(req adr.HandleRequest) float32 { var snrM float32 = -999 for _, m := range req.UplinkHistory {

            fmt.Println(m.MaxSNR)

    if m.MaxSNR > snrM {
        snrM = m.MaxSNR
    }
}
return snrM

}

Here, I found that UplinkHistory is initialized whenever SF changes.

Is this intentional? What should I change so that UplinkHistory won't initialize even if SF changes?

brocaar commented 2 years ago

A SF change invalidates the uplink history because it affects the SNR. The ADR algorithm should only consider the SNR values that were reported using the current SF / data-rate.