🎉 Initial version
This commit is contained in:
25
TPLinkClient/Utils.go
Normal file
25
TPLinkClient/Utils.go
Normal file
@ -0,0 +1,25 @@
|
||||
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()
|
||||
}
|
Reference in New Issue
Block a user