Upgrade to ReachView v2.24.0

This commit is contained in:
2020-11-23 11:15:30 +01:00
parent b8a07953dd
commit e06aa5129a
16 changed files with 260 additions and 103 deletions

View File

@ -1,14 +1,18 @@
package reachview
import "forge.cadoles.com/Pyxis/orion/emlid"
import (
"forge.cadoles.com/Pyxis/orion/emlid"
"forge.cadoles.com/Pyxis/orion/emlid/common"
)
// Client is a ReachRS Updater client
type Client struct {
*emlid.Client
*common.Client
}
// NewClient returns a new ReachRS ReachView client
func NewClient(opts ...emlid.OptionFunc) *Client {
client := emlid.NewClient(opts...)
return &Client{client}
return &Client{
Client: common.NewClient(opts...),
}
}

View File

@ -1,13 +1,19 @@
package reachview
import "context"
import (
"context"
"forge.cadoles.com/Pyxis/orion/emlid/common"
"github.com/pkg/errors"
)
const (
eventGetConfiguration = "get configuration"
eventCurrentConfiguration = "current configuration"
eventApplyConfiguration = "apply configuration"
eventConfigurationApplied = "configuration applied"
eventResetConfiguration = "reset configuration to default"
eventGetConfiguration = "get configuration"
eventCurrentConfiguration = "current configuration"
eventApplyConfiguration = "apply configuration"
eventConfigurationApplied = "configuration applied"
eventResetConfiguration = "reset configuration to default"
eventSettingsResetToDefault = "settings reset to default"
)
// Configuration fetches and return the current configuration of the ReachRS module
@ -42,10 +48,32 @@ func (r *Client) ApplyConfiguration(ctx context.Context, config *Configuration)
}
// ResetConfiguration resets the module configuration to factory defaults
func (r *Client) ResetConfiguration(ctx context.Context) (string, *Configuration, error) {
res := &configurationApplied{}
if err := r.ReqResp(ctx, eventResetConfiguration, nil, eventConfigurationApplied, res); err != nil {
return ConfigurationApplyFailed, nil, err
func (r *Client) ResetConfiguration(ctx context.Context) error {
err := r.HandleVersion(
ctx,
common.NewVersionHandler("< 2.24.0", func(ctx context.Context, version string, stable bool) error {
res := &configurationApplied{}
if err := r.ReqResp(ctx, eventResetConfiguration, nil, eventConfigurationApplied, res); err != nil {
return errors.WithStack(err)
}
if res.Result != ConfigurationApplySuccess {
return errors.New(res.Result)
}
return nil
}),
common.NewVersionHandler(">= 2.24.0", func(ctx context.Context, version string, stable bool) error {
if err := r.ReqResp(ctx, eventResetConfiguration, nil, eventSettingsResetToDefault, nil); err != nil {
return errors.WithStack(err)
}
return nil
}),
)
if err != nil {
return errors.WithStack(err)
}
return res.Result, res.Configuration, nil
return nil
}

View File

@ -80,7 +80,7 @@ type Configuration struct {
// RTKSettings -
type RTKSettings struct {
GLONASSARMode *string `mapstructure:"glonass ar mode,omitempty" json:"glonass ar mode,omitempty"`
UpdateRate *string `mapstructure:"update rate,omitempty" json:"update rate,omitempty"`
UpdateRate *float64 `mapstructure:"update rate,omitempty" json:"update rate,omitempty"`
ElevationMaskAngle *string `mapstructure:"elevation mask angle,omitempty" json:"elevation mask angle,omitempty"`
MaxHorizontalAcceleration *string `mapstructure:"max horizontal acceleration,omitempty" json:"max horizontal acceleration,omitempty"`
SNRMask *string `mapstructure:"snr mask,omitempty" json:"snr mask,omitempty"`