Documentation ¶
Index ¶
- type DemoMqttDPDriver
- func (dd *DemoMqttDPDriver) DeviceNotify(ctx context.Context, action commons.DeviceNotifyType, cid string, ...) error
- func (dd *DemoMqttDPDriver) GetMqtt() *MqttItf
- func (dd *DemoMqttDPDriver) GetMqttUsername() string
- func (dd *DemoMqttDPDriver) HandleCommands(ctx context.Context, cid string, msg dpmodel.CommandRequest, ...) error
- func (dd *DemoMqttDPDriver) ProductNotify(ctx context.Context, t commons.ProductNotifyType, pid string, ...) error
- func (dd *DemoMqttDPDriver) Run() error
- func (dd *DemoMqttDPDriver) Stop(ctx context.Context) error
- type DriverConfig
- type HttpConfig
- type MqttConfig
- type MqttItf
- func (m *MqttItf) Auth(clientId, username, password string) (bool, error)
- func (m *MqttItf) Closed(clientId, username string)
- func (m *MqttItf) ConnectHandler(client mqtt.Client)
- func (m *MqttItf) Connected(clientId, username, ip, port string)
- func (m *MqttItf) Pub(clientId, username, topic string, qos byte, retained bool) (bool, error)
- func (m *MqttItf) Sub(clientId, username, topic string, qos byte) (bool, error)
- func (m *MqttItf) UnSub(clientId, username string, topics []string)
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
}
- 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 ¶
func (dd *DemoMqttDPDriver) ProductNotify(ctx context.Context, t commons.ProductNotifyType, pid string, product dpmodel.DPModelProduct) error
1.ProductNotify 产品增删改通知,删除产品时product参数为空 2.注意:不要在该接口做阻塞性操作
func (*DemoMqttDPDriver) Run ¶
func (dd *DemoMqttDPDriver) Run() error
////////////////////////////////////////////////////////////////////////////////////////////////
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) ConnectHandler ¶
Click to show internal directories.
Click to hide internal directories.