aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-01-22 20:42:35 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-01-22 20:42:35 -0500
commit45d39c55e3966d5f6e7f2db962d53a4eab52e53d (patch)
tree3aecf56c71f39af146ec18e2002bfa44b5491bb8
parent15619bdd2fb0350bda4585872598e704896edfeb (diff)
Starting implementation for GetBridgeInfo
-rw-r--r--bridge.go47
1 files changed, 36 insertions, 11 deletions
diff --git a/bridge.go b/bridge.go
index 2a6b97d..00e88c9 100644
--- a/bridge.go
+++ b/bridge.go
@@ -2,6 +2,7 @@ package main
import (
"log"
+ "encoding/xml"
)
func main() {
@@ -11,16 +12,40 @@ func main() {
type Bridge struct {
IPAddress string
Username string
- Debug bool
- Info struct {
- DeviceType string
- FriendlyName string
- ManufacturerURL string
- About string
- ModelName string
- ModelNumber string
- ModelURL string
- SerialNumber string
- UDN string
+ Info Info
+}
+
+Info struct {
+ DeviceType string
+ FriendlyName string
+ ManufacturerURL string
+ About string
+ ModelName string
+ ModelNumber string
+ ModelURL string
+ SerialNumber string
+ UDN string
+}
+
+func NewBridge(ip string) *Bridge {
+ // TODO: if yaml file exists then return
+ bridge := Bridge {
+ IPAddress: ip
+ // TODO: other defaults here
+ }
+
+ response := GetBridgeInfo()
+ bridge.Info = GetBridgeInfo("192.168.1.128") // TODO: IP var
+}
+
+// Go to http://<bridge_ip>/description.xml and parse the info
+func GetBridgeInfo(ip string) Info {
+ data := Info{}
+
+ err := xml.Unmarshal([]byte(data), &data)
+ if err != nil {
+ fmt.Println("GetBridgeInfo error. Cannot parse data from description.")
}
+
+ log.Println("FriendlyName")
}