feat: use /configuration/device and replice reachview system to define
antenna height See Pyxis/fieldnotes#63 (comment)
This commit is contained in:
@ -116,6 +116,16 @@ func (o *Operations) PostBaseCoordinates(ctx context.Context, base *model.Base)
|
||||
return &updated, nil
|
||||
}
|
||||
|
||||
func (o *Operations) PostDevice(ctx context.Context, device *model.ConfigurationDevice) (*model.ConfigurationDevice, error) {
|
||||
var updated model.ConfigurationDevice
|
||||
|
||||
if err := o.PostJSON("/configuration/device", device, &updated); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return &updated, nil
|
||||
}
|
||||
|
||||
func (o *Operations) GetUpdater(ctx context.Context) (*model.Updater, error) {
|
||||
updater := &model.Updater{}
|
||||
if err := o.GetJSON("/updater", updater); err != nil {
|
||||
|
@ -148,15 +148,7 @@ type Configuration struct {
|
||||
} `json:"settings,omitempty"`
|
||||
} `json:"base_corrections,omitempty"`
|
||||
} `json:"correction_input,omitempty"`
|
||||
Device struct {
|
||||
AntennaHeight float64 `json:"antenna_height,omitempty"`
|
||||
NightMode bool `json:"night_mode,omitempty"`
|
||||
OnboardingShown bool `json:"onboarding_shown,omitempty"`
|
||||
PowerOnBottomConnector bool `json:"power_on_bottom_connector,omitempty"`
|
||||
PrivacyPolicyAccepted bool `json:"privacy_policy_accepted,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
UsageAnalysisAccepted bool `json:"usage_analysis_accepted,omitempty"`
|
||||
} `json:"device,omitempty"`
|
||||
Device ConfigurationDevice `json:"device,omitempty"`
|
||||
Logging struct {
|
||||
Logs struct {
|
||||
Autostart bool `json:"autostart,omitempty"`
|
||||
|
11
reach/client/protocol/v2/model/device.go
Normal file
11
reach/client/protocol/v2/model/device.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
type ConfigurationDevice struct {
|
||||
AntennaHeight float64 `json:"antenna_height,omitempty"`
|
||||
NightMode bool `json:"night_mode,omitempty"`
|
||||
OnboardingShown bool `json:"onboarding_shown,omitempty"`
|
||||
PowerOnBottomConnector bool `json:"power_on_bottom_connector,omitempty"`
|
||||
PrivacyPolicyAccepted bool `json:"privacy_policy_accepted,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
UsageAnalysisAccepted bool `json:"usage_analysis_accepted,omitempty"`
|
||||
}
|
@ -60,6 +60,8 @@ func (o *Operations) Reboot(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const DeviceHeight = 0.134
|
||||
|
||||
// SetBase implements protocol.Operations.
|
||||
func (o *Operations) SetBase(ctx context.Context, funcs ...protocol.SetBaseOptionFunc) error {
|
||||
config, err := o.GetConfiguration(ctx)
|
||||
@ -96,17 +98,41 @@ func (o *Operations) SetBase(ctx context.Context, funcs ...protocol.SetBaseOptio
|
||||
base.Coordinates.Longitude = *opts.Longitude
|
||||
}
|
||||
|
||||
if opts.AntennaOffset != nil {
|
||||
base.AntennaOffset = *opts.AntennaOffset
|
||||
}
|
||||
|
||||
if _, err := o.PostBaseCoordinates(ctx, base); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
if opts.AntennaOffset != nil {
|
||||
device := &model.ConfigurationDevice{
|
||||
AntennaHeight: *opts.AntennaOffset + DeviceHeight,
|
||||
}
|
||||
|
||||
if _, err := o.PostDevice(ctx, device); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBaseInfo implements protocol.Operations.
|
||||
func (o *Operations) GetBaseInfo(ctx context.Context) (*protocol.BaseInfo, error) {
|
||||
config, err := o.GetConfiguration(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
baseInfo := &protocol.BaseInfo{
|
||||
Mode: config.BaseMode.BaseCoordinates.Mode,
|
||||
AntennaOffset: config.BaseMode.BaseCoordinates.AntennaOffset - DeviceHeight,
|
||||
Height: config.BaseMode.BaseCoordinates.Coordinates.Height,
|
||||
Latitude: config.BaseMode.BaseCoordinates.Coordinates.Latitude,
|
||||
Longitude: config.BaseMode.BaseCoordinates.Coordinates.Longitude,
|
||||
}
|
||||
|
||||
return baseInfo, nil
|
||||
}
|
||||
|
||||
// Configuration implements protocol.Operations.
|
||||
func (o *Operations) Configuration(ctx context.Context) (any, error) {
|
||||
config, err := o.GetConfiguration(ctx)
|
||||
|
Reference in New Issue
Block a user