feat: use /configuration/device and replice reachview system to define

antenna height

See Pyxis/fieldnotes#63 (comment)
This commit is contained in:
2024-09-20 10:12:05 +02:00
parent b2cdf23fb7
commit bea49c78a9
8 changed files with 149 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package testsuite
import (
"context"
"math"
"math/rand"
"os"
"strconv"
@ -156,7 +157,7 @@ var testCases = []operationTestCase{
latitude := -90 + rand.Float64()*180
longitude := -180 + rand.Float64()*360
height := rand.Float64() * 1000
antennaOffset := rand.Float64() * 2
antennaOffset := toFixed(rand.Float64()*2, 3)
opts := []protocol.SetBaseOptionFunc{
protocol.WithBaseLatitude(latitude),
@ -173,13 +174,29 @@ var testCases = []operationTestCase{
return
}
config, err := ops.Configuration(ctx)
baseInfo, err := ops.GetBaseInfo(ctx)
if err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
t.Logf("updated configuration: %v", spew.Sdump(config))
t.Logf("base info: %v", spew.Sdump(baseInfo))
if e, g := latitude, baseInfo.Latitude; e != g {
t.Errorf("baseInfo.Latitude: expected '%v', got '%v'", e, g)
}
if e, g := longitude, baseInfo.Longitude; e != g {
t.Errorf("baseInfo.Longitude: expected '%v', got '%v'", e, g)
}
if e, g := height, baseInfo.Height; e != g {
t.Errorf("baseInfo.Height: expected '%v', got '%v'", e, g)
}
if e, g := antennaOffset, baseInfo.AntennaOffset; e != g {
t.Errorf("baseInfo.AntennaOffset: expected '%v', got '%v'", e, g)
}
},
},
@ -247,3 +264,9 @@ func TestOperations(t *testing.T, opsFactory OperationsFactoryFunc) {
})
}
}
func toFixed(n float64, precision int) float64 {
scale := math.Pow(10, float64(precision))
return math.Round(n*scale) / scale
}