Documentation
¶
Index ¶
- func Exist(name string) bool
- type Attribute
- type AuthDevice
- type ChildDevice
- type Device
- type DeviceInfo
- type Instance
- type Manager
- func (p *Manager) AddDevice(device Device) error
- func (p *Manager) Auth(identity string, params map[string]string) (err error)
- func (p *Manager) Devices() (ds []Device, err error)
- func (p *Manager) Disconnect(identity string, params map[string]string) (err error)
- func (p *Manager) GetAttributes(identity string) (s []Instance, err error)
- func (p *Manager) HealthCheck(identity string) bool
- func (p *Manager) Init()
- func (p *Manager) IsOTASupport(identity string) (bool, error)
- func (p *Manager) Notify(identity string, instanceID int, attr *utils.Attribute) attribute.NotifyFunc
- func (p *Manager) OTA(identity, firmwareURL string) (ch chan OTAResp, err error)
- func (p *Manager) RemoveDevice(identity string) error
- func (p *Manager) SetAttribute(identity string, instanceID int, attr string, val interface{}) (err error)
- func (p *Manager) SetAttributeNotify(identity string) error
- func (p *Manager) Subscribe(notify chan Notify)
- func (p *Manager) Unsubscribe(notify chan Notify)
- func (p *Manager) WatchNotify(ch WatchChan)
- type Notification
- type Notify
- type OTADevice
- type OTAProgressState
- type OTAResp
- type OptionFunc
- type ParentDevice
- type Server
- func (p Server) Connect(ctx context.Context, req *proto.AuthReq) (resp *proto.GetAttributesResp, err error)
- func (p Server) Disconnect(ctx context.Context, req *proto.AuthReq) (resp *proto.Empty, err error)
- func (p Server) Discover(request *proto.Empty, server proto.Plugin_DiscoverServer) error
- func (p Server) GetAttributes(context context.Context, request *proto.GetAttributesReq) (resp *proto.GetAttributesResp, err error)
- func (p Server) HealthCheck(context context.Context, req *proto.HealthCheckReq) (resp *proto.HealthCheckResp, err error)
- func (p *Server) Init()
- func (p Server) OTA(req *proto.OTAReq, server proto.Plugin_OTAServer) error
- func (p Server) SetAttributes(context context.Context, request *proto.SetAttributesReq) (resp *proto.SetAttributesResp, err error)
- func (p Server) StateChange(request *proto.Empty, server proto.Plugin_StateChangeServer) error
- type SetAttribute
- type SetRequest
- type WatchChan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthDevice ¶ added in v1.5.0
type AuthDevice interface { Device // IsAuth 返回设备是否成功认证/配对 IsAuth() bool // Auth 认证/配对 Auth(params map[string]string) error // RemoveAuthorization 取消认证/配对 RemoveAuthorization(params map[string]string) error }
AuthDevice 需要认证的设备
type ChildDevice ¶ added in v1.9.1
type ChildDevice interface {
Online() bool
}
ChildDevice 子设备,暂时只需要Online方法
type DeviceInfo ¶
type Instance ¶
type Instance struct { Type string `json:"type"` InstanceId int `json:"instance_id"` Attributes []Attribute `json:"attributes"` }
func GetDeviceInstances ¶ added in v1.9.1
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) Disconnect ¶ added in v1.5.0
func (*Manager) GetAttributes ¶
func (*Manager) HealthCheck ¶
func (*Manager) IsOTASupport ¶ added in v1.9.1
func (*Manager) RemoveDevice ¶
RemoveDevice 删除设备
func (*Manager) SetAttribute ¶
func (*Manager) SetAttributeNotify ¶ added in v1.9.1
func (*Manager) Unsubscribe ¶
func (*Manager) WatchNotify ¶
type Notification ¶
type OTAProgressState ¶ added in v1.9.1
type OTAProgressState int // OTA进度
const ( OTAFinish OTAProgressState = 100 // OTA成功 OTAUpgradeFail OTAProgressState = -1 // 更新失败 OTADownloadFail OTAProgressState = -2 // 下载失败 OTAValidateFail OTAProgressState = -3 // 校验失败 OTABurnFail OTAProgressState = -4 // 烧写失败 )
func OTAProgress ¶ added in v1.9.1
func OTAProgress(i int) OTAProgressState
type OTAResp ¶ added in v1.9.1
type OTAResp struct {
Step OTAProgressState
}
type OptionFunc ¶
type OptionFunc func(s *Server)
func WithConfigFile ¶
func WithConfigFile(configFile string) OptionFunc
func WithDomain ¶ added in v1.5.0
func WithDomain(domain string) OptionFunc
func WithStatic ¶
func WithStatic(staticDir string) OptionFunc
type ParentDevice ¶ added in v1.9.1
type ParentDevice interface { Device GetChildDeviceById(instanceId int) ChildDevice }
ParentDevice 父设备:拥有子设备的设备
type Server ¶
type Server struct { Manager *Manager Domain string Router *gin.Engine ApiRouter *gin.RouterGroup // contains filtered or unexported fields }
func NewPluginServer ¶
func NewPluginServer(opts ...OptionFunc) *Server
func (Server) Disconnect ¶ added in v1.5.0
func (Server) GetAttributes ¶
func (p Server) GetAttributes(context context.Context, request *proto.GetAttributesReq) (resp *proto.GetAttributesResp, err error)
func (Server) HealthCheck ¶
func (p Server) HealthCheck(context context.Context, req *proto.HealthCheckReq) (resp *proto.HealthCheckResp, err error)
func (Server) SetAttributes ¶
func (p Server) SetAttributes(context context.Context, request *proto.SetAttributesReq) (resp *proto.SetAttributesResp, err error)
func (Server) StateChange ¶
type SetAttribute ¶
type SetRequest ¶
type SetRequest struct {
Attributes []SetAttribute `json:"attributes"`
}
type WatchChan ¶
type WatchChan chan Notification
Click to show internal directories.
Click to hide internal directories.