proxy

package
v0.0.0-...-6312dd6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(path string, packageName string) (string, error)

func LoadThings

func LoadThings(path string) map[string]things.Thing

func SaveConfig

func SaveConfig(path string, packageName string, value string) error

Types

type Adapter

type Adapter struct {
	*adapter.Adapter

	IsPairing bool
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(adapterId, name string) *Adapter

func (*Adapter) CancelPairing

func (a *Adapter) CancelPairing()

func (*Adapter) CancelRemoveThing

func (a *Adapter) CancelRemoveThing(id string)

func (*Adapter) Close

func (a *Adapter) Close()

func (*Adapter) GetName

func (a *Adapter) GetName() string

func (*Adapter) GetPackageName

func (a *Adapter) GetPackageName() string

func (*Adapter) HandleDeviceAdded

func (a *Adapter) HandleDeviceAdded(devices ...DeviceProxy)

func (*Adapter) HandleDeviceRemoved

func (a *Adapter) HandleDeviceRemoved(device DeviceProxy)

func (*Adapter) HandleDeviceSaved

func (a *Adapter) HandleDeviceSaved(msg messages.DeviceSavedNotificationJsonData)

func (*Adapter) Send

func (a *Adapter) Send(mt messages.MessageType, data any)

func (*Adapter) SendError

func (a *Adapter) SendError(message string)

func (*Adapter) SendPairingPrompt

func (a *Adapter) SendPairingPrompt(prompt, url string, did string)

SendPairingPrompt 向前端UI发送提示

func (*Adapter) SendPropertyChangedNotification

func (a *Adapter) SendPropertyChangedNotification(deviceId string, property properties.PropertyDescription)

func (*Adapter) SendUnpairingPrompt

func (a *Adapter) SendUnpairingPrompt(prompt, url string, did string)

func (*Adapter) StartPairing

func (a *Adapter) StartPairing(timeout <-chan time.Time)

type AdapterProxy

type AdapterProxy interface {
	adapter.Entity
	devices.AdapterHandler

	GetName() string
	GetPackageName() string

	// CancelPairing ## 取消配对 子类可改写业务逻辑
	CancelPairing()
	// StartPairing ## 开始配对 子类可改写业务逻辑
	StartPairing(timeout <-chan time.Time)
	// HandleDeviceSaved 当网关把一个设备进行了保存
	HandleDeviceSaved(data messages.DeviceSavedNotificationJsonData)
	// HandleDeviceRemoved 当一个设备被网关移除
	HandleDeviceRemoved(DeviceProxy)
	// CancelRemoveThing 当一个设备重新添加
	CancelRemoveThing(id string)
	// contains filtered or unexported methods
}

AdapterProxy Adapter 的抽象接口,

type Client

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

func (*Client) Dial

func (c *Client) Dial() (*websocket.Conn, error)

type DeviceProxy

type DeviceProxy interface {
	// Entity Device的公共接口
	devices.Entity
	// DeviceHandler 处理Device下Property业务的抽象接口,
	properties.DeviceHandler

	// SetCredentials 设备设置用户名t 密码时
	//子类需重写这个方法,来完成设备的用户名密码设置的逻辑
	SetCredentials(username, password string) error
	// SetPin  设备需要Pin码时时调用
	//子类需重写这个方法,来完成设备的用户名密码设置的逻辑
	SetPin(pin string) error
}

DeviceProxy 所有Addon所有Device的抽象接口,

addons/devices下所有Device均实现了此接口

type Manager

type Manager struct {
	*manager.Manager

	Done chan struct{}
	// contains filtered or unexported fields
}

func NewAddonManager

func NewAddonManager(ctx context.Context, pluginId string) (*Manager, error)

func (*Manager) AddAdapters

func (m *Manager) AddAdapters(adapters ...AdapterProxy)

func (*Manager) GetAdapter

func (m *Manager) GetAdapter(adapterId string) AdapterProxy

func (*Manager) HandleAdapterRemoved

func (m *Manager) HandleAdapterRemoved(id string)

func (*Manager) OnMessage

func (m *Manager) OnMessage(byt []byte)

type ManagerProxy

type ManagerProxy interface {

	// AddAdapters 插件调用的方法,向Manager参加AdapterProxy
	AddAdapters(adapters ...AdapterProxy)
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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