diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-01-24 23:36:07 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-01-24 23:36:07 -0500 |
commit | 3d0ad2f5e81c734bc0ca6364d2ea7c966ef5dbb9 (patch) | |
tree | f7cab7f6cf2a89e18cf5f6c251847c0fe0330737 | |
parent | c05519e646091a1791aa278f468962407e691bc3 (diff) |
Improved function header documentation format.
-rw-r--r-- | bridge.go | 7 | ||||
-rw-r--r-- | lights.go | 4 |
2 files changed, 8 insertions, 3 deletions
@@ -1,7 +1,6 @@ package main // username: 319b36233bd2328f3e40731b23479207 - import ( "log" "os" @@ -15,6 +14,8 @@ import ( func main() { bridge := NewBridge("192.168.1.128", "319b36233bd2328f3e40731b23479207") log.Println(bridge.IPAddress) + + GetAllLights(bridge) } type Bridge struct { @@ -42,6 +43,7 @@ type Device struct { UDN string `xml:"UDN"` } +// NewBridge defines hardware that is compatible with Hue. func NewBridge(ip string, username string) *Bridge { bridge := Bridge { IPAddress: ip, @@ -52,7 +54,8 @@ func NewBridge(ip string, username string) *Bridge { return &bridge } -// Go to http://<bridge_ip>/description.xml set the bridge.Info +// GetBridgeInfo retreives the description.xml file from the bridge. +// Go to http://<bridge_ip>/description.xml func GetBridgeInfo(self *Bridge) { response, error := http.Get("http://" + self.IPAddress + "/description.xml") if error != nil { @@ -32,6 +32,8 @@ type Light struct { //http://192.168.1.128/api/319b36233bd2328f3e40731b23479207/lights/ // http://<bridge_ip>/api/<username>/lights/ + +// GetAllLights retreives the state of all lights that the bridge is aware of. func GetAllLights(bridge *Bridge) { response, error := http.Get( fmt.Sprintf("http://%s/api/%s/lights/", bridge.IPAddress, bridge.Username)) @@ -50,7 +52,7 @@ func GetAllLights(bridge *Bridge) { os.Exit(1) } - data := []Light{} + data := Light{} error = json.Unmarshal(body, &data) if error != nil { trace("", error) |