huaweicloud-iot-device-sdk-go/samples/gateway/gateway_update_status.go

31 lines
665 B
Go
Raw Normal View History

2020-12-24 23:31:16 +08:00
package main
import (
"fmt"
iot "github.com/ctlove0523/huaweicloud-iot-device-sdk-go"
2021-03-30 21:51:28 +08:00
"github.com/ctlove0523/huaweicloud-iot-device-sdk-go/samples"
2020-12-25 23:59:35 +08:00
"time"
2020-12-24 23:31:16 +08:00
)
func main() {
2021-03-30 21:51:28 +08:00
device := samples.CreateDevice()
2020-12-26 08:47:12 +08:00
device.SetSubDevicesAddHandler(func(devices iot.SubDeviceInfo) {
for _, info := range devices.Devices {
2020-12-25 23:59:35 +08:00
fmt.Println("handle device add")
fmt.Println(iot.Interface2JsonString(info))
}
})
2020-12-24 23:31:16 +08:00
2020-12-26 08:47:12 +08:00
device.SetSubDevicesDeleteHandler(func(devices iot.SubDeviceInfo) {
for _, info := range devices.Devices {
fmt.Println("handle device delete")
fmt.Println(iot.Interface2JsonString(info))
}
})
2020-12-27 09:22:18 +08:00
device.Init()
2021-03-19 19:52:53 +08:00
time.Sleep(200 * time.Second)
2020-12-26 08:47:12 +08:00
2020-12-25 00:12:51 +08:00
}