use-go / onvif

full and enhanced onvif protocol stack in golang.
MIT License
400 stars 187 forks source link

Unable to set IP Address #40

Open Lythinari opened 11 months ago

Lythinari commented 11 months ago

Id just like to prefix this with the fact that Im using a cheap ONVIF camera. But wondering whether Im doing something wrong, response returns "false" however I cant connect to the camera on the new IP address.

Ive have managed to do other Get calls, but unable to perform this Set call.

dev, err := onvif.NewDevice(onvif.DeviceParams{
    Xaddr:      "192.168.1.10:8899",
    Username:   "admin",
    Password:   "",
    HttpClient: new(http.Client),
})
if err != nil {
    panic(err)
}

prefxedIpv4Address := xsdonvif.PrefixedIPv4Address{Address: "192.168.1.2", PrefixLength: 24}

ipv4NetworkInterfaceSetConfiguration := xsdonvif.IPv4NetworkInterfaceSetConfiguration{Enabled: true, Manual: prefxedIpv4Address, DHCP: true}

networkInterfaceSetConfiguration := xsdonvif.NetworkInterfaceSetConfiguration{Enabled: true, IPv4: ipv4NetworkInterfaceSetConfiguration}

setNetworkInterfaces := device.SetNetworkInterfaces{InterfaceToken: "eth0", NetworkInterface: networkInterfaceSetConfiguration}

setNetworkInterfaceResponse, err := sdk.Call_SetNetworkInterfaces(ctx, dev, setNetworkInterfaces)
if err != nil {
    log.Println(err)
} else {
    fmt.Println(setNetworkInterfaceResponse)
}