dpmqtt

package
v0.0.0-...-3e55329 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DemoMqttDPDriver

type DemoMqttDPDriver struct {
	// contains filtered or unexported fields
}
  1. DemoMqttDPDriver 必须实现接口 `type DPModelDriver interface` 接口定义:`tedge-driver-sdk-go/dpmodel/interface.go`

func NewDemoMqttDPDriver

func NewDemoMqttDPDriver(dpDs *service.DPDriverService) *DemoMqttDPDriver

func (*DemoMqttDPDriver) DeviceNotify

func (dd *DemoMqttDPDriver) DeviceNotify(ctx context.Context, action commons.DeviceNotifyType, cid string, device commons.DeviceInfo) error

1.在Tedge控制台页面,新增、激活、更新子设备属性、删除子设备时,回调该接口 2.注意:不要在该接口做阻塞性操作 3.如果接入的设备不需要在Tedge控制台页面手动新增子设备,则该接口实现为空即可

func (*DemoMqttDPDriver) GetMqtt

func (dd *DemoMqttDPDriver) GetMqtt() *MqttItf

////////////////////////////////////////////////////////////////////////////////////////////////

func (*DemoMqttDPDriver) GetMqttUsername

func (dd *DemoMqttDPDriver) GetMqttUsername() string

func (*DemoMqttDPDriver) HandleCommands

func (dd *DemoMqttDPDriver) HandleCommands(ctx context.Context, cid string, msg dpmodel.CommandRequest, protocols map[string]commons.ProtocolProperties, dpExtend dpmodel.DPExtendInfo) error

//////////////////////////////////////////////////////////////////////////////////////// 1.接收 Tedge/云端 下发的MQTT消息 2.注意:不要在该接口做阻塞性操作

func (*DemoMqttDPDriver) ProductNotify

1.ProductNotify 产品增删改通知,删除产品时product参数为空 2.注意:不要在该接口做阻塞性操作

func (*DemoMqttDPDriver) Run

func (dd *DemoMqttDPDriver) Run() error

////////////////////////////////////////////////////////////////////////////////////////////////

func (*DemoMqttDPDriver) Stop

func (dd *DemoMqttDPDriver) Stop(ctx context.Context) error

在Tedge页面,更新驱动实例,或停止驱动实例时,回调该接口,驱动程序进行资源清理

type DriverConfig

type DriverConfig struct {
	HttpConf HttpConfig `yaml:"httpconf"`
	MqttConf MqttConfig `yaml:"mqttconf"`
}

//////////////////////////////////////////////////////////////////////////////////////

type HttpConfig

type HttpConfig struct {
	Listen string `yaml:"listen"`
}

type MqttConfig

type MqttConfig struct {
	Username string `yaml:"username"`
}

type MqttItf

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

func NewMqttItf

func NewMqttItf(dpDriver *DemoMqttDPDriver) *MqttItf

func (*MqttItf) Auth

func (m *MqttItf) Auth(clientId, username, password string) (bool, error)

func (*MqttItf) Closed

func (m *MqttItf) Closed(clientId, username string)

func (*MqttItf) ConnectHandler

func (m *MqttItf) ConnectHandler(client mqtt.Client)

func (*MqttItf) Connected

func (m *MqttItf) Connected(clientId, username, ip, port string)

func (*MqttItf) Pub

func (m *MqttItf) Pub(clientId, username, topic string, qos byte, retained bool) (bool, error)

func (*MqttItf) Sub

func (m *MqttItf) Sub(clientId, username, topic string, qos byte) (bool, error)

func (*MqttItf) UnSub

func (m *MqttItf) UnSub(clientId, username string, topics []string)

Jump to

Keyboard shortcuts

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