|
@ -5,7 +5,7 @@ import ( |
|
|
"context" |
|
|
"context" |
|
|
"flag" |
|
|
"flag" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"git.aiterp.net/lucifer/new-server/internal/drivers/nanoleaf" |
|
|
|
|
|
|
|
|
"git.aiterp.net/lucifer/new-server/app/config" |
|
|
"git.aiterp.net/lucifer/new-server/models" |
|
|
"git.aiterp.net/lucifer/new-server/models" |
|
|
"log" |
|
|
"log" |
|
|
"os" |
|
|
"os" |
|
@ -15,7 +15,7 @@ import ( |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var flagDriver = flag.String("driver", "Nanoleaf", "The bridge driver to use") |
|
|
|
|
|
|
|
|
var flagDriver = flag.String("driver", string(models.DTNanoLeaf), "The bridge driver to use") |
|
|
var flagAddress = flag.String("address", "127.0.0.1", "The bridge's address") |
|
|
var flagAddress = flag.String("address", "127.0.0.1", "The bridge's address") |
|
|
var flagToken = flag.String("token", "", "The bridge's access token / api key / login") |
|
|
var flagToken = flag.String("token", "", "The bridge's access token / api key / login") |
|
|
var flagPair = flag.Bool("pair", false, "Try to pair with the bridge.") |
|
|
var flagPair = flag.Bool("pair", false, "Try to pair with the bridge.") |
|
@ -25,8 +25,11 @@ var flagSearchTimeout = flag.Duration("search-timeout", time.Second*3, "Timeout |
|
|
func main() { |
|
|
func main() { |
|
|
flag.Parse() |
|
|
flag.Parse() |
|
|
|
|
|
|
|
|
// TODO: Select driver
|
|
|
|
|
|
driver := nanoleaf.Driver{} |
|
|
|
|
|
|
|
|
// Find drivers
|
|
|
|
|
|
driver, err := config.DriverProvider().Provide(models.DriverKind(*flagDriver)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalln("Failed to find driver:", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Find bridge
|
|
|
// Find bridge
|
|
|
bridges, err := driver.SearchBridge(context.Background(), *flagAddress, !*flagPair) |
|
|
bridges, err := driver.SearchBridge(context.Background(), *flagAddress, !*flagPair) |
|
|