代码拉取完成,页面将自动刷新
package main
import (
"context"
"fmt"
"log"
"net/http"
goonvif "gitee.com/cai-yusheng/go-onvif"
"gitee.com/cai-yusheng/go-onvif/device"
sdk "gitee.com/cai-yusheng/go-onvif/sdk/device"
"gitee.com/cai-yusheng/go-onvif/xsd/onvif"
)
const (
login = "admin"
password = "Supervisor"
)
func main() {
ctx := context.Background()
//Getting an camera instance
dev, err := goonvif.NewDevice(goonvif.DeviceParams{
Xaddr: "192.168.13.14:80",
Username: login,
Password: password,
HttpClient: new(http.Client),
})
if err != nil {
panic(err)
}
//Preparing commands
systemDateAndTyme := device.GetSystemDateAndTime{}
getCapabilities := device.GetCapabilities{Category: "All"}
createUser := device.CreateUsers{
User: onvif.User{
Username: "TestUser",
Password: "TestPassword",
UserLevel: "User",
},
}
//Commands execution
systemDateAndTymeResponse, err := sdk.Call_GetSystemDateAndTime(ctx, dev, systemDateAndTyme)
if err != nil {
log.Println(err)
} else {
fmt.Println(systemDateAndTymeResponse)
}
getCapabilitiesResponse, err := sdk.Call_GetCapabilities(ctx, dev, getCapabilities)
if err != nil {
log.Println(err)
} else {
fmt.Println(getCapabilitiesResponse)
}
createUserResponse, err := sdk.Call_CreateUsers(ctx, dev, createUser)
if err != nil {
log.Println(err)
} else {
// You could use https://gitee.com/cai-yusheng/go-onvif/gosoap for pretty printing response
fmt.Println(createUserResponse)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。