Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set camera's WiFi network? #87

Open
Pecacheu opened this issue Mar 26, 2022 · 0 comments
Open

How to set camera's WiFi network? #87

Pecacheu opened this issue Mar 26, 2022 · 0 comments

Comments

@Pecacheu
Copy link

Pecacheu commented Mar 26, 2022

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant