package main
import (
"context"
"net/http"
"github.com/MrEhbr/homekit"
"github.com/brutella/hc"
"github.com/brutella/hc/accessory"
"github.com/brutella/hc/log"
)
func main() {
// create an accessory
info := accessory.Info{Name: "Lamp"}
ac := accessory.NewSwitch(info)
t, err := homekit.NewTransport(12345, "config", "00102003", ac.Accessory)
if err != nil {
log.Info.Panic(err)
}
ctx, cancel := context.WithCancel(context.Background())
hc.OnTermination(func() {
cancel()
})
if err := t.Run(ctx); err != nil && err != http.ErrServerClosed {
log.Info.Printf("transport Run error: %s", err)
}
}
go get -u github.com/MrEhbr/homekit
transport.go, config.go are forked from the github.com/brutella/hc package.
Those files are Copyright (c) 2017, Matthias Hochgatterer and subject to the conditions in LICENSE.
Any added files (such as storage.go) are subject to the conditions in the Homekit LICENSE file
© 2020 [Alexey Burmistrov]
Licensed under the Apache License, Version 2.0 (LICENSE
). See the COPYRIGHT
file for more details.
SPDX-License-Identifier: Apache-2.0