From 9a595fa99711a2566ba9feb305599142675b7680 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Thu, 22 Aug 2024 13:09:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=20conns=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20conn=20=E7=9A=84=E8=AF=AD=E5=8F=A5=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E7=A8=8B=E5=BA=8F=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/handler/onvif/connection.go | 11 ++++++----- service/onvif/connection.go | 1 + service/onvif/device.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/router/handler/onvif/connection.go b/router/handler/onvif/connection.go index 979df28..55b4d39 100644 --- a/router/handler/onvif/connection.go +++ b/router/handler/onvif/connection.go @@ -29,9 +29,7 @@ func CreateConnection(c *gin.Context) { return } - conns[conn.Device.GetDeviceParams().Xaddr] = conn - - info, err := conn.GetDeviceInformation() + info, err := conn.GetDeviceInfo() if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "message": err.Error(), @@ -39,6 +37,9 @@ func CreateConnection(c *gin.Context) { return } + // store connection + conns[conn.Device.GetDeviceParams().Xaddr] = conn + c.JSON(http.StatusOK, gin.H{ "device": info, }) @@ -48,7 +49,7 @@ func GetConnections(c *gin.Context) { devices := make(map[string]interface{}) for xaddr, conn := range conns { - info, err := conn.GetDeviceInformation() + info, err := conn.GetDeviceInfo() if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "message": err.Error(), @@ -75,7 +76,7 @@ func GetConnectionByXaddr(c *gin.Context) { return } - info, err := conn.GetDeviceInformation() + info, err := conn.GetDeviceInfo() if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "message": err.Error(), diff --git a/service/onvif/connection.go b/service/onvif/connection.go index 2b18631..2f66db3 100644 --- a/service/onvif/connection.go +++ b/service/onvif/connection.go @@ -13,6 +13,7 @@ func NewConnection(xaddr string, username string, password string) (*Connection, Xaddr: xaddr, Username: username, Password: password, + AuthMode: onvif.DigestAuth, }) if err != nil { return nil, err diff --git a/service/onvif/device.go b/service/onvif/device.go index b955ebd..af423e9 100644 --- a/service/onvif/device.go +++ b/service/onvif/device.go @@ -2,7 +2,7 @@ package onvif import "github.com/IOTechSystems/onvif/device" -func (c *Connection) GetDeviceInformation() (*device.GetDeviceInformationResponse, error) { +func (c *Connection) GetDeviceInfo() (*device.GetDeviceInformationResponse, error) { resp, err := c.Device.CallMethod(device.GetDeviceInformation{}) if err != nil { return nil, err