12345678910111213141516171819202122232425262728293031323334353637383940 |
- package main
- import (
- "fmt"
- "smart_tunnel_edge/mqtt"
- "smart_tunnel_edge/util"
- "smart_tunnel_edge/util/config"
- "smart_tunnel_edge/util/logger"
- )
- func main() {
- logger.InitLog() //初始化日志
- mqtt.InitMqtt() //初始化mqtt
- err := config.LoadSerialConfig()
- if err != nil {
- logger.Logger.Errorf("加载串口配置失败: %v", err)
- return
- }
- //打开串口并监听
- if err := util.OpenSerialPort(config.SerialConfig.SerialMap); err != nil {
- fmt.Printf("处理串口时发生错误: %v", err)
- return
- }
- //初始化设备
- err = config.LoadDevConfig()
- if err != nil {
- logger.Logger.Errorf("加载设备配置失败: %v", err)
- return
- }
- for _, dev := range config.DevConfig.EnvDevs { //循环设备制定采集任务
- go util.StartDeviceCollection(dev)
- }
- go util.TimeTasks()
- select {}
- }
|