完善自我更新逻辑
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package config
|
||||
|
||||
// 变动
|
||||
|
||||
// 常量
|
||||
const (
|
||||
// 版本号
|
||||
APP_VERSION = 1
|
||||
|
||||
Log_file_dic = "./logs"
|
||||
MQTT_BROKER = "tls://ai.ronsunny.cn:8093"
|
||||
PASSWORD = "123456"
|
||||
)
|
||||
|
||||
var (
|
||||
// DeviceType string
|
||||
// DeptId string
|
||||
)
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type MqttTopic struct {
|
||||
Project string
|
||||
DeptId string
|
||||
Domain string
|
||||
DeviceType string
|
||||
DeviceID string
|
||||
@@ -21,7 +21,7 @@ func FromStringToMqttTopic(topic string) *MqttTopic {
|
||||
parts = append(parts, "")
|
||||
}
|
||||
return &MqttTopic{
|
||||
Project: parts[0],
|
||||
DeptId: parts[0],
|
||||
Domain: parts[1],
|
||||
DeviceType: parts[2],
|
||||
DeviceID: parts[3],
|
||||
@@ -38,7 +38,7 @@ func (m *MqttTopic) ToString() string {
|
||||
return s
|
||||
}
|
||||
return strings.Join([]string{
|
||||
toVal(m.Project),
|
||||
toVal(m.DeptId),
|
||||
toVal(m.Domain),
|
||||
toVal(m.DeviceType),
|
||||
toVal(m.DeviceID),
|
||||
@@ -48,7 +48,7 @@ func (m *MqttTopic) ToString() string {
|
||||
|
||||
// 严格生成 topic,不允许 "+" 或空
|
||||
func (m *MqttTopic) Build() (string, error) {
|
||||
parts := []string{m.Project, m.Domain, m.DeviceType, m.DeviceID, m.Resource}
|
||||
parts := []string{m.DeptId, m.Domain, m.DeviceType, m.DeviceID, m.Resource}
|
||||
for _, p := range parts {
|
||||
if p == "" || p == "+" {
|
||||
return "", errors.New("cannot build strict topic, wildcard exists")
|
||||
|
||||
@@ -3,5 +3,5 @@ package model
|
||||
type UpdateInfo struct {
|
||||
Version int `json:"version"`
|
||||
DownloadURL string `json:"url"`
|
||||
Notes bool `json:"notes"`
|
||||
Notes string `json:"notes"`
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package utils
|
||||
|
||||
// 变动
|
||||
|
||||
// 常量
|
||||
const (
|
||||
// 版本号
|
||||
APP_VERSION = 0
|
||||
|
||||
Log_file_dic = "./logs"
|
||||
MQTT_HOST = "ai.ronsunny.cn"
|
||||
MQTT_PORT = 8093
|
||||
PASSWORD = "123456"
|
||||
PROJECT = "sentinel"
|
||||
DEVICE_TPYE = "edge"
|
||||
)
|
||||
Reference in New Issue
Block a user