My personal views, thoughts and opinions.

Tuesday, May 07, 2013

Vilar IP Cam - Network settings

I have 4 Vilar IP Cams. Recently I needed to move two of them to a new network. The setup program that came with the cam did not find the cameras so I had to do the setup via the web interface. It turned out however that the network settings page (Basic -> Network) did not save/apply the changes I made in to the page controls.

Since I'm Firefox user and I also do some pretty basic web development I enabled Firebug and checked what the malfunctioning Apply button actually does. 

It turned out that it was not simply a submit form button, but instead called settcpip JavaScript function. The same function was called on every click event as well. The function itself performed some IP address validation and if everyting was ok invoked:
I debugged this settcpip function by:
  • Enabling Script debugging
  • Reloading the page (in Firebug UI)
  • In the first JavaScript shown by Firebug I searched for settcpip
  • Set breakpoint at the line
element = document.getElementById('StaticIP');
To my surpise the element turned out to be ... null. I checked the HTML source and yes - there was no such id.

I had two options:
  • Adapt the HTML to what JavaScript expected (i.e. change the options of the select tag to "StaticIP")
  • Short-circuit the function used to check for correct IP address

Since I already spent too much time fixing a bug present in ~20 obviously never tested versions of the firmware I decided to check if the form submit will work at all.

What I did was to go the Apply button source and replace settcpip with document.form1.submit()

After that hitting Apply worked like a charm and I was able to change my cam's IP address.

If you want to use the same trick, please bear in mind that a single mistake in the form may trigger your cam unreachable. Then you'll most probably need to reset it to factory defaults by pressing the reset switch for at least 20 seconds.

Google+ Followers