Skip to content

Commit cb03b94

Browse files
committed
Add device get-system-time command.
1 parent fda612c commit cb03b94

36 files changed

+65
-35
lines changed

cmd/gonvif/device/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func init() {
2222
getDeviceInformation,
2323
getNetworkInterfaces,
2424
getServices,
25+
getSystemTime,
2526
setSystemFactoryDefault,
2627
systemReboot,
2728
)

cmd/gonvif/device/get-device-information.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var getDeviceInformation = &cobra.Command{
1111
Use: "get-device-information",
1212
Short: "Show Onvif device information",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err

cmd/gonvif/device/get-network-interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var getNetworkInterfaces = &cobra.Command{
1111
Use: "get-network-interfaces",
1212
Short: "List Onvif device network interfaces",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err

cmd/gonvif/device/get-services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var getServices = &cobra.Command{
1111
Use: "get-services",
1212
Short: "List Onvif device services",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package device
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/eyetowers/gonvif/cmd/gonvif/root"
7+
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver10/device/wsdl"
8+
)
9+
10+
var getSystemTime = &cobra.Command{
11+
Use: "get-system-time",
12+
Short: "Show Onvif device system date and time",
13+
Args: cobra.NoArgs,
14+
RunE: func(*cobra.Command, []string) error {
15+
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
16+
if err != nil {
17+
return err
18+
}
19+
return runGetSystemTime(client)
20+
},
21+
}
22+
23+
func runGetSystemTime(client wsdl.Device) error {
24+
resp, err := client.GetSystemDateAndTime(&wsdl.GetSystemDateAndTime{})
25+
if err != nil {
26+
return err
27+
}
28+
return root.OutputJSON(resp)
29+
}

cmd/gonvif/device/set-system-factory-default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var setSystemFactoryDefault = &cobra.Command{
1616
Use: "set-system-factory-default",
1717
Short: "Set Onvif device system factory default",
1818
Args: cobra.NoArgs,
19-
RunE: func(cmd *cobra.Command, args []string) error {
19+
RunE: func(*cobra.Command, []string) error {
2020
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
2121
if err != nil {
2222
return err

cmd/gonvif/device/system-reboot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var systemReboot = &cobra.Command{
1111
Use: "system-reboot",
1212
Short: "Reboot Onvif device",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err

cmd/gonvif/events/create-pull-point-subscription.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var createPullPointSubscription = &cobra.Command{
1111
Use: "create-pull-point-subscription",
1212
Short: "Create Onvif events pull point subscription",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err

cmd/gonvif/events/get-event-brokers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var getEventBrokers = &cobra.Command{
1515
Use: "get-event-brokers",
1616
Short: "List Onvif event brokers",
1717
Args: cobra.NoArgs,
18-
RunE: func(cmd *cobra.Command, args []string) error {
18+
RunE: func(*cobra.Command, []string) error {
1919
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
2020
if err != nil {
2121
return err

cmd/gonvif/events/get-event-properties.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var getEventProperties = &cobra.Command{
1111
Use: "get-event-properties",
1212
Short: "Show Onvif detailed event propeties",
1313
Args: cobra.NoArgs,
14-
RunE: func(cmd *cobra.Command, args []string) error {
14+
RunE: func(*cobra.Command, []string) error {
1515
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
1616
if err != nil {
1717
return err

0 commit comments

Comments
 (0)