Web-IO - Use your own application in the browser
Query and set IO signals using HTTP requests
The main advantage of browser-based applications is their independence from the operating system of the application computer. Regardless of whether Windows, Linux, iOS or Android - the browser is part of the system. Even purely technically embedded systems without a GUI today offer mechanisms for sending HTTP requests and receiving the corresponding replies.
On this page first we show the basic access to our Web-IO products using HTTP requests and HTTPS requests, subdivided as follows:
- Access via HTTP requests
- Configuring Web-API
- Construction and structure of HTTP requests
Access via HTTP requests
Here we will first describe only what is essential for handling HTTP requests. A more detailed description of HTTP and HTTPS can be found in the book TCP/IP-Ethernet, which you can download here at no cost.
If you are creating applications which use HTTP, you generally do not need to worry about processing on the protocol level yourself. For browser applications this is handled by the browser itself or linked function libraries. Even modern high level languages offer function calls to which only the corresponding HTTP request is passed.
By going to https://wut.de/webio in the address line of the browser the W&T web server for example returns a web page with the overview of available 230V Web-IO models.
A simple example of a technical HTTP request is to open https://klima.wut.de/single, which simply returns only the current outside temperature at the W&T company headquarters.
Structure of an HTTP request
An HTTP request always begins with the keyword
https:// if encrypted transmission is required. Then follows the IP address or the hostname of the web server to be accessed.
HTTP is processed on TCP port 80 and HTTPS on port 443. If the server can be reached under a different port, this can be appended, separated by a
:. Only now, separated by a
/ does the actual request (e.g. name of a web page such as index.html) follow. Any necessary parameters can follow behind a
?. If there are multiple parameters,
& is used as a separator.
Communication using HTTP requests
Data exchange using HTTP requests always resembles a question/answer scenario. An HTTP client sends a request to a web server and the web server replies with an HTTP reply. The HTTP client is thus always an active part of HTTP communication. The web server can never send data to the client on its own using pure HTTP mechanisms.
From the menu tree in the web interface, select Communication channels >> Web-API and enable Allow HTTP-Requests.
The HTTP port can if needed be adapted under Basic settings >> Network.
The outputs to be switched using the Web-API must be enabled accordingly.
Prepending the IP address and system name will be covered later.
Construction of HTTP requests
Construction and structure of HTTP requests
As shown above, each HTTP requests begins with
https:// followed by the actual Request command. The upper/lower case form shown here must be followed. Use
? to separate additional parameters. For the Web-IO Digital always use the password with the syntax
PW=password&. Each parameter set is terminated with
&, so that two parameter sets are also separated by
Example: Input query
As an example, here is the command for calling the input switching states. The Web-IO is protected with the password blue.
Depending on the model, the reply from the Web-IO looks like this in the example:
input;1 (Web-IO Digital 2xIn, 2xOut)
input;0001 (Web-IO Digital 12xIn, 12xOut and 12xIn, 6xRelay)
The reply consists of the keyword from the request, separated by a semicolon and one or more values.
Here the reply begins with the keyword
input and is followed by the value
0001 which indicates the switching state of all the inputs in hexadecimal format. Here: Input 0 = ON, all other inputs = OFF.
For better understanding of the hexadecimal input coding, here is another example for a Web-IO with 12 inputs:
Inputs 0, 1, 5, 7, 10 and 11 are ON. The other inputs are in the OFF state. This bit pattern results in a dual number where ON bits = 1 and OFF bits = 0.
And so here
1100 1010 0011.
In hex this corresponds to
CA3 and in four-place representation
More about hexadecimal number can be found here.
Example: Setting the outputs
The command for setting outputs has a similar structure as the
input command but has more parameters:
The digit behind the keyword
outputaccess indicates which output to switch - here Output 0.
State is used to send which state to switch to. Possible values are
TOGGLE (state change).
The reply from the Web-IO looks like this depending on the model:
output;1 (Web-IO Digital 2xIn, 2xOut)
output;0001 (Web-IO Digital 12xIn, 12xOut and 12xIn, 6xRelay)
Just as with the input query, the reply is the corresponding keyword followed by the bit pattern of the output states. Regardless of which output is set, the bit pattern always represents the status of all outputs.