Selaa lähdekoodia

@author liuqing
@commit 硬编码修改

lq 3 kuukautta sitten
vanhempi
commit
e76a62d11d

+ 1 - 2
cloud/ipolesvr/conf/main.ini

@@ -1,5 +1,4 @@
 [ipolesvr]
 GB28181API = http://192.168.110.28:1985/api/v1/gb28181
 SRSLIVEDIR = /data/live
-
-
+HLDefaultTenant = 100000

+ 13 - 12
cloud/ipolesvr/config.go

@@ -39,13 +39,13 @@ func ParseTopic(topic string) (string, string, string, string, error) {
 }
 
 // ParseTopicHL 获取租户、设备类型、设备编码、MQTT协议topic固定部分(定义在topic.go文件)
-func ParseTopicHL(topic string) (string, string, error) {
+func ParseTopicHL(topic string, defaultTenant string) (string, string, error) {
 	strList := strings.Split(topic, "/")
 	if len(strList) < 4 {
 		return "", "", errors.New("不支持的topic")
 	}
-	if strList[3] == "longchi" {
-		strList[0] = "100000"
+	if strList[3] == "longchi" && defaultTenant != "" {
+		strList[0] = defaultTenant
 	}
 	return strList[0], topic, nil
 }
@@ -61,15 +61,16 @@ func ParseTopicCltLed(topic string) (string, string, string, string, string, err
 }
 
 type MainConfig struct {
-	GB28181API    string
-	SRSLIVEDIR    string
-	SRSLIVEMP4    int
-	SDKAppId      string
-	SecretId      string
-	SecretKey     string
-	SMSKey        string
-	SMSTemplateId string
-	SMSReceiver   []string
+	GB28181API      string
+	SRSLIVEDIR      string
+	SRSLIVEMP4      int
+	SDKAppId        string
+	SecretId        string
+	SecretKey       string
+	SMSKey          string
+	SMSTemplateId   string
+	SMSReceiver     []string
+	HLDefaultTenant string
 }
 
 func (o *MainConfig) ReadConfig(path, sec string) bool {

+ 1 - 1
cloud/ipolesvr/hlzbconcentratormgr.go

@@ -72,7 +72,7 @@ func (o *HlZigbeeConcentratorMgr) Handler(args ...interface{}) interface{} {
 			continue
 		}
 
-		Tenant, t, err := ParseTopicHL(m.Topic())
+		Tenant, t, err := ParseTopicHL(m.Topic(), mainConfig.HLDefaultTenant)
 		if err != nil {
 			continue
 		}

+ 9 - 7
common/protocol/config.go

@@ -23,13 +23,15 @@ type CloudConfig struct {
 }
 
 type AppConfig struct {
-	Name    string      `json:"name"`    //应用名称
-	Tenant  string      `json:"tenant"`  //租户ID
-	GID     string      `json:"gid"`     //网关ID
-	SN      string      `json:"sn"`      //序列号
-	Upgrade bool        `json:"upgrade"` //需要升级
-	Edge    EdgeConfig  `json:"edge"`    //边缘端配置
-	Cloud   CloudConfig `json:"cloud"`   //云端配置
+	Name      string      `json:"name"`      //应用名称
+	Tenant    string      `json:"tenant"`    //租户ID
+	GID       string      `json:"gid"`       //网关ID
+	SN        string      `json:"sn"`        //序列号
+	Upgrade   bool        `json:"upgrade"`   //需要升级
+	UpdateUrl string      `json:"updateurl"` //更新服务URL
+	NtpServer string      `json:"ntpserver"` //NTP服务器地址
+	Edge      EdgeConfig  `json:"edge"`      //边缘端配置
+	Cloud     CloudConfig `json:"cloud"`     //云端配置
 }
 
 // --------------------------------------------------------

+ 2 - 0
edge/ipole/conf/app.json

@@ -4,6 +4,8 @@
   "GID":"T184136721",
   "SN":"202012302040",
   "Upgrade":true,
+  "UpdateUrl":"http://106.52.134.22:8180/",
+  "NtpServer":"106.52.134.22",
   "Edge":{
     "mqtt":{
       "server":"tcp://127.0.0.1:1883",

+ 8 - 4
edge/ipole/main.go

@@ -51,9 +51,9 @@ func GetNextUint64() uint64 {
 func EnableUpdate() {
 	var updater = &selfupdate.Updater{
 		CurrentVersion: version,
-		ApiURL:         "http://106.52.134.22:8180/",
-		BinURL:         "http://106.52.134.22:8180/",
-		DiffURL:        "http://106.52.134.22:8180/",
+		ApiURL:         appConfig.UpdateUrl,
+		BinURL:         appConfig.UpdateUrl,
+		DiffURL:        appConfig.UpdateUrl,
 		Dir:            "update/",
 		CmdName:        appname, // app name
 	}
@@ -91,7 +91,11 @@ func WatchGoforever(args ...interface{}) interface{} {
 // SyncTime 每半小时同步一次时间
 func SyncTime(args ...interface{}) interface{} {
 	for {
-		err := exec.Command("ntpclient", "-h", "106.52.134.22", "-s").Run()
+		if appConfig.NtpServer == "" {
+			time.Sleep(30 * time.Minute)
+			continue
+		}
+		err := exec.Command("ntpclient", "-h", appConfig.NtpServer, "-s").Run()
 		if err != nil {
 			logrus.Errorf("时间同步失败:%s", err.Error())
 		} else {