Make sure we only listen to location updates
This commit is contained in:
parent
7d86b83335
commit
4756835b91
9
main.go
9
main.go
|
@ -15,6 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
|
Type string `json:"_type"`
|
||||||
Longitude float32 `json:"lon"`
|
Longitude float32 `json:"lon"`
|
||||||
Latitude float32 `json:"lat"`
|
Latitude float32 `json:"lat"`
|
||||||
Altitude int `json:"alt"`
|
Altitude int `json:"alt"`
|
||||||
|
@ -128,6 +129,12 @@ func main() {
|
||||||
var location Location
|
var location Location
|
||||||
json.Unmarshal(msg.Payload(), &location)
|
json.Unmarshal(msg.Payload(), &location)
|
||||||
|
|
||||||
|
// Make sure that the message we get is a location update
|
||||||
|
// @TODO Find a more elegant way of doing this
|
||||||
|
if location.Type != "location" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(location)
|
fmt.Println(location)
|
||||||
temp := false
|
temp := false
|
||||||
for _, region := range location.InRegions {
|
for _, region := range location.InRegions {
|
||||||
|
@ -159,7 +166,7 @@ func main() {
|
||||||
var brightness uint8 = 0
|
var brightness uint8 = 0
|
||||||
|
|
||||||
// Event loop
|
// Event loop
|
||||||
events:
|
events:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case temp := <-home:
|
case temp := <-home:
|
||||||
|
|
Reference in New Issue
Block a user