Add basic Configuration() method

This commit is contained in:
wpetit 2018-09-20 17:28:18 +02:00
parent ff13693f69
commit e3672cc6d7
3 changed files with 81 additions and 0 deletions

44
reach/configuration.go Normal file
View File

@ -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
}

View File

@ -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()
}

View File

@ -7,6 +7,11 @@ var runUpdaterIntegrationTests = flag.Bool(
"Run the 'Updater' integration tests (in addition to the unit tests)", "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( var reachHost = flag.String(
"reach-host", "192.168.42.1", "reach-host", "192.168.42.1",
"The Reach module host to use in integration tests", "The Reach module host to use in integration tests",