wip SetBaseMode
This commit is contained in:
@ -222,4 +222,18 @@ func (c *Client) GetModemConfiguration(ctx context.Context) (any, error) {
|
|||||||
return config, nil
|
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{}
|
var _ protocol.Operations = &Client{}
|
||||||
|
@ -64,4 +64,6 @@ type Operations interface {
|
|||||||
|
|
||||||
//GetModemConfiguration mobile data config
|
//GetModemConfiguration mobile data config
|
||||||
GetModemConfiguration(ctx context.Context) (any, error)
|
GetModemConfiguration(ctx context.Context) (any, error)
|
||||||
|
|
||||||
|
SetBaseMode(ctx context.Context, funcs ...SetBaseOptionFunc) error
|
||||||
}
|
}
|
||||||
|
@ -400,4 +400,10 @@ func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
|
|||||||
return nil, protocol.ErrUnimplemented
|
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{}
|
var _ protocol.Operations = &Operations{}
|
||||||
|
@ -183,3 +183,13 @@ func (o *Operations) GetModem(ctx context.Context) (*model.ModemConfiguration, e
|
|||||||
|
|
||||||
return config, nil
|
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
|
||||||
|
}
|
||||||
|
@ -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{}
|
var _ protocol.Operations = &Operations{}
|
||||||
|
Reference in New Issue
Block a user