9. Controlling from your own software.
You can control the IP-SwitchBox from your own programs. Http is used.
There are two "commands" for this, k0 and k1.
Reading
.
Send a http request for k0 to get current status.
The reply consists of 17 bytes in hexadecimal format:
Byte 1 …. 4
Tells the setting of the output for example." 4031" (0x34, 0x30, 0x33, 0x31) tells that outputs
1,5,6 and 15 are on. Positions without read rights are reported as off.
Byte 5 … 8
Tells which outputs that currently are doing reset.
Byte 9 …12
Tells the read rights. For example, 000F (0x30, 0x30, 0x30, 0x46) tells that you have read
rights on output 4, 3, 2 and 1.
Byte 13…16
Tells the write rights in the same way.
Byte 17
Is 0 (0x30) if the box is available for control and is 1 (0x31) if the box is reserved for another
user.
Example
:
By sending "
GET /k0"
via http we get the answer "40310000FFFF100F0" that means;
That output 15, 6, 5 and 1 are on.
That no output is doing reset.
That we have read rights on all 16 outputs.
That we have write rights on output 16, 4, 3, 2 and 1.
That we may write to the box.
(If you write it in groups it is easyer to read: 4031 0000 FFFF 100F 1234 0)
Control
.
To control the box a http request for k1aaaabbbbccccdddd is sent.
Where a,b,c,d are the parameters.
aaaa Bit mask for switch on. Four bytes of hexadecimal values (0..F).
A bit set to 1 means that the corresponding output shall be switched on.
(for
example. "40F1" means that output 15, 8, 7, 6, 5 and 1 shall be on)
bbbb Bit mask for switch off. Four bytes of hexadecimal values (0..F).
A bit set to 1 means that the corresponding output shall be switched off.
The bit mask for switch on has higher priority than the bit mask for switch off.
If both the bit for switch on and switch off is set to 1 the output will be on.
cccc Bit mask for reset.
Four bytes of hexadecimal values (0..F).
A bit set to 1 means that the corresponding output shall make a reset sequence.
dddd Bit mask for
Four bytes of hexadecimal values (0..F).
canceling reset.
A bit set to 1 means that the reset sequence for the corresponding output shall
be canceled.
The bit mask for cancel have higher priority than the bit mask for reset.
Example
: By sending "
GET /k140F1FFFF0000FFFF"
via http:
We switch on output 15, 8, 7, 6, 5 and 1.
We switch off other outputs that might have been on before.
We do not start any reset sequence.
We cancel all current reset sequences.