Protocol

Hello,

I’m working on an Android application for the VM201.

I’m wondering if there will be more commands available in the future such as changing the names of the channels and add/remove/edit the timers.

Sincerely yours,

Bart

[quote=“Bart”]I’m wondering if there will be more commands available in the future such as changing the names of the channels and add/remove/edit the timers.[/quote]Unfortunately, I would have to say never

There is simply no more memory available in the processor for additions.

Just thinking outside the box

Maybe use a text based web browser like Lynx and scripting or straight up send HTML POST responses to port 80 to simulate a session with the cards browser interface?

I have never tried something like that (would java script used by web interface get in the way)? ([color=#00BF40]question to self)[/color]
Haven’t messed with Lynx but sure would be nice to be able to set the timer schedule from a PC program to add flexibility like the ability to change the 28 VM201 schedules quickly.

just a follow up to prior post

lynx does not work because it does not support java
there are other text based browsers that do support java (elinks, links2) but I did not pursue because I found a better solution

cURL (curl.haxx.se/downloads.html) does the trick
It has been around quite a while and is well maintained and documented.
There are many, many packages for different OS’s
I chose the Edward Lopinto Windows installer (MSI) port.

cURL is a command line tool that does a lot of network “Stuff”.
HTTP, HTTPS, FTP, SFTP, etc, etc.
Kind of like telnet on steroids
cURL handles communications and formatting for the protocol desired whereas you have to know how to communicate and format when using telnet

cURL also has a library you can use in your programs but I haven’t gotten that far yet.

example 1: toggle a timer off or on (this is an HTTP GET command) (it is the exact same command for on or off)
cURL 192.168.0.50/cgi.timers.cgi?timer=0 (where timer is 0-7; 0 for relay 1, 1 for relay 2, etc) (replace the IP with the IP of your card)

example 2: set a scheduled event for 1 row out of the 28 available on the VM201
cURL -i -d@C:\TimerSettings.txt 192.168.0.50/timers.html
you need to create a file (C:\TimerSettings.txt) with the following:
row=9&channel=2&prgday=10&prghour=0&prgmin=30&prgaction=3&prgpulse=3&prgpulseunit=0 (you can also break the line into multiple lines for readability)

example 3: same as example 2 but without a file
cURL -i -drow=9&channel=2&prgday=10&prghour=0&prgmin=30&prgaction=3&prgpulse=3&prgpulseunit=0 192.168.0.50/timers.html

acceptable values: row is 1 -28 (VM201 has max of 28 timer events)
channel 0-8 (0 = no event, otherwise the relay number)
prgday 0 - 10 (see the web interface for the 11 possible settings like Mon-Fri)
prghour 0 - 23 (24 hours clock)
prgmin 0 - 59
prgactiom 0 -3 (no action, off, on, pulse)
prgpulse 0 -99 (pulse time in pulse units)
prgpulseunits 0 -2 (second, minutes, hours)

you can use the web interface (refresh the page) to easily see the results

The examples above are all you need to create events and to turn the timer on for a relay

anything that can be programmed over the web interface can be programmed using cURL command line or library
you need to know what the web interface sends when you click SAVE or when you toggle something on/off
when you toggle you are using GET (example 1)
when you click SAVE you are using POST (examples 2 and 3)
One way to see what the web interface sends to the card is with fiddlercap (telerik.com/fiddler/fiddlercap)
Install and run fiddlercap
Start a capture just before you toggle an option or just before you click SAVE
Stop the capture just after
Save the capture file somewhere (change the extension to ZIP)
Open the ZIP file and in RAW folder open file called something like 1_c.txt.
If it is a GET command the first line is what you want (without the HTTP/1.1 part)
If it is a POST command the last line is the parameters.
For POST the first line is the URL to send the parameters to, (without the HTTP/1.1 part)

NOTE: there are rules for sending POST and GET data (CGI rules) (just the data part)
letters and numbers are fine, spaces have to be changed to + signs, other characters have to be sent using hex notation %FF (e.g. left bracket is %5B)
cURL can format the data for you (see the documentation to change -d). Otherwise you have to do it (or copy and paste from the fiddlercap capture file)
Capture the POST for setting relay names to see an example of CGI format

NOTE: this post is for one way (setting the VM201, not reading)
you can use cURL to read the card settings too but you have to dissect the data returned after sending a command to get the info you need)
I am writing this in an Access database so I will be storing the settings in a table and I don’t need to get them from the card.