diff --git a/conf/gateway.conf b/conf/gateway.conf index 6d3bb94..510fe3a 100644 --- a/conf/gateway.conf +++ b/conf/gateway.conf @@ -212,5 +212,7 @@ "openserial":false, "open_tcp_server":true, "check_serial":true, - "dpark_location":"spaoDevs" + "dpark_location":"spaoDevs", + "tcp_port":10090, + "api_port":10086 } diff --git a/loadconfig.go b/loadconfig.go index 4987793..28ca5e8 100644 --- a/loadconfig.go +++ b/loadconfig.go @@ -37,6 +37,8 @@ type Conf struct { CHECKSERIAL bool `json:"check_serial"` LORANODES []LoraNode `json:"lora_nodes"` DPARKLOCATION string `json:"dpark_location"` + TCPPORT int `json:"tcp_port"` + APIPORT int `json:"api_port"` } //无线 下位机 diff --git a/main.go b/main.go index 0142154..752137e 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "log" "net" "os" + "strconv" ) var err error @@ -42,7 +43,9 @@ func main() { c.AddFunc("0, 0, *, *, *, *", get_weather) c.Start() - listener, err := net.Listen("tcp", "0.0.0.0:10090") + tcp_port := strconv.Itoa(conf.TCPPORT) + + listener, err := net.Listen("tcp", "0.0.0.0:"+tcp_port) if err != nil { log.Printf("listen fail, err: %v\n", err) return diff --git a/router.go b/router.go index 7b7a111..c1ae26e 100644 --- a/router.go +++ b/router.go @@ -44,9 +44,9 @@ func gw_router() { } + api_port := strconv.Itoa(conf.APIPORT) - - router.Run(":10086") + router.Run(":"+api_port) } type DparkConf struct {