mqtt

package
v0.0.0-...-33e1650 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIsSetting

func CheckIsSetting(ctx *transport.Context, deviceCode string) map[string]interface{}

CheckIsSetting 检查是否有需要下发的配置

func CheckIsUpgradePatch

func CheckIsUpgradePatch(ctx *transport.Context, deviceCode string) *managev1.UpgradePatch

CheckIsUpgradePatch 检查是否有升级任务

func ReplyMqttDevice

func ReplyMqttDevice(ctx *transport.Context, deviceConfig *managev1.DeviceConfig, needReply bool, c interface{})

ReplyMqttDevice 回复MQTT连接的设备

func ResolvePicData

func ResolvePicData(ctx *transport.Context, msg *vulcanus.DeviceMsg, deviceData *gjson.Result, picData []byte) bool

ResolvePicData 解析图片数据

func ResolveSetting

func ResolveSetting(ctx *transport.Context, msg *vulcanus.DeviceMsg, deviceData *gjson.Result)

ResolveSetting 解析设备状态回复

func ResolveState

func ResolveState(deviceConfig *managev1.DeviceConfig, deviceData *gjson.Result, time string)

ResolveState 解析设备状态数据

func ResolveUpgradeReply

func ResolveUpgradeReply(ctx *transport.Context, msg *vulcanus.DeviceMsg, deviceData *gjson.Result)

ResolveUpgradeReply 解析设备升级回复

func SendSettingInfo

func SendSettingInfo(ctx *transport.Context, deviceConfig *managev1.DeviceConfig, settingInfo map[string]interface{})

SendSettingInfo 发送配置数据包 param: settingInfo 包含 type 和 synInf 字段

func SendUpgradePatch

func SendUpgradePatch(ctx *transport.Context, msg *vulcanus.DeviceMsg, upgradePatch *managev1.UpgradePatch)

SendUpgradePatch 发送设备升级包

Types

type MqttReplyContent

type MqttReplyContent struct {
	Data interface{} `json:"data"`
}

type ReplyContent

type ReplyContent struct {
	Id      string `mapstructure:"id" json:"id"`           // 设备码
	Time    string `mapstructure:"time" json:"time"`       // 回复时间
	Type    int    `mapstructure:"type" json:"type"`       // 类型
	SynInf  int64  `mapstructure:"synInf" json:"synInf"`   // 同步码
	Err     int    `mapstructure:"err" json:"err"`         // 没有错误 0  数据错误 1
	Connect int    `mapstructure:"connect" json:"connect"` // 是否继续通信  0 结束通信  1继续通信
}

func NewReplyContent

func NewReplyContent(id string, _type int, synInf int64, err int, connect int) *ReplyContent

func NewReplyContentSimple

func NewReplyContentSimple(id string, _type int) *ReplyContent

type Server

type Server struct {
	Client mqtt.Client
	// contains filtered or unexported fields
}

Server is an MQTT Consumer wrapper.

func NewServer

func NewServer(ctx *transport.Context, cs []vulcanus.MqttCodec, hs []vulcanus.DataHandler, opts ...ServerOption) *Server

NewServer creates a MQTT consumer by options.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start start the MQTT consumer.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stop the MQTT consumer.

type ServerOption

type ServerOption func(*Server)

func Broker

func Broker(broker string) ServerOption

Broker with server broker.

func ClientId

func ClientId(clientId string) ServerOption

ClientId with server clientId.

func Password

func Password(password string) ServerOption

Password with server password.

func PubTopic

func PubTopic(pubTopic string) ServerOption

PubTopic with server pubTopic.

func SubTopics

func SubTopics(subTopics []string) ServerOption

SubTopics with server subTopics.

func Username

func Username(username string) ServerOption

Username with server username.

type SettingReply

type SettingReply struct {
	Id    int64  `json:"id"`
	Reply string `json:"reply"`
}

type UpgradeReplyContent

type UpgradeReplyContent struct {
	ReplyContent
	Update int    `json:"update"` // 升级标志 1:有升级任务 2:升级中 3:升级完成
	Path   string `json:"path"`
	Pklen  int    `json:"pklen"`
	Crc    uint16 `json:"crc"`
	Uid    uint64 `json:"uid"`
}

Jump to

Keyboard shortcuts

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