feat(reachview): GetModemConfiguration func

This commit is contained in:
2025-07-04 14:45:36 +02:00
parent 1fcf748310
commit c9c6115bf3
8 changed files with 115 additions and 17 deletions

View File

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

View File

@ -61,4 +61,7 @@ type Operations interface {
//SetModem updates mobile data config
SetModem(ctx context.Context, funcs ...SetModemOptionsFunc) error
//GetModemConfiguration mobile data config
GetModemConfiguration(ctx context.Context) (any, error)
}

View File

@ -1,16 +0,0 @@
package testsuite
import (
"testing"
"forge.cadoles.com/cadoles/go-emlid/reach/client"
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
)
func TestReachOperations(t *testing.T) {
opsFactory := func(addr string) (protocol.Operations, error) {
return client.NewClient(addr), nil
}
TestOperations(t, opsFactory)
}

View File

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

View File

@ -173,3 +173,13 @@ func (o *Operations) PostModem(ctx context.Context, config *model.ModemAuthentic
return &updated, nil
}
func (o *Operations) GetModem(ctx context.Context) (*model.ModemAuthentication, error) {
config := &model.ModemAuthentication{}
if err := o.GetJSON("/modem/1/settings", config); err != nil {
return nil, errors.WithStack(err)
}
return config, nil
}

View File

@ -2,5 +2,5 @@ package model
type Action struct {
Name string `json:"name"`
Paylaod map[string]any `json:"payload"`
Paylaod map[string]any `json:"payload,omitempty"`
}

View File

@ -399,4 +399,15 @@ func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOpt
return nil
}
// SetModem implements protocol.Operations.
func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
config, err := o.GetModem(ctx)
if err != nil {
return nil, errors.WithStack(err)
}
return config, nil
}
var _ protocol.Operations = &Operations{}