wip SetBaseMode

This commit is contained in:
2025-07-08 16:16:33 +02:00
parent daadb9b678
commit 08f12ab5cb
5 changed files with 77 additions and 0 deletions

View File

@ -222,4 +222,18 @@ func (c *Client) GetModemConfiguration(ctx context.Context) (any, error) {
return config, nil
}
// SetBase implements protocol.Operations.
func (c *Client) SetBaseMode(ctx context.Context, funcs ...protocol.SetBaseOptionFunc) error {
_, ops, err := c.getProtocol(ctx)
if err != nil {
return errors.WithStack(err)
}
if err := ops.SetBaseMode(ctx, funcs...); err != nil {
return errors.WithStack(err)
}
return nil
}
var _ protocol.Operations = &Client{}

View File

@ -64,4 +64,6 @@ type Operations interface {
//GetModemConfiguration mobile data config
GetModemConfiguration(ctx context.Context) (any, error)
SetBaseMode(ctx context.Context, funcs ...SetBaseOptionFunc) error
}

View File

@ -400,4 +400,10 @@ func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
return nil, protocol.ErrUnimplemented
}
// Deprecated : is no longer maintained for modules in V1
func (o *Operations) SetBaseMode(ctx context.Context, funcs ...protocol.SetBaseOptionFunc) error {
return protocol.ErrUnimplemented
}
var _ protocol.Operations = &Operations{}

View File

@ -183,3 +183,13 @@ func (o *Operations) GetModem(ctx context.Context) (*model.ModemConfiguration, e
return config, nil
}
func (o *Operations) PostBaseMode(ctx context.Context, base *model.Base) (*model.Base, error) {
var updated model.Base
if err := o.PostJSON("/configuration/base_mode", base, &updated); err != nil {
return nil, errors.WithStack(err)
}
return &updated, nil
}

View File

@ -410,4 +410,49 @@ func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
}
func (o *Operations) SetBaseMode(ctx context.Context, funcs ...protocol.SetBaseOptionFunc) error {
config, err := o.GetConfiguration(ctx)
if err != nil {
return errors.WithStack(err)
}
opts := protocol.NewSetBaseOptions(funcs...)
base := &model.Base{
Accumulation: config.BaseMode.BaseCoordinates.Accumulation,
AntennaOffset: config.BaseMode.BaseCoordinates.AntennaOffset,
Coordinates: model.BaseCoordinates{
Height: config.BaseMode.BaseCoordinates.Coordinates.Height,
Latitude: config.BaseMode.BaseCoordinates.Coordinates.Latitude,
Longitude: config.BaseMode.BaseCoordinates.Coordinates.Longitude,
},
Mode: config.BaseMode.BaseCoordinates.Mode,
}
if opts.Mode != nil {
base.Mode = *opts.Mode
}
if opts.Accumulation != nil {
base.Accumulation = *opts.Accumulation
}
if opts.Height != nil {
base.Coordinates.Height = *opts.Height
}
if opts.Latitude != nil {
base.Coordinates.Latitude = *opts.Latitude
}
if opts.Longitude != nil {
base.Coordinates.Longitude = *opts.Longitude
}
if _, err := o.PostBaseMode(ctx, base); err != nil {
return errors.WithStack(err)
}
return nil
}
var _ protocol.Operations = &Operations{}