diff --git a/BallCamera.go b/BallCamera.go index 9d57148..f8dd5c7 100644 --- a/BallCamera.go +++ b/BallCamera.go @@ -432,3 +432,7 @@ func verify(data []byte) (byte, error) { func (this *BallCamera) Logout() error { return Core.Logout(this.userId) } + +func (this *BallCamera) Status() bool { + return Core.NET_DVR_RemoteControl(this.userId) +} diff --git a/BallCamera_test.go b/BallCamera_test.go index 29511df..07aec50 100644 --- a/BallCamera_test.go +++ b/BallCamera_test.go @@ -12,8 +12,8 @@ func TestCamera(t *testing.T) { if err != nil { return } - Camera, err := NewBallCamera("192.168.211.48", 8000, "admin", "okwy1234", BuKongQiu) - //Camera, err := NewBallCamera("192.168.211.64", 8000, "admin", "ubis3333", Base) + //Camera, err := NewBallCamera("192.168.211.48", 8000, "admin", "okwy1234", BuKongQiu) + Camera, err := NewBallCamera("192.168.211.64", 8000, "admin", "ubis3333", Base) if err != nil { t.Errorf("NewBallCamera() error = %v", err) return diff --git a/Core/core.go b/Core/core.go index 49bc32b..15aa765 100644 --- a/Core/core.go +++ b/Core/core.go @@ -58,6 +58,10 @@ func Login(Ip string, Port int, Username string, Password string) (LONG, NET_DVR return LONG(cUserId), DeviceInfo, nil } +func NET_DVR_RemoteControl(userId LONG) bool { + return C.NET_DVR_RemoteControl(C.LONG(userId), C.DWORD(20005), nil, C.DWORD(0)) == C.TRUE +} + func Logout(userId LONG) error { if userId > -1 { cResult := C.NET_DVR_Logout(C.LONG(userId)) diff --git a/Nvr.go b/Nvr.go index ede95e5..a8771be 100644 --- a/Nvr.go +++ b/Nvr.go @@ -28,7 +28,7 @@ func NewNvr(Ip string, Port int, Username, Password string) (*Nvr, error) { }, nil } -func (this *Nvr) getNvrUTCDiff() (int, error) { +func (this *Nvr) GetTimeZone() (int, error) { var data Core.NET_DVR_NETAPPCFG var dataPtr = unsafe.Pointer(data.GetCPtr()) err := Core.GetDVRConfig(this.userId, 222, 0, dataPtr, Core.DWORD(unsafe.Sizeof(data.GetC()))) @@ -105,7 +105,7 @@ func (this *Nvr) CheckTimeRegionWithDay(Year, Month, Day, Channel uint16) ([]Tim if err != nil { return nil, err } - ByUTCDiff, err := this.getNvrUTCDiff() + ByUTCDiff, err := this.GetTimeZone() if err != nil { return nil, err } @@ -166,6 +166,10 @@ func (this *Nvr) Logout() error { return Core.Logout(this.userId) } +func (this *Nvr) Status() bool { + return Core.NET_DVR_RemoteControl(this.userId) +} + type TimeRange struct { StartTime time.Time EndTime time.Time diff --git a/Nvr_test.go b/Nvr_test.go index 2a43712..1f38074 100644 --- a/Nvr_test.go +++ b/Nvr_test.go @@ -15,7 +15,7 @@ func TestNewNvr(t *testing.T) { if err != nil { t.Error(err) } - diff, err := nvr.getNvrUTCDiff() + diff, err := nvr.GetTimeZone() if err != nil { return }