diff --git a/reach/configuration.go b/reach/configuration.go new file mode 100644 index 0000000..b7f3fca --- /dev/null +++ b/reach/configuration.go @@ -0,0 +1,44 @@ +package reach + +const ( + eventGetConfiguration = "get configuration" + eventCurrentConfiguration = "current configuration" +) + +// Configuration is a configuration +type Configuration struct { + RTKSettings *RTKSettings `mapstructure:"rtk settings,omitempty"` +} + +// RTKSettings - +type RTKSettings struct { + GLONASSARMode string `mapstructure:"glonass ar mode"` + UpdateRate string `mapstructure:"update rate"` + ElevationMaskAngle string `mapstructure:"elevation mask angle"` + MaxHorizontalAcceleration string `mapstructure:"max horizontal acceleration"` + SNRMask string `mapstructure:"snr mask"` + GPSARMode string `mapstructure:"gps ar mode"` + PositionningMode string `mapstructure:"positioning mode"` + PositioningSystems *PositionningSystems `mapstructure:"positioning systems,omitempty"` + MaxVerticalAcceleration string `mapstructure:"max vertical acceleration"` +} + +// PositionningSystems - +type PositionningSystems struct { + GLONASS bool `json:"glonass"` + SBAS bool `json:"sbas"` + QZS bool `json:"qzs"` + QZSS bool `json:"qzss"` + Compass bool `json:"compass"` + Galileo bool `json:"galileo"` + GPS bool `json:"gps"` +} + +// Configuration fetches and return the current configuration of the ReachRS module +func (r *ReachView) Configuration() (*Configuration, error) { + configuration := &Configuration{} + if err := r.fetch(eventGetConfiguration, nil, eventCurrentConfiguration, configuration); err != nil { + return nil, err + } + return configuration, nil +} diff --git a/reach/configuration_test.go b/reach/configuration_test.go new file mode 100644 index 0000000..046a974 --- /dev/null +++ b/reach/configuration_test.go @@ -0,0 +1,32 @@ +package reach + +import ( + "testing" +) + +func TestReachViewConfiguration(t *testing.T) { + + if !*runReachViewIntegrationTests { + t.Skip("To run this test, use: go test -reachview-integration") + } + + client := NewReachViewClient( + WithStandardLogger(), + WithEndpoint(*reachHost, 80), + ) + if err := client.Connect(); err != nil { + t.Fatal(err) + } + + config, err := client.Configuration() + if err != nil { + t.Error(err) + } + + if config == nil { + t.Error("config should not be nil") + } + + defer client.Close() + +} diff --git a/reach/test.go b/reach/test.go index 5343fc6..0253f58 100644 --- a/reach/test.go +++ b/reach/test.go @@ -7,6 +7,11 @@ var runUpdaterIntegrationTests = flag.Bool( "Run the 'Updater' integration tests (in addition to the unit tests)", ) +var runReachViewIntegrationTests = flag.Bool( + "reachview-integration", false, + "Run the 'ReachView' integration tests (in addition to the unit tests)", +) + var reachHost = flag.String( "reach-host", "192.168.42.1", "The Reach module host to use in integration tests",