Compare commits
1 Commits
c9c6115bf3
...
daadb9b678
Author | SHA1 | Date | |
---|---|---|---|
daadb9b678 |
@ -207,7 +207,7 @@ func (c *Client) SetModem(ctx context.Context, funcs ...protocol.SetModemOptions
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetModem implements protocol.Operations.
|
// GetModemConfiguration implements protocol.Operations.
|
||||||
func (c *Client) GetModemConfiguration(ctx context.Context) (any, error) {
|
func (c *Client) GetModemConfiguration(ctx context.Context) (any, error) {
|
||||||
_, ops, err := c.getProtocol(ctx)
|
_, ops, err := c.getProtocol(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -377,6 +377,29 @@ 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) {
|
||||||
|
@ -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.ModemAuthentication, error) {
|
func (o *Operations) GetModem(ctx context.Context) (*model.ModemConfiguration, error) {
|
||||||
config := &model.ModemAuthentication{}
|
config := &model.ModemConfiguration{}
|
||||||
|
|
||||||
if err := o.GetJSON("/modem/1/settings", config); err != nil {
|
if err := o.GetJSON("/modem/1/info", config); err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,3 +10,25 @@ 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"`
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user