-
Notifications
You must be signed in to change notification settings - Fork 204
Description
I'm trying to make a program that can set the WiFi network of a camera connected via ethernet without having to use the camera's configuration utility. I have multiple different brand ONVIF cams so that would be convenient. I have seen the ability to set a network in other ONVIF/IP cam control software, so I'm sure it's possible.
I looked through the ONVIF documentation and found the GetDot11Status and SetNetworkInterfaces commands, which weren't implemented in the library. Luckily, it didn't seem that difficult to add them in using the existing functions for reference. But now that I did, it's not working!
I know this isn't the library's fault, but I'm hoping someone here knows what I'm doing wrong on a protocol level... Since clearly the data itself is getting to the camera, it's just not doing what I want.
In the case of GetDot11Status, it works, but the ONE piece of info I want, the SSID, is just left blank. In the case of SetNetworkInterfaces, it gives me an error code even though I'm sure I'm giving it the right data based on the spec here.
function parseSoap(o) { //Builds XML string recursively
let s='',k; for(k in o) s+=`<tds:${k}>${typeof o[k]=='object'?
parseSoap(o[k]):o[k]}</tds:${k}>`; return s;
}
cam.services.device.getDot11Stat = async function(t) {
return await onvif._OnvifSoap.requestCommand(this.oxaddr, 'GetDot11Status',
this._createRequestSoap(parseSoap({GetDot11Status:{InterfaceToken:t}})));
}
cam.services.device.setNetwork = async function(o) {
return await onvif._OnvifSoap.requestCommand(this.oxaddr, 'SetNetworkInterfaces',
this._createRequestSoap(parseSoap({SetNetworkInterfaces:o})));
}
//Note: InterfaceToken hard-coded based on token given in getZeroConfiguration, it's always "eth0"
console.log(cam.services.device.getDot11Stat("eth0")); //Works, but SSID field blank
console.log(cam.services.device.setNetwork({
InterfaceToken:"eth0", NetworkInterface:{
IPv4:{DHCP:true}, Extension:{Dot11:{
SSID:"TestNetwork", Mode:"Infrastructure",
Security:{Mode:"WEP", PSK:{Passphrase:"Password123"}}
}}
}
})); //Causes 400 error "IPv4 invalid"