huaweicloud-iot-device-sdk-go/samples/connect/connect_demo.go

22 lines
384 B
Go
Raw Normal View History

2020-12-26 21:55:44 +08:00
package main
import (
2021-03-30 08:49:40 +08:00
"fmt"
"github.com/ctlove0523/huaweicloud-iot-device-sdk-go/samples"
2020-12-26 21:55:44 +08:00
)
2021-03-30 08:49:40 +08:00
func main() {
device := samples.CreateDevice()
2020-12-26 21:55:44 +08:00
2021-03-30 08:49:40 +08:00
initResult := device.Init()
2020-12-26 21:55:44 +08:00
2021-03-30 08:49:40 +08:00
fmt.Printf("device init %v\n", initResult)
2020-12-26 21:55:44 +08:00
2021-03-30 08:49:40 +08:00
fmt.Printf("device connected to server %v\n", device.IsConnected())
2020-12-26 21:55:44 +08:00
2021-03-30 08:49:40 +08:00
device.DisConnect()
2020-12-26 21:55:44 +08:00
2021-03-30 08:49:40 +08:00
fmt.Printf("device connected to server %v\n", device.IsConnected())
2020-12-26 21:55:44 +08:00
}