step should not be constant but dependent on valid measurements

This commit is contained in:
Joerg Lehmann 2020-04-03 12:30:13 +02:00
parent 9e79787a41
commit dc805547d9
1 changed files with 12 additions and 1 deletions

View File

@ -175,7 +175,18 @@ func DecodePayload(s string, deveui string, devaddr string, lrrlat float32, lrrl
if write2file { if write2file {
// Time of first Packet // Time of first Packet
var tfp = (time.Now().Unix() / 60) - int64(pl_1.O) var tfp = (time.Now().Unix() / 60) - int64(pl_1.O)
var step = int64(pl_1.O / 7) humidity_values := []uint8{pl_1.H1, pl_1.H2, pl_1.H3, pl_1.H4, pl_1.H5, pl_1.H6, pl_1.H7, pl_1.H8}
valid_measurements := 0
for _, v := range humidity_values {
if v > 0 {
valid_measurements = valid_measurements + 1
}
}
fmt.Printf("Valid Measurements: %d,\n", valid_measurements)
var step int64
if valid_measurements > 1 {
step = int64(int(pl_1.O) / (valid_measurements - 1))
}
// the first temperature is usually too high (maybe becaus of lorawan send, so we take // the first temperature is usually too high (maybe becaus of lorawan send, so we take
// the second measurement as first..., the same for humidity, which is usually too low... // the second measurement as first..., the same for humidity, which is usually too low...