Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ReceiveTopic 设置设备主题, 需要提供设备编号 ReceiveTopicFormat = "/receive/%s" // SendDevices 上报主题 SendDevicesTopic = "/send/devices" )
Variables ¶
View Source
var ( // MQTTSecretEnable 是否启用 mqtt 消息加密 MQTTSecretEnable = false // MQTTMsgSecretKey mqtt 消息加密 key, 如果使用3DES 必须保证 24 字节 MQTTSecretKey = "" // MQTTServer mqtt 服务地址 MQTTServer = "localhost:1883" // MQTTUser mqtt 服务连接用户名 MQTTUser = "" // MQTTPassword mqtt 服务连接密码 MQTTPassword = "" // DeviceNo 网关设备编号 DeviceNo = "" // Pannel Address 控制面板地址 DevicePannelAddress = "" // ReceiveTopic 设置设备主题 ReceiveTopic = "" // MQTTClient mqtt client MQTTClient mqtt.Client MQTTClientID = fmt.Sprintf("controller-%d", time.Now().UnixMilli()) )
Functions ¶
Types ¶
type Command ¶
type Command interface {
// Name command name
Name() string
// Msg command mqtt message
Msg() ([]byte, error)
}
Command mqtt command
type CommandResult ¶
type CommandResult struct {
// Command 指令名称
Command string `json:"command"`
// Serial 序列号, 用于反馈于指定请求判断
Serial string `json:"serial"`
// DeviceNo 设备编号
DeviceNo string `json:"device_no"`
// Result 执行结果, 1:成功, 0:失败
Result string `json:"result"`
}
CommandResult 指令执行结果
type ReadStatusCommand ¶
type ReadStatusCommand struct {
Timestamp string `json:"time_stamp"`
Command string `json:"command"`
Serial string `json:"serial"`
}
ReadStatusCommand 读取设备状态指令
func NewReadStatusCommand ¶
func NewReadStatusCommand() *ReadStatusCommand
NewReadStatusCommand 创建读取设备指令
type ReadStatusResult ¶
type ReadStatusResult struct {
Timestamp string `json:"time_stamp"`
// Command 指令名称
Command string `json:"command"`
// Serial 序列号, 用于反馈于指定请求判断
Serial string `json:"serial"`
// DeviceNo 设备编号
DeviceNo string `json:"device_no"`
// Panels 控制面板列表
Panels []Panel `json:"panels"`
}
ReadStatusResult 读取网关设备状态结果
func NewReadStatusResult ¶
func NewReadStatusResult(deviceNo string) *ReadStatusResult
NewReadStatusResult 创建设备状态结果
type SetPanelsCommand ¶
type SetPanelsCommand struct {
// Command 指令名称, 如 set_panels
Command string `json:"command" jsonschema:"description=指令名称"`
// Serial 序列号
Serial string `json:"serial" jsonschema:"description=序列号"`
// DeviceNo 设备编号, 如 c49878f1e235
DeviceNo string `json:"device_no" jsonschema:"description=设备编号"`
// Panels 控制面板列表
Panels []Panel `json:"panels" jsonschema:"description=控制面板列表"`
// TimeStamp 时间戳
Timestamp string `json:"time_stamp" jsonschema:"description=时间戳"`
}
SetPanelsCommand 设置面板指令
func NewSetPanelsCommand ¶
func NewSetPanelsCommand() *SetPanelsCommand
NewSetPanelsCommand 创建设置面板指令
func NewSetPanelsCommandWithDevice ¶
func NewSetPanelsCommandWithDevice(device Device) *SetPanelsCommand
NewSetPanelsCommandWithDevice create a set panels command with device
Click to show internal directories.
Click to hide internal directories.