2 Star 1 Fork 0

蔡雨生/go-onvif

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
DeviceService.go 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
蔡雨生 提交于 2023-06-30 10:21 . init
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)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/cai-yusheng/go-onvif.git
git@gitee.com:cai-yusheng/go-onvif.git
cai-yusheng
go-onvif
go-onvif
v0.0.3

搜索帮助