Initial Commit

This commit is contained in:
ProtoTess
2025-10-30 00:50:27 +00:00
parent 2e3156df5d
commit 1319e1ea3f
25 changed files with 5216 additions and 16 deletions
+42
View File
@@ -0,0 +1,42 @@
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/0x524A/go-onvif/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()
}
}