tcp port和api port设置成配置项

This commit is contained in:
fish 2019-05-07 16:20:29 +08:00
parent 699b2a5273
commit 95a4d57d05
4 changed files with 11 additions and 4 deletions

View File

@ -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
}

View File

@ -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"`
}
//无线 下位机

View File

@ -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

View File

@ -44,9 +44,9 @@ func gw_router() {
}
api_port := strconv.Itoa(conf.APIPORT)
router.Run(":10086")
router.Run(":"+api_port)
}
type DparkConf struct {