mqttclient

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverClientPrefix = "driver-"
	DriverTopicPrefix  = "tedge/driver/"
	InnerTopicPrefix   = "tedge/inner/"

	DriverTX = "tx"
	DriverRX = "rx"
)

同时,username 应该由驱动传入,而不是从专家模式中读取,以及配置文件中的username!!!

View Source
const (
	Auth = iota + 1 // 连接鉴权
	Sub             // 设备订阅校验
	Pub             // 设备发布校验
	UnSub
	Connected
	Closed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncMsg

type AsyncMsg struct {
	Id   int64
	Type int
	Data json.RawMessage
}

type AuthCheck

type AuthCheck struct {
	ClientId string
	Username string
	Password string
	Pass     bool
	Msg      string
}

type ClosedNotify

type ClosedNotify struct {
	ClientId string
	Username string
}

ClosedNotify 三方设备或服务断开连接后通知对应驱动

type ConnectedNotify

type ConnectedNotify struct {
	ClientId string
	Username string
	IP       string
	Port     string
}

ConnectedNotify 三方设备或服务连接成功后通知对应驱动

type MqttClient

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

func NewMqttClient

func NewMqttClient(server, username string, logger commons.TedgeLogger) (*MqttClient, error)

func (*MqttClient) Connect

func (mc *MqttClient) Connect() error

func (*MqttClient) Disconnect

func (mc *MqttClient) Disconnect()

func (*MqttClient) GetOpts

func (mc *MqttClient) GetOpts() *mqtt.ClientOptions

func (*MqttClient) OnConnectHandler

func (mc *MqttClient) OnConnectHandler(handler mqtt.OnConnectHandler) mqtt.OnConnectHandler

func (*MqttClient) Publish

func (mc *MqttClient) Publish(topic string, qos byte, retained bool, message []byte) error

func (*MqttClient) SetClient

func (mc *MqttClient) SetClient(client mqtt.Client)

func (*MqttClient) SetDriver

func (mc *MqttClient) SetDriver(driver commons.MqttDriver)

func (*MqttClient) Subscribe

func (mc *MqttClient) Subscribe(topic string, qos byte, handler mqtt.MessageHandler) error

func (*MqttClient) UnSubscribe

func (mc *MqttClient) UnSubscribe(topic string) error

type PubTopic

type PubTopic struct {
	ClientId string
	Username string
	Topic    string
	QoS      byte
	Retained bool
	Pass     bool
	Msg      string
}

type SubTopic

type SubTopic struct {
	Topic string
	QoS   byte
	Pass  bool
	Msg   string
}

SubTopic 三方设备或服务订阅topic校验

type SubTopics

type SubTopics struct {
	ClientId string
	Username string
	Topics   []SubTopic
}

type UnSubNotify

type UnSubNotify struct {
	ClientId string
	Username string
	Topics   []string
}

Jump to

Keyboard shortcuts

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