Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaz committed Apr 9, 2016
1 parent 590f71c commit 261c4d4
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 548 deletions.
4 changes: 2 additions & 2 deletions examples/getTag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func main() {
Password: strings.TrimSpace(*password), // Your password here.
Address: net.ParseIP(strings.TrimSpace(*address)), // Base station IP.
}
fmt.Println(*tag)

record, err := station.GetProperty(*tag)
if nil != err {
panic(err)
}

fmt.Printf("Got back prop: %s\n", record.Tag)

if airport.EncryptionEncryped == record.Encryption {
if airport.EncryptionEncrypted == record.Encryption {
fmt.Println("Encrypted")
} else {
fmt.Println("Unencrypted")
Expand Down
15 changes: 6 additions & 9 deletions src/airport.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package airport

import (
"net"
"bytes"
"io"
"net"
)

// Airport TODO
Expand All @@ -20,21 +20,18 @@ func (a *Airport) Reboot() error {
}

// GetStationName TODO
func (a *Airport) GetStationName() (string, error) {
tag := "syNm"
requestBytes := NewInfo(nil).Get(tag).GetRequestBytes()

info, err := a.read(requestBytes)
func (a *Airport) GetStationName() (string, error) {
tag, err := a.GetProperty("syNm")

if nil != err {
return "", err
}

return string(info.Get(tag).GetValue()), nil
return string(tag.GetValue()), nil
}

// GetProperty TODO
func (a *Airport) GetProperty(tag string) (*InfoRecord, error) {
func (a *Airport) GetProperty(tag string) (*InfoRecord, error) {
infoRecord := NewInfo(nil).Get(tag)

if nil == infoRecord {
Expand Down Expand Up @@ -78,7 +75,7 @@ func (a *Airport) read(requestPayload []byte) (*Info, error) {
}

responseBuffer := new(bytes.Buffer)
io.Copy(responseBuffer, conn)
io.Copy(responseBuffer, conn)

return NewInfo(responseBuffer.Bytes()), nil
}
Expand Down
Loading

0 comments on commit 261c4d4

Please sign in to comment.