-
-
Save brutella/6e2eb0783701589d492be1592cff59ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Steps to get this running | |
// 1. Install Go: http://golang.org/doc/install | |
// 2. Setup Go workspace: http://golang.org/doc/code.html#Organization | |
// 3. Download dependencies in Terminal.app | |
// 3.1 Navigate to multiswitchtest.go | |
// 3.2 Execute `go get` | |
// 4. Run `go run multiswitchtest.go` | |
package main | |
import ( | |
"strconv" | |
"github.com/brutella/hc" | |
"github.com/brutella/hc/log" | |
"github.com/brutella/hc/accessory" | |
) | |
func main(){ | |
log.Debug.Enable() | |
accessory_cnt := 18 | |
hc_config := hc.Config{Pin: "56781234", StoragePath: "./db"} | |
info := accessory.Info{ | |
Name: "0", | |
SerialNumber: "0", | |
} | |
switch1 := accessory.NewSwitch(info) | |
var switches[] *accessory.Accessory | |
for i := 1; i < accessory_cnt; i++ { | |
info_ := accessory.Info{ | |
Name: strconv.Itoa(i), | |
SerialNumber: strconv.Itoa(i), | |
} | |
s := accessory.NewSwitch(info_); | |
switches = append(switches, s.Accessory) | |
} | |
t, err := hc.NewIPTransport(hc_config, switch1.Accessory, switches...) | |
if(err != nil){ | |
log.Info.Fatal("Error starting Transport. Error: ", err) | |
} | |
hc.OnTermination(func(){ | |
log.Info.Println("Stopping transport") | |
<-t.Stop() | |
}) | |
t.Start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment