stgmqtt

package
v0.0.0-...-91c7ab2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README

此模块实现国网物联网通用部分的协议,适用于江苏、四川物联网上送

Documentation

Index

Constants

View Source
const (
	Vs_Js = "jiangsu"
	Vs_Sc = "sichuang"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppI

type AppI interface {
	//Run 启动运行守护程序
	Run()
	//Stop 停止运行守护程序
	Stop()
	ReportStatus() error
	ReportEvent(containerName, appName string, event model.EventType, msg string) error
}

AppI app相关的操作

type Client

type Client interface {
	Run()

	AddTerminal(info Terminal) (iotDeviceID string, err error)
	DelTerminal(deviceSN string) error
	UpdateTerminalStatus(deviceSN string, online bool) error

	//ReportData 业务数据
	ReportData(deviceSN string, method string, data interface{}) error
	//ReportEvent 业务事件
	ReportEvent(deviceSN string, method string, data interface{}) error
}

func NewStgMqtt

func NewStgMqtt(ops Options, handler MessageHandler) (Client, error)

type ContainerI

type ContainerI interface {
	//Run 启动运行守护程序
	Run()
	//Stop 停止运行守护程序
	Stop()

	ReportStatus() error
	ReportEvent(containName string, event model.EventType, msg string) error
}

ContainerI 容器相关的操作

type DevInfo

type DevInfo = model.DevInfo

type MessageHandler

type MessageHandler interface {
	OnConnect()
	OnConnectionLost(reason error)

	OnSysSetConfig(SystemConfig) error
}

type Options

type Options struct {
	InstVersion Version // stgmqtt实例的版本

	DevInfo      DevInfo
	SystemConfig SystemConfig

	IotPlatformAddr    string // 物联平台的地址
	IotPlatformVersion string // 物联平台的版本

	MqttVersion         string // 物联网协议版本
	MqttBrokers         []string
	MqttClientID        string
	MqttUsername        string
	MqttPassword        string
	MqttQOS             uint8
	MqttResponseTimeout time.Duration // 响应超时时间

	StoreDir string //持久化存储目录
}

func (Options) Check

func (ops Options) Check() error

Check 检查配置是否有效

type ServiceI

type ServiceI interface {
	//Run 启动运行守护程序
	Run()
	//Stop 停止运行守护程序
	Stop()
	//ReportData 业务数据上报
	ReportData(iotDeviceID string, method string, data interface{}) error
	//ReportEvent 业务事件上报
	ReportEvent(iotDeviceID string, method string, data interface{}) error
}

ServiceI 业务相关的操作

type StgMqtt

type StgMqtt struct {
	sync.RWMutex

	SystemI
	TopoI
	ServiceI
	AppI
	ContainerI
	// contains filtered or unexported fields
}

func (*StgMqtt) AddTerminal

func (stg *StgMqtt) AddTerminal(info model.TerminalInfo) (iotDeviceID string, err error)

func (*StgMqtt) DelTerminal

func (stg *StgMqtt) DelTerminal(deviceSN string) error

func (*StgMqtt) ReportData

func (stg *StgMqtt) ReportData(deviceSN string, method string, data interface{}) error

func (*StgMqtt) ReportEvent

func (stg *StgMqtt) ReportEvent(deviceSN string, method string, data interface{}) error

func (*StgMqtt) Run

func (stg *StgMqtt) Run()

func (*StgMqtt) UpdateTerminalStatus

func (stg *StgMqtt) UpdateTerminalStatus(deviceSN string, online bool) error

type SystemConfig

type SystemConfig = model.SystemConfig

type SystemI

type SystemI interface {
	//Run 启动运行守护程序
	Run()
	//Stop 停止运行守护程序
	Stop()
	//LinkUp 设备接入
	LinkUp() error
	//LinkDown 设备断开
	LinkDown(reason string) error
	//GetIotCurTime 获取物联网平台当前时间
	GetIotCurTime() (time.Time, error)
	//ReportStatus 上报设备状态
	ReportStatus() error
	//ReportEvent 设备事件上报
	ReportEvent(event model.EventType, info string) error
}

SystemI 设备、系统相关的操作

type Terminal

type Terminal = model.TerminalInfo

type TopoI

type TopoI interface {
	//Run 启动运行守护程序
	Run()
	//Stop 停止运行守护程序
	Stop()
	AddTerminal(info model.TerminalInfo) (iotDeviceID string, err error)
	DelTerminal(deviceID string) error
	UpdateTerminalStatus(deviceID string, status model.DeviceStatus) error
}

TopoI 设备拓扑相关

type Version

type Version string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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