1 Star 0 Fork 146

jicky/driver-box

forked from iBUILDING-X/driver-box 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
三刀 提交于 2023-08-01 13:46 . 添加打包工具
package main
import (
"flag"
"github.com/ibuilding-x/driver-box/driverbox"
"github.com/ibuilding-x/driver-box/driverbox/export"
"github.com/ibuilding-x/driver-box/driverbox/helper"
"os"
)
func main() {
//localMode()
var broker string
var clientId string
var username string
var password string
var exportTopic string
flag.StringVar(&broker, "broker", os.Getenv("MQTT_BROKER"), "mqttExport: broker address")
flag.StringVar(&clientId, "clientId", os.Getenv("MQTT_CLIENT_ID"), "mqttExport: clientId")
flag.StringVar(&username, "username", os.Getenv("MQTT_USERNAME"), "mqttExport: username")
flag.StringVar(&password, "password", os.Getenv("MQTT_PASSWORD"), "mqttExport: password")
flag.StringVar(&exportTopic, "exportTopic", os.Getenv("MQTT_EXPORT_TOPIC"), "mqttExport: exportTopic")
flag.Parse()
if len(clientId) == 0 {
clientId = ""
}
helper.DriverConfig.DefaultDeviceTTL = 5
driverbox.Start([]export.Export{&export.MqttExport{
Broker: broker,
ClientID: clientId,
Username: username,
Password: password,
ExportTopic: exportTopic,
}})
}
func localMode() {
_ = os.Setenv("MQTT_BROKER", "mqtt://127.0.0.1:1883")
_ = os.Setenv("MQTT_CLIENT_ID", "123456")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jicky168/driver-box.git
git@gitee.com:jicky168/driver-box.git
jicky168
driver-box
driver-box
master

搜索帮助