dev

package
v0.0.0-...-b44964e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetConfig

func SetConfig(ctx context.Context, dc DevConn, devConf *DevConf, setArgTmpl *ConfigSetArg) (bool, error)

func UsageSummary

func UsageSummary() string

Types

type Client

type Client struct {
	Port      string
	Reconnect bool
	Timeout   time.Duration
}

func (*Client) CreateDevConn

func (c *Client) CreateDevConn(
	ctx context.Context, connectAddr string, reconnect bool,
) (*MosDevConn, error)

CreateDevConn creates a direct connection to the device at a given address, which could be e.g. "serial:///dev/ttyUSB0", "serial://COM7", "tcp://192.168.0.10", etc.

func (*Client) CreateDevConnWithOpts

func (c *Client) CreateDevConnWithOpts(ctx context.Context, connectAddr string, reconnect bool, tlsConfig *tls.Config, codecOpts *codec.Options) (*MosDevConn, error)

func (*Client) PostProcessFlags

func (c *Client) PostProcessFlags(fs *flag.FlagSet) error

func (*Client) RegisterFlags

func (c *Client) RegisterFlags(fs *flag.FlagSet)

func (*Client) RunWithTimeout

func (c *Client) RunWithTimeout(ctx context.Context, f func(context.Context) error) error

RunWithTimeout takes a parent context and a function, and calls the function with the newly created context with timeout (see the "timeout" flag)

type ConfigSetArg

type ConfigSetArg struct {
	Config map[string]interface{} `json:"config,omitempty"`
	// Since 2.12
	Level   int  `json:"level,omitempty"`
	Save    bool `json:"save,omitempty"`
	Reboot  bool `json:"reboot,omitempty"`
	TryOnce bool `json:"try_once,omitempty"`
}

type ConfigSetResp

type ConfigSetResp struct {
	Saved bool `json:"saved,omitempty"`
}

type DevConf

type DevConf struct {
	// contains filtered or unexported fields
}

DevConf represents configuration of a device

func GetConfig

func GetConfig(ctx context.Context, dc DevConn) (*DevConf, error)

func GetConfigLevel

func GetConfigLevel(ctx context.Context, dc DevConn, level int) (*DevConf, error)

func (*DevConf) Get

func (c *DevConf) Get(path string) (string, error)

Get takes a path like "wifi.sta.ssid" and tries to get config value at the given path.

func (*DevConf) Set

func (c *DevConf) Set(path, value string) error

Set takes a path like "wifi.sta.ssid" and a value, and tries to set config value at the given path. Value is always a string, but if given path refers to a number or a boolean, then the given value string will be converted to the appropriate type.

type DevConn

type DevConn interface {
	Call(ctx context.Context, method string, args interface{}, resp interface{}) error
	GetTimeout() time.Duration
	Connect(context.Context, bool) error
	Disconnect(context.Context) error
}

type GetInfoResult

type GetInfoResult struct {
	App        *string            `json:"app,omitempty"`
	Arch       *string            `json:"arch,omitempty"`
	Fs_free    *int64             `json:"fs_free,omitempty"`
	Fs_size    *int64             `json:"fs_size,omitempty"`
	Fw_id      *string            `json:"fw_id,omitempty"`
	Fw_version *string            `json:"fw_version,omitempty"`
	Mac        *string            `json:"mac,omitempty"`
	RAMFree    *int64             `json:"ram_free,omitempty"`
	RAMMinFree *int64             `json:"ram_min_free,omitempty"`
	RAMSize    *int64             `json:"ram_size,omitempty"`
	Uptime     *int64             `json:"uptime,omitempty"`
	Wifi       *GetInfoResultWifi `json:"wifi,omitempty"`
}

func GetInfo

func GetInfo(ctx context.Context, dc DevConn) (*GetInfoResult, error)

type GetInfoResultWifi

type GetInfoResultWifi struct {
	SSSID  *string `json:"ssid,omitempty"`
	StaIP  *string `json:"sta_ip,omitempty"`
	APIP   *string `json:"ap_ip,omitempty"`
	Status *string `json:"status,omitempty"`
}

type MosDevConn

type MosDevConn struct {
	ConnectAddr string
	RPC         mgrpc.MgRPC
	Dest        string
	Reconnect   bool
	// contains filtered or unexported fields
}

func (*MosDevConn) Call

func (dc *MosDevConn) Call(ctx context.Context, method string, args interface{}, resp interface{}) error

func (*MosDevConn) CallB

func (dc *MosDevConn) CallB(ctx context.Context, method string, args interface{}) ([]byte, error)

func (*MosDevConn) CallRaw

func (dc *MosDevConn) CallRaw(ctx context.Context, method string, args interface{}) (json.RawMessage, error)

func (*MosDevConn) Connect

func (dc *MosDevConn) Connect(ctx context.Context, reconnect bool) error

func (*MosDevConn) ConnectWithOpts

func (dc *MosDevConn) ConnectWithOpts(ctx context.Context, reconnect bool, tlsConfig *tls.Config, codecOpts *codec.Options) error

func (*MosDevConn) Disconnect

func (dc *MosDevConn) Disconnect(ctx context.Context) error

func (*MosDevConn) GetTimeout

func (dc *MosDevConn) GetTimeout() time.Duration

func (*MosDevConn) IsConnected

func (dc *MosDevConn) IsConnected() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL