Skip to content

Instantly share code, notes, and snippets.

@gerardbos
Created November 8, 2017 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gerardbos/df971f24eef9a8a41b5fccc86d87d7bf to your computer and use it in GitHub Desktop.
Save gerardbos/df971f24eef9a8a41b5fccc86d87d7bf to your computer and use it in GitHub Desktop.
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