Documentation ¶
Index ¶
- Constants
- Variables
- func ParseTopic(topic string) (string, error)
- func Run(handle func(Context) error)
- type Context
- type DeltaCallback
- type DeviceEvent
- type DeviceInfo
- type DevicePropConfigs
- type DeviceProperties
- type DeviceShadow
- type DmCtx
- func (c *DmCtx) Close() error
- func (c *DmCtx) GetAllDevices() []DeviceInfo
- func (c *DmCtx) GetDevicePropConfigs() (map[string]DevicePropConfigs, error)
- func (c *DmCtx) GetDeviceProperties(info *DeviceInfo) (*DeviceShadow, error)
- func (c *DmCtx) GetDriverConfig() (string, error)
- func (c *DmCtx) Offline(info *DeviceInfo) error
- func (c *DmCtx) Online(info *DeviceInfo) error
- func (c *DmCtx) RegisterDeltaCallback(info *DeviceInfo, cb DeltaCallback)
- func (c *DmCtx) RegisterEventCallback(info *DeviceInfo, cb EventCallback)
- func (c *DmCtx) ReportDeviceProperties(info *DeviceInfo, props *DeviceProperties) error
- func (c *DmCtx) Start()
- func (c *DmCtx) SystemConfigExt() *SystemConfig
- type EventCallback
- type SystemConfig
- type Topic
Constants ¶
View Source
const ( DefaultDriverConf = "/etc/baetyl/driver.yml" DefaultPropsConf = "/etc/baetyl/props.yml" KeyDevice = "device" KeyStatus = "status" OnlineStatus = "online" OfflineStatus = "offline" )
View Source
const (
DeviceTopicRe = "\\$baetyl/device/(.+)/(.+)"
)
Variables ¶
View Source
var ( ErrCallbackNotRegister = errors.New("callback not registered yet") ErrInvalidCallback = errors.New("invalid device callback") ErrInvalidMessage = errors.New("invalid device message") ErrInvalidChannel = errors.New("invalid channel") ErrResponseChannelNotExist = errors.New("response channel not exist") )
Functions ¶
func ParseTopic ¶ added in v2.1.8
Types ¶
type Context ¶
type Context interface { context.Context SystemConfigExt() *SystemConfig GetAllDevices() []DeviceInfo ReportDeviceProperties(info *DeviceInfo, props *DeviceProperties) error GetDeviceProperties(info *DeviceInfo) (*DeviceShadow, error) RegisterDeltaCallback(info *DeviceInfo, cb DeltaCallback) RegisterEventCallback(info *DeviceInfo, cb EventCallback) Online(info *DeviceInfo) error Offline(info *DeviceInfo) error GetDriverConfig() (string, error) GetDevicePropConfigs() (map[string]DevicePropConfigs, error) Start() io.Closer }
func NewContext ¶
type DeltaCallback ¶
type DeltaCallback func(*DeviceInfo, *DeviceProperties) error
type DeviceEvent ¶
type DeviceEvent struct { Name string `json:"name,omitempty"` Event interface{} `json:"event,omitempty"` }
type DeviceInfo ¶
type DevicePropConfigs ¶
type DeviceProperties ¶
type DeviceShadow ¶
type DmCtx ¶
func (*DmCtx) GetAllDevices ¶
func (c *DmCtx) GetAllDevices() []DeviceInfo
func (*DmCtx) GetDevicePropConfigs ¶
func (c *DmCtx) GetDevicePropConfigs() (map[string]DevicePropConfigs, error)
func (*DmCtx) GetDeviceProperties ¶
func (c *DmCtx) GetDeviceProperties(info *DeviceInfo) (*DeviceShadow, error)
func (*DmCtx) GetDriverConfig ¶
func (*DmCtx) Offline ¶
func (c *DmCtx) Offline(info *DeviceInfo) error
func (*DmCtx) Online ¶
func (c *DmCtx) Online(info *DeviceInfo) error
func (*DmCtx) RegisterDeltaCallback ¶
func (c *DmCtx) RegisterDeltaCallback(info *DeviceInfo, cb DeltaCallback)
func (*DmCtx) RegisterEventCallback ¶
func (c *DmCtx) RegisterEventCallback(info *DeviceInfo, cb EventCallback)
func (*DmCtx) ReportDeviceProperties ¶
func (c *DmCtx) ReportDeviceProperties(info *DeviceInfo, props *DeviceProperties) error
func (*DmCtx) SystemConfigExt ¶
func (c *DmCtx) SystemConfigExt() *SystemConfig
type EventCallback ¶
type EventCallback func(*DeviceInfo, *DeviceEvent) error
type SystemConfig ¶
type SystemConfig struct { context.SystemConfig `yaml:",inline" json:",inline"` Devices []DeviceInfo `yaml:"devices,omitempty" json:"devices,omitempty"` }
type Topic ¶
type Topic struct { Delta mqtt2.QOSTopic `yaml:"delta,omitempty" json:"delta,omitempty"` Report mqtt2.QOSTopic `yaml:"report,omitempty" json:"report,omitempty"` Event mqtt2.QOSTopic `yaml:"event,omitempty" json:"event,omitempty"` Get mqtt2.QOSTopic `yaml:"get,omitempty" json:"get,omitempty"` GetResponse mqtt2.QOSTopic `yaml:"getResponse,omitempty" json:"getResponse,omitempty"` }
Click to show internal directories.
Click to hide internal directories.