Skip to content
Snippets Groups Projects
Commit 93ee66bf authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Get ride of the engine global variable

parent af81c797
Branches
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ func newDevices(bDevice *BridgeDevice) {
setupDevice(dev, bDevice)
dev.Dump()
bDevice.XAALDevice = append(bDevice.XAALDevice, dev)
eng.AddDevice(dev)
GetGW().engine.AddDevice(dev)
}
}
}
......@@ -4,15 +4,19 @@ import (
"sync"
"gitlab.imt-atlantique.fr/xaal/code/go/core/uuid"
"gitlab.imt-atlantique.fr/xaal/code/go/core/xaal"
)
type gateway struct {
engine *xaal.Engine
devices []*BridgeDevice
baseAddr uuid.UUID
}
var instance *gateway
var once sync.Once
var (
instance *gateway
once sync.Once
)
func GetGW() *gateway {
once.Do(func() {
......
......@@ -7,10 +7,6 @@ import (
"gitlab.imt-atlantique.fr/xaal/code/go/core/xaal"
)
var (
eng *xaal.Engine
)
func main() {
mqttBroker := flag.String("broker", "", "The MQTT broker URL")
flag.Parse()
......@@ -24,7 +20,8 @@ func main() {
// client.Publish("zigbee2mqtt/0x70b3d52b600f89d3/set", 0, false, `{"state": "toggle"}`)
xaal.SetupLogger()
eng = xaal.NewEngine()
eng := xaal.NewEngine()
GetGW().engine = eng
eng.Run()
client.Disconnect(250)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment