Skip to content

Instantly share code, notes, and snippets.

@jsl
Last active February 1, 2016 00:32
Show Gist options
  • Save jsl/08e988d25ac09942005d to your computer and use it in GitHub Desktop.
Save jsl/08e988d25ac09942005d to your computer and use it in GitHub Desktop.
Using Curl to scan to preset positions in a Trendnet TV-IP6721PI

Repositioning your Trendnet TV-IP6721PI using Curl

It's easy to drive your TrendNet camera using curl. This is how you can make it scan to different preset positions.

Note that Curl must be used in Digest mode.

Assuming you have a ~/.netrc file containing your device username and password, first fetch the preset elements (look for the xml section).

curl --digest -n http://camera.local/eng/liveView.cgi

You should see elements in the resulting document such as:

<preset>
<presetName>Bottom-Stairs</presetName>
<presetID>1</presetID>
</preset>
<preset>
<presetName>Top-Stairs</presetName>
<presetID>2</presetID>
</preset>

NB: It looks like the presetId element is one-based, but the "index" parameter that you need to use is zero-based. So, to access the presetID 1 above, subtract one and to access the first preset.

Once you have the list of presets, you can issue a standard GET request to change the camera position:

curl --digest -n http://camera.local/cgi/ptdc.cgi?command=goto_preset_position&index=0

The response document has a field for success or failure, however this seems like it may be buggy or have weird behavior - my camera moves when I access an index above the number of presets I've defined and the response document indicates success.

You can go home using the following URL:

curl --digest -n http://camera.local/cgi/ptdc.cgi?command=go_home

The response document always tells me this operation failed, however it seems to work and actually move the camera to the home position.

Note that it should be easy to figure out the other commands to issue to the camera using Chrome developer tools (Network tab). Just click something in the interface, and see what the URL is that is requested from the camera.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment