Documentation
¶
Overview ¶
Package plugin 插件模块
Index ¶
- Variables
- func AddDevice(d *entity.Device, tx *gorm.DB) (err error)
- func ArchiveURL(pluginID string, req *http.Request) string
- func BuildFromDir(path, tag string) (imageID string, err error)
- func BuildFromTar(tarPath string) (imageID string, err error)
- func DefaultOnDeviceStateChange(d entity.Device, attr entity.Attribute) error
- func EndPointsManager() (manager endpoints.Manager, err error)
- func GetControlAttributeByID(d entity.Device, instanceID int, attr string) (attribute entity.Attribute, err error)
- func GetControlAttributes(d entity.Device) (attributes []entity.Attribute, err error)
- func GetInstanceControlAttributes(instance Instance) (attributes []entity.Attribute)
- func LogoURL(req *http.Request, d entity.Device) string
- func NewClient(callbacks ...OnDeviceStateChange) *client
- func NewDiscovery(cli *client) *discovery
- func NewManager() *manager
- func PluginURL(d entity.Device, req *http.Request, token string) string
- func RelativeControlPath(d entity.Device, token string) string
- func RemoveDevice(deviceID int) (err error)
- func SetAttributes(areaID uint64, pluginID, identity string, data json.RawMessage) (err error)
- func SetGlobalClient(c Client)
- func SetGlobalManager(m Manager)
- func StaticURL(pluginID, relativePath string, req *http.Request) string
- func UpdateShadowReported(d entity.Device, attr entity.Attribute) (err error)
- type Attribute
- type Client
- type Device
- type DeviceAttributes
- type DeviceType
- type DiscoverResponse
- type Info
- type Instance
- type Manager
- type OnDeviceStateChange
- type Plugin
- func (p Plugin) BrandLogoURL(req *http.Request) string
- func (p Plugin) Install() (err error)
- func (p Plugin) IsAdded() bool
- func (p Plugin) IsDevelopment() bool
- func (p Plugin) IsNewest() bool
- func (p Plugin) IsRunning() bool
- func (p Plugin) Remove() (err error)
- func (p Plugin) Up() (err error)
- func (p Plugin) Update() (err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var NotExistErr = errors.New("plugin not exist")
Functions ¶
func BuildFromDir ¶
BuildFromDir 从源码编译镜像
func BuildFromTar ¶
BuildFromTar 从源码tar压缩包中build镜像
func EndPointsManager ¶
func GetControlAttributeByID ¶
func GetControlAttributeByID(d entity.Device, instanceID int, attr string) (attribute entity.Attribute, err error)
GetControlAttributeByID 获取设备属性(不包括设备型号、厂商等属性)
func GetControlAttributes ¶
GetControlAttributes 获取设备属性(不包括设备型号、厂商等属性)
func GetInstanceControlAttributes ¶
GetInstanceControlAttributes 获取实例的控制属性
func NewClient ¶
func NewClient(callbacks ...OnDeviceStateChange) *client
func NewDiscovery ¶
func NewDiscovery(cli *client) *discovery
func NewManager ¶
func NewManager() *manager
func RelativeControlPath ¶
RelativeControlPath 返回设备的插件控制页相对路径
func SetAttributes ¶
func SetAttributes(areaID uint64, pluginID, identity string, data json.RawMessage) (err error)
SetAttributes 通过插件设置设备的属性
func SetGlobalClient ¶
func SetGlobalClient(c Client)
func SetGlobalManager ¶
func SetGlobalManager(m Manager)
Types ¶
type Client ¶
type Client interface {
DevicesDiscover(ctx context.Context) <-chan DiscoverResponse
GetAttributes(device entity.Device) (DeviceAttributes, error)
SetAttributes(device entity.Device, data json.RawMessage) (result []byte, err error)
HealthCheck(entity.Device) error
IsOnline(entity.Device) bool
Disconnect(entity.Device) error
DeviceInfo(entity.Device) Info
}
func GetGlobalClient ¶
func GetGlobalClient() Client
type Device ¶
type Device struct {
Model string `json:"model"`
Name string `json:"name"`
Type DeviceType `json:"type"` // 设备类型
Logo string `json:"logo" yaml:"logo"` // 设备logo相对路径
Control string `json:"control" yaml:"control"` // 设备控制页面相对路径
Provisioning string `json:"provisioning" yaml:"provisioning"` // 设备置网页面相对路径
}
type DeviceAttributes ¶
type DeviceAttributes struct {
Identity string `json:"identity"`
Instances []Instance `json:"instances"`
Online bool `json:"online"`
}
func GetUserDeviceAttributes ¶
func GetUserDeviceAttributes(areaID uint64, userID int, pluginID, identity string) (das DeviceAttributes, err error)
GetUserDeviceAttributes 获取用户设备的属性(包括权限)
type DeviceType ¶
type DeviceType string
const ( TypeLight DeviceType = "light" // 灯 TypeSwitch DeviceType = "switch" // 开关 TypeOutlet DeviceType = "outlet" // 插座 TypeRoutingGateway DeviceType = "routing_gateway" // 路由网关 TypeSecurity DeviceType = "security" // 安防 )
type DiscoverResponse ¶
type Manager ¶
type Manager interface {
// Load 加载并返回所有插件
Load() (map[string]*Plugin, error)
Get(id string) (*Plugin, error)
}
func GetGlobalManager ¶
func GetGlobalManager() Manager
type OnDeviceStateChange ¶
type Plugin ¶
type Plugin struct {
ID string `json:"id"`
Image docker.Image `json:"image"`
LogoURL string `json:"logo_url"`
Version string `json:"version"`
Brand string `json:"brand"`
Info string `json:"info"`
DownloadURL string `json:"download_url"` // 插件静态文件下载地址
SupportDevices []*Device `json:"support_devices"`
Source string `json:"source"` // 插件来源
AreaID uint64 `json:"area_id"`
}
func LoadPluginFromZip ¶
LoadPluginFromZip 从压缩包中加载插件
func LoadPluginInfo ¶
LoadPluginInfo 加载插件信息
func (Plugin) BrandLogoURL ¶
BrandLogoURL 插件logo的地址
Source Files
¶
Click to show internal directories.
Click to hide internal directories.