refactor(router): 改为结构化 web 项目
This commit is contained in:
40
service/onvif/connection.go
Normal file
40
service/onvif/connection.go
Normal file
@ -0,0 +1,40 @@
|
||||
package onvif
|
||||
|
||||
import (
|
||||
"github.com/IOTechSystems/onvif"
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
Params DeviceParams `json:"params"`
|
||||
Device *onvif.Device `json:"device"`
|
||||
}
|
||||
|
||||
type DeviceParams struct {
|
||||
Xaddr string `json:"xaddr"`
|
||||
EndpointRefAddress string `json:"endpointRefAddress"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
AuthMode string `json:"authMode"`
|
||||
}
|
||||
|
||||
func NewConnection(addr string, username string, password string) (*Connection, error) {
|
||||
dev, err := onvif.NewDevice(onvif.DeviceParams{
|
||||
Xaddr: addr,
|
||||
Username: username,
|
||||
Password: password,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Connection{
|
||||
Params: DeviceParams{
|
||||
Xaddr: dev.GetDeviceParams().Xaddr,
|
||||
EndpointRefAddress: dev.GetDeviceParams().EndpointRefAddress,
|
||||
Username: dev.GetDeviceParams().Username,
|
||||
Password: dev.GetDeviceParams().Password,
|
||||
AuthMode: dev.GetDeviceParams().AuthMode,
|
||||
},
|
||||
Device: dev,
|
||||
}, nil
|
||||
}
|
Reference in New Issue
Block a user