Files
onvif-go/examples/discovery/main.go
T
ProtoTess b4e4982876 Refactor XML response handling in device extended and security tests
- Adjusted formatting in XML response strings for consistency in device_extended_test.go and device_security_test.go.
- Improved readability by aligning XML declaration and body content.
- Updated mock server responses to ensure proper handling of various ONVIF operations.

Enhance device security and storage handling

- Refactored struct field declarations in device_security.go and device_storage_test.go for improved clarity.
- Ensured consistent formatting across struct definitions and XML tags.

Standardize whitespace and formatting across multiple files

- Removed unnecessary blank lines and adjusted indentation in discovery, imaging, media, and PTZ server files.
- Improved overall code readability and maintainability by ensuring consistent formatting.

Update example applications for better readability

- Cleaned up whitespace in example applications to enhance code clarity.
- Ensured consistent formatting in main.go files across various examples.

Refactor server and SOAP handler code for consistency

- Standardized struct field declarations and XML tag formatting in server and SOAP handler files.
- Improved readability by aligning struct fields and ensuring consistent use of whitespace.

General code cleanup and formatting adjustments

- Applied consistent formatting across various files, including types.go and test files.
- Enhanced readability by aligning struct fields and removing unnecessary blank lines.
2025-12-01 00:49:36 +00:00

43 lines
977 B
Go

package main
import (
"context"
"fmt"
"log"
"time"
"github.com/0x524a/onvif-go/discovery"
)
func main() {
fmt.Println("Discovering ONVIF devices on the network...")
// Create a context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// Discover devices
devices, err := discovery.Discover(ctx, 5*time.Second)
if err != nil {
log.Fatalf("Discovery failed: %v", err)
}
if len(devices) == 0 {
fmt.Println("No ONVIF devices found on the network")
return
}
fmt.Printf("\nFound %d device(s):\n\n", len(devices))
for i, device := range devices {
fmt.Printf("Device #%d:\n", i+1)
fmt.Printf(" Endpoint: %s\n", device.GetDeviceEndpoint())
fmt.Printf(" Name: %s\n", device.GetName())
fmt.Printf(" Location: %s\n", device.GetLocation())
fmt.Printf(" Types: %v\n", device.Types)
fmt.Printf(" Scopes: %v\n", device.Scopes)
fmt.Printf(" XAddrs: %v\n", device.XAddrs)
fmt.Println()
}
}