deco

package module
v0.0.0-...-f5904f7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

README

This Go package provides a basic API wrapper for the tp-link M4 mesh router

Available methods

  • Performance: Get CPU and Memory usage
  • ClientList: Get connected clients
  • Custom: Make a custom request to the router
  • DeviceList: Get connected Decos
  • Wan: Get information about wan

TODO: look through the firmware for more endpoints

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DecoRequestTimeout = 10 * time.Second

Functions

This section is empty.

Types

type Client

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

Client is a client for sending requests to the Deco-m4 API

func New

func New(target string) *Client

New creates a new Go client for the Deco-m4 API

func (*Client) Authenticate

func (c *Client) Authenticate(password string) error

Authenticate will generate the keys needed for the communication with the router.

func (*Client) ClientList

func (c *Client) ClientList(mac string) (*ClientListResp, error)

ClientList returns the list of connected devices

func (*Client) Custom

func (c *Client) Custom(path string, params EndpointArgs, body []byte) (interface{}, error)

Custom lets you make a custom request

func (*Client) DeviceList

func (c *Client) DeviceList() (*DeviceListResp, error)

DeviceList returns the list of connected deco APs

func (*Client) Performance

func (c *Client) Performance() (*PerfResp, error)

Performance returns the current cpu and mem usage.

type ClientListResp

type ClientListResp struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		ClientList []struct {
			AccessHost     string `json:"access_host"`
			ClientMesh     bool   `json:"client_mesh"`
			ClientType     string `json:"client_type"`
			ConnectionType string `json:"band5"`
			DownSpeed      uint   `json:"down_speed"`
			EnablePriority bool   `json:"enable_priority"`
			Interface      string `json:"interface"`
			IP             string `json:"ip"`
			MAC            string `json:"mac"`
			Name           string `json:"name"`
			Online         bool   `json:"online"`
			OwnerID        string `json:"owner_id"`
			RemainTime     int    `json:"remain_time"`
			SpaceID        string `json:"space_id"`
			UpSpeed        uint   `json:"up_speed"`
			WireType       string `json:"wire_type"`
		} `json:"client_list"`
	} `json:"result"`
}

ClientListResp is the structure of the client_list endpoint

type DeviceListResp

type DeviceListResp struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		DeviceList []struct {
			DeviceIP          string   `json:"device_ip"`
			DeviceID          string   `json:"device_id,omitempty"`
			DeviceType        string   `json:"device_type"`
			NandFlash         bool     `json:"nand_flash"`
			OwnerTransfer     bool     `json:"owner_transfer,omitempty"`
			Previous          string   `json:"previous"`
			BSSID5G           string   `json:"bssid_5g"`
			BSSID2G           string   `json:"bssid_2g"`
			BSSIDSta5G        string   `json:"bssid_sta_5g"`
			BSSIDSta2G        string   `json:"bssid_sta_2g"`
			ParentDeviceID    string   `json:"parent_device_id,omitempty"`
			SoftwareVer       string   `json:"software_ver"`
			Role              string   `json:"role"`
			ProductLevel      int      `json:"product_level"`
			HardwareVer       string   `json:"hardware_ver"`
			InetStatus        string   `json:"inet_status"`
			SupportPLC        bool     `json:"support_plc"`
			MAC               string   `json:"mac"`
			SetGatewaySupport bool     `json:"set_gateway_support"`
			InetErrorMsg      string   `json:"inet_error_msg"`
			ConnectionType    []string `json:"connection_type,omitempty"`
			CustomNickname    string   `json:"custom_nickname,omitempty"`
			Nickname          string   `json:"nickname"`
			GroupStatus       string   `json:"group_status"`
			OemID             string   `json:"oem_id"`
			SignalLevel       struct {
				Band24 string `json:"band2_4"`
				Band5  string `json:"band5"`
			} `json:"signal_level"`
			DeviceModel       string `json:"device_model"`
			OversizedFirmware bool   `json:"oversized_firmware"`
			SpeedGetSupport   bool   `json:"speed_get_support,omitempty"`
			HwID              string `json:"hw_id"`
		} `json:"device_list"`
	} `json:"result"`
}

DeviceListResp is the structure of the device_list endpoint

type EndpointArgs

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

EndpointArgs holds the url params to be sent

type PerfResp

type PerfResp struct {
	ErrorCode int `json:"error_code"`
	Result    struct {
		CPU float32 `json:"cpu_usage"`
		MEM float32 `json:"mem_usage"`
	} `json:"result"`
}

PerfResp is the structure of the performance endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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