Compare commits
2 Commits
08f12ab5cb
...
master
Author | SHA1 | Date | |
---|---|---|---|
4050090814 | |||
05f5b3f771 |
@ -222,18 +222,4 @@ 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,6 +64,4 @@ 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,10 +400,4 @@ 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,13 +183,3 @@ 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
|
|
||||||
}
|
|
||||||
|
@ -281,17 +281,6 @@ func (o *Operations) AveragePosition(ctx context.Context) (*protocol.TaskMessage
|
|||||||
if err = o.client.Emit("task", &model.Action{Name: "average_base_coordinates"}); err != nil {
|
if err = o.client.Emit("task", &model.Action{Name: "average_base_coordinates"}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ch, err := o.On(ctx, "task_status")
|
|
||||||
for message := range ch {
|
|
||||||
var taskMsg protocol.TaskMessage[protocol.AveragePositionPayload]
|
|
||||||
if err := mapstructure.Decode(message, &taskMsg); err != nil {
|
|
||||||
return nil, errors.WithStack(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if taskMsg.State == "completed" {
|
|
||||||
return &taskMsg, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,49 +399,4 @@ 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