26 lines
407 B
Go
26 lines
407 B
Go
package TPLinkClient
|
|
|
|
import (
|
|
"bytes"
|
|
"net"
|
|
)
|
|
|
|
func macToBytes(mac string) []byte {
|
|
hwAddr, _ := net.ParseMAC(mac)
|
|
return hwAddr
|
|
}
|
|
|
|
func decodeString(data []byte) string {
|
|
nullIndex := bytes.IndexByte(data, 0)
|
|
if nullIndex >= 0 {
|
|
s := data[:nullIndex]
|
|
return string(s)
|
|
} else {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
func bytesToIp(data []byte) string {
|
|
return net.IP{data[0], data[1], data[2], data[3]}.String()
|
|
}
|