[DKSF 70.3] Manage device with url-encoded commands

A device's interface of URL-encoded commands can be used to integrate it to web applications without using an SNMP protocol.

The following operations are available over a URL-encoded commands interface:

A Relay Management

A relay status request
http://192.168.0.100/relay.cgi?r1

A line number is specified after ?r. 

Returned Values
relay_result('error');

An error (a wrong request format or an improper relay number).

relay_result('ok', 2, 1);

Response.
The first argument is always 'ok' ('error' when fails).
The second argument is a source of a relay management:

0 - turned off manually
1 - turned on manually
2 - a watchdog
3 - a schedule
4 - a schedule + watchdog
5 - logic

The values are given for DKST70 firmware.
The third argument: instant timely status of a relay (0 or 1), taking into account functioning of a watchdog, reset activation and an impulse issuing, etc.

Relay Switching
http://192.168.0.100/relay.cgi?rn=s

n - a relay number, 1 or 2

s – a relay operation mode. One of the following values:

  • 0 – manual off
  • 1 – manual on
  • 2 – watchdog
  • 3 – schedule
  • 4 – schedule+watchdog
  • 5 – logic
  • f – a “flip” command. A relay status can be changed from Off to On and vice versa. A relay must be set to a Manual Off or Manual On mode.

CGI returns a text ok or an error depending on a result.

A relay operation mode on a web page of a relay management will be changed accordingly.

IO Lines Management in an Output Mode

An IO line status request
http://192.168.0.100/io.cgi?io4

A number of a line is specified after ?io

Returning Values

An error (a wrong request format or an incorrect IO line number).

io_result('error');

Response

io_result('ok', -1, 1, 339);

The first argument is always 'ok' (an 'error' when a request fails)
The second argument is always 1, to extend API in future
The third argument is a current instant status of an IO line,
  including a reset status
The forth argument is a pulse counter on a certain IO line

A fixed name of a JSON-P callback is io_result(), and cannot be changed in a request.

Switching a Line (in an Output Mode)
http://192.168.0.100/io.cgi?io4=0
http://192.168.0.100/io.cgi?io4=1

Switching between statuses 0 or 1.
A number of a line is specified after ?io. 

http://192.168.0.100/io.cgi?io4=f

Switching to alternative (inverse) status.

http://192.168.0.100/io.cgi?io4=f,5

A short term switching to an inverse status, i.e. issuing an impulse.
Its duration is set after a comma in seconds. 

Choosing a line management source (in an output mode)
http://192.168.0.100/io.cgi?io4=2

It connects a line as a Logic output.
To switch back to a manual management, you should invoke /io.cgi?io4=0 или /io.cgi?io4=1 (i,e, set 0 or 1 manually).

Returning Values
io_result('error');

An error (an incorrect format of a request or a wring number of an IO line).

io_result('ok');

A command is implemented.

Current Sensor

A status report
http://192.168.0.100/curdet.cgi
Returning values
curdet_result('ok', 0, 'Норма');

The first argument is always 'ok' (an error is impossible).
The second argument is a numeric value of a status.
The third argument is a text value of a status.

0 - normal
1 - ALARM!
2 - break
3 - short circuit
4 - deenergized

A sensor reset
http://192.168.0.100/curdet.cgi?reset

A power supply is cut off a current loop for a short period of time.

Returning values
curdet_result('ok');
curdet_result('error');

An error can be returned when a format or a text of a request is incorrect. 

 

Temperature Sensors

A Status Request
http://192.168.0.100/thermo.cgi?t3

A number of a sensor is specified after ?t

Returning Values
thermo_result('error');

An error in a request (a wrong format, an incorrect sensor number).

thermo_result('ok', 36, 2);

Response.
The first argument is always 'ok' ('error' in case of an incorrect request)
The second argument is a current temperature
The third argument is a sensor status

0 - a sensor is not connected or fails
1 - a temperature is below a norm
2 - a temperature is normal
3 - a temperature is above a norm
 

Humidity Sensor

A status request
http://192.168.0.100/relhum.cgi
Returning values
relhum_result('ok', 55, 25, 2);

Response.
The first argument is always 'ok'
The second argument is a relative humidity in %
The third argument is a temperature of a humidity sensor
The forth argument is a sensor status:

0 - a sensor is not connected or fails
1 - a humidity is below a norm
2 - a humidity is normal
3 - a humidity is above a norm

A Remotely Controlled IR Commands Transceiver

Sending an IR command
http://192.168.0.100/ir.cgi?play=11

A command number is specified after =.

Returning values
ir_result('ok');
ir_result('error');

An error is returned in case of an improper request format or an incorrect command number.
Errors of an IRC-TRv2 module are not checked when forming a response.