Auxiliary Operations
XW-210 WiFi™ Users Manual
6.2 HTTP GET Requests (for custom applications)
The XW-210 has a built in web server that responds to HTTP GET requests. The server is always active.
These GET requests are sent from web browsers when a web page is requested. They are fairly similar
to the actual addresses seen in the browser's address bar. The following section describes the HTTP
GET protocol and how it can be used to control and monitor the XW-210.
6.2.1 Using GET for Control and Monitoring
There are many libraries and methods for sending a HTTP request programmatically. For reference, an
example of how to manually build the HTTP request to control a relay is shown below. Please note that
\r\n is not needed in all instances. The '\r\n' string is used to represent the Carriage Return and Line Feed
characters. Since not all methods of using a string can handle the actual CR LF characters, the '\r\n' is
used in its place. For example, if you are using a programming language, you will likely use '\r\n'. If you
are typing the command directly into a terminal program for testing, you will simply press enter once for
each set of '\r\n'. If you are unsure, try using '\r\n' first and if that doesn't work, you may try using the enter
key. In no case will you need to use the string '\\r\\n'.
No Password
GET requests to the device for XML files.
Example request state.xml:
GET /state.xml HTTP/1.1\r\n\r\n
Example turn Relay1 On:
GET /state.xml?relay1State=1 HTTP/1.1\r\n\r\n
Password Enabled
If the Control Password is enabled on XW-210 and the state.xml page is requested through a browser,
the user will be prompted for a password. If the XML request is sent from an XML application, the html
request will need to contain the password, encoded as Base64.
The following is an html request header without the password:
GET /state.xml?relay1State=1&noReply=1 HTTP/1.1\r\n\r\n
The following example adds the password:
GET /state.xml?relay1State=1&noReply=1 HTTP/1.1\r\n
Authorization: Basic bm9uZTp3ZWJyZWxheQ==\r\n\r\n
bm9uZTp3ZWJyZWxheQ==
is the Base64 encoded version of the user “name:password,”
none:webrelay.
A utility is provided at http://www.controlbyweb.com/encoder to encode the password. Simply type the
string username:password into the website and press 'Encode'.
cURL Example
The following is an html request without a password:
curl "http://192.168.1.2/state.xml?relay1State=1"
The following example adds the ability to supply a password
curl --basic -u none:webrelay "http://192.168.1.2/state.xml?relay1State=1"
Page 60
Xytronix Research & Design, Inc.
Summary of Contents for WebRelay Wireless XW-210I
Page 1: ......