You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
618 B
40 lines
618 B
1 month ago
|
package common_utils
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestIP4(t *testing.T) {
|
||
|
ip4 := ReadIP4()
|
||
|
println(ip4)
|
||
|
|
||
|
}
|
||
|
func TestIP4WithFilter(t *testing.T) {
|
||
|
|
||
|
println("==================")
|
||
|
prefix := "10."
|
||
|
ip4 := ReadIP4WithPrefix(prefix)
|
||
|
println(ip4)
|
||
|
}
|
||
|
|
||
|
func TestMqttReConn(t *testing.T) {
|
||
|
client := NewMqttHelper(
|
||
|
"10.8.30.160",
|
||
|
30883,
|
||
|
fmt.Sprintf("%s-%s", "testReConn", time.Now().Format("20060102-150405")),
|
||
|
"",
|
||
|
"",
|
||
|
false,
|
||
|
)
|
||
|
client.Subscribe("re", onData)
|
||
|
for {
|
||
|
time.Sleep(time.Minute)
|
||
|
}
|
||
|
}
|
||
|
func onData(topic, payload string) {
|
||
|
log.Printf("[%s]收到数据 %s", topic, payload)
|
||
|
}
|