Compare commits
1 Commits
master
...
532d96a9be
Author | SHA1 | Date | |
---|---|---|---|
532d96a9be |
@ -207,19 +207,4 @@ func (c *Client) SetModem(ctx context.Context, funcs ...protocol.SetModemOptions
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetModemConfiguration 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{}
|
var _ protocol.Operations = &Client{}
|
||||||
|
@ -63,5 +63,5 @@ type Operations interface {
|
|||||||
SetModem(ctx context.Context, funcs ...SetModemOptionsFunc) error
|
SetModem(ctx context.Context, funcs ...SetModemOptionsFunc) error
|
||||||
|
|
||||||
//GetModemConfiguration mobile data config
|
//GetModemConfiguration mobile data config
|
||||||
GetModemConfiguration(ctx context.Context) (any, error)
|
GetModemConfiguration(ctx context.Context, funcs ...SetModemOptionsFunc) (any, error)
|
||||||
}
|
}
|
||||||
|
@ -377,29 +377,6 @@ var testCases = []operationTestCase{
|
|||||||
t.Logf("Message : %+v", taskMsg)
|
t.Logf("Message : %+v", taskMsg)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "GetModemConfiguration",
|
|
||||||
Run: func(t *testing.T, ops protocol.Operations) {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
if err := ops.Connect(ctx); err != nil {
|
|
||||||
t.Errorf("%+v", errors.WithStack(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if err := ops.Close(ctx); err != nil {
|
|
||||||
t.Errorf("%+v", errors.WithStack(err))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
config, err := ops.GetModemConfiguration(ctx)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%+v", errors.WithStack(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Logf("Modem configuration : %+v", config)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOperations(t *testing.T, opsFactory OperationsFactoryFunc) {
|
func TestOperations(t *testing.T, opsFactory OperationsFactoryFunc) {
|
||||||
|
16
reach/client/protocol/testsuite/operations_test.go
Normal file
16
reach/client/protocol/testsuite/operations_test.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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)
|
||||||
|
}
|
@ -396,7 +396,7 @@ func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated : is no longer maintained for modules in V1
|
// Deprecated : is no longer maintained for modules in V1
|
||||||
func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
|
func (o *Operations) GetModemConfiguration(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) (*model.ModemAuthentication, error) {
|
||||||
return nil, protocol.ErrUnimplemented
|
return nil, protocol.ErrUnimplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,10 +174,10 @@ func (o *Operations) PostModem(ctx context.Context, config *model.ModemAuthentic
|
|||||||
return &updated, nil
|
return &updated, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Operations) GetModem(ctx context.Context) (*model.ModemConfiguration, error) {
|
func (o *Operations) GetModem(ctx context.Context) (*model.ModemAuthentication, error) {
|
||||||
config := &model.ModemConfiguration{}
|
config := &model.ModemAuthentication{}
|
||||||
|
|
||||||
if err := o.GetJSON("/modem/1/info", config); err != nil {
|
if err := o.GetJSON("/modem/1/settings", config); err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,25 +10,3 @@ type ModemAuthentication struct {
|
|||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
} `json:"authentication"`
|
} `json:"authentication"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModemConfiguration struct {
|
|
||||||
AccessTechnology string `json:"access_technology"`
|
|
||||||
AllowedModes []string `json:"allowed_modes"`
|
|
||||||
AvailableAPNs []string `json:"available_apns,omitempty"`
|
|
||||||
CurrentAPN string `json:"current_apn"`
|
|
||||||
CurrentMode string `json:"current_mode"`
|
|
||||||
FailReason *string `json:"fail_reason,omitempty"`
|
|
||||||
IMEI string `json:"imei"`
|
|
||||||
InternetAvailable string `json:"internet_available,omitempty"`
|
|
||||||
LockReason *string `json:"lock_reason,omitempty"`
|
|
||||||
OperatorName string `json:"operator_name"`
|
|
||||||
PreferredMode string `json:"preferred_mode"`
|
|
||||||
RegistrationState string `json:"registration_state"`
|
|
||||||
RSSI int `json:"rssi"`
|
|
||||||
State string `json:"state"`
|
|
||||||
Stats struct {
|
|
||||||
Since string `json:"since"`
|
|
||||||
UsageMB string `json:"usage_mb"`
|
|
||||||
} `json:"stats"`
|
|
||||||
UnlockRetries int `json:"unlock_retries"`
|
|
||||||
}
|
|
||||||
|
@ -281,6 +281,17 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +400,7 @@ func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetModem implements protocol.Operations.
|
// SetModem implements protocol.Operations.
|
||||||
func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
|
func (o *Operations) GetModemConfiguration(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) (any, error) {
|
||||||
config, err := o.GetModem(ctx)
|
config, err := o.GetModem(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
|
Reference in New Issue
Block a user