client

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PowerOnStateOn   PowerOnState = "on"
	PowerOnStateOff  PowerOnState = "off"
	PowerOnStateStay PowerOnState = "stay"

	StateOn  State = "on"
	StateOff State = "off"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(ip net.IP, port int, deviceId string) *Client

func (Client) DeviceInfo

func (c Client) DeviceInfo() (*DeviceInfoData, error)

func (Client) FlashFirmware

func (c Client) FlashFirmware(filePath string) error

func (Client) PowerOnState

func (c Client) PowerOnState(state PowerOnState) error

func (Client) SleepTimer added in v1.1.0

func (c Client) SleepTimer(state State, duration int) error

func (Client) Switch

func (c Client) Switch(state State) error

func (Client) UnlockOTA

func (c Client) UnlockOTA() error

func (Client) WiFiConfig

func (c Client) WiFiConfig(ssid, password string) error

func (Client) WiFiSignal

func (c Client) WiFiSignal() (int, error)

type DeviceInfoData

type DeviceInfoData struct {
	Switch     string `json:"switch"`
	Startup    string `json:"startup"`
	Pulse      string `json:"pulse"`
	PulseWidth int    `json:"pulseWidth"`
	SSID       string `json:"ssid"`
	OTAUnlock  bool   `json:"otaUnlock"`
}

type PowerOnState

type PowerOnState string

type Response

type Response struct {
	// The order of device status update (also the order of TXT Record update)
	Seq int `json:"seq"`

	// Whether the device successfully sets the specified device information.
	// - 0:   Successfully
	// - 400: The operation failed and the request was formatted incorrectly.
	//        The request body is not a valid JSON format.
	// - 401: The operation failed and the request was unauthorized.
	//        Device information encryption is enabled on the device, but the request is not encrypted.
	// - 404: The operation failed and the device does not exist.
	//        The device does not support the requested deviceid.
	// - 422: The operation failed and the request parameters are invalid.
	//        For example, the device does not support setting specific device information.
	Error int `json:"error"`

	// Object type, it returns specific device info when check the device information
	Data json.RawMessage `json:"data"`
}

func (Response) UnmarshalData

func (r Response) UnmarshalData(v interface{}) error

type ResponseError

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

func (ResponseError) Code

func (e ResponseError) Code() int

func (ResponseError) Error

func (e ResponseError) Error() string

type State added in v1.1.0

type State string

type WiFiSignalData

type WiFiSignalData struct {
	SignalStrength int `json:"signalStrength"`
}

Jump to

Keyboard shortcuts

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