-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
46 lines (38 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"github.com/ninjasphere/go-ninja/api"
nconfig "github.com/ninjasphere/go-ninja/config"
"github.com/ninjasphere/go-ninja/logger"
"github.com/ninjasphere/go-ninja/support"
"os"
)
var (
info = ninja.LoadModuleInfo("./package.json")
log = logger.GetLogger(info.ID) // gets replaced by NewDriver
config = &ZStackConfig{
Hostname: "localhost",
OtasrvrPort: 2525,
GatewayPort: 2541,
NwkmgrPort: 2540,
StableFlagFile: "/var/run/zigbee.stable", // TODO
}
)
func main() {
config.StableFlagFile = nconfig.String("/var/run/zigbee.stable", "zigbee", "stable-file")
config.Hostname = nconfig.String("localhost", "zigbee", "host")
check, err := os.Open("/etc/disable-zigbee")
if err != nil {
// this is the expected case
_, err := NewDriver(config)
if log.IsDebugEnabled() {
log.Debugf("version - %s - running with configuration %+v", Version, config)
}
if err != nil {
log.Fatalf("Failed to start ZigBee driver: %s", err)
}
} else {
check.Close()
log.Debugf("version - %s - zigbee access disabled by /etc/disable-zigbee", Version)
}
support.WaitUntilSignal()
}