REST API Development
DISCLAIMER OF LIABILITY
THE PROCEDURES AND SAMPLES IN THIS PAGE ARE PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND (EITHER EXPRESS OR IMPLIED), INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A SPECIFIC OR GENERAL PURPOSE AND THOSE ARISING BY STATUTE OR BY LAW, OR FROM A CAUSE OF DEALING OR USAGE OF TRADE.
THIS ALSO APPLIES TO THE CONSEQUENCES OF ANY ACTIONS TAKEN ON THE BASIS OF THE INFORMATION PROVIDED.
What is REST?
REST is a web application programming architecture that uses the HTTP protocol to create, update and delete data (also known as CRUD operations).
That means you can use an URL to request some information from a server. For example, using the following URL:
https://mywebsite.com/resources/item17
You could get all the information related to item17 from mywebsite.com (as long as the application has been developed with REST).
Keonn systems
All of the series 150/60 Keonn Systems have a REST server running in the embedded Linux board. That is, you can program a client that makes a request to start or stop your AdvanReader, for example.
When you make a Request (HTTP request) to a server, the server will give you a Response back (usually in XML format). The following diagram represents this architecture:
To see all the requests you can make to your AdvanReader, you can download the REST Reference Guide from the Downloads section.
Developing a REST client
To make a request to your AdvanReader, you can develop a client (in JavaScript, Java, C/C++, Python, etc.) or you can use a REST Client like PostMan if you don't have any programming skills.
In any way, you need to know your device IP beforehand.
Using PostMan client
In this section, we provide some examples of HTTP requests to an AdvanReader using the PostMan client.
Find Device ID
You can find the Device ID with the following HTTP GET call:
http://192.168.1.173:3161/devices
Remember to use your actual device IP. In this example, the device ID is AdvanReader-m2-150.
Start & Stop Reading
With the device ID found in the previous step, the device can start and stop reading by using the following HTTP GET calls:
http://192.168.1.173:3161/devices/<deviceID>/start
http://192.168.1.173:3161/devices/<deviceID>/stop.
In this case, the <deviceID> is AdvanReader-m2-150:
To check that the request has been made, go to AdvanNet's web interface:
Define antennas
With the device ID found in the previous steps, make sure the device is in stop mode, then issue a PUT request to
http://<deviceIP>:3161/devices/<deviceID>/antennas
<?xml version="1.0" encoding="UTF-8"?>
<request>
<entries>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>deviceID,1,1,0,1,loc_antenna1,10,20,30</def>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>deviceID,1,2,0,1,loc_antenna2,40,20,30</def>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>deviceID,1,3,0,-1,loc_antenna3,80,20,30</def>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>deviceID,1,4,0,-1,loc_antenna4,120,20,30</def>
</entry>
</entries>
</request>
Explanation:
Each entry represents an antenna. For each antenna the following is defined
<def><deviceID>,1,2,0,-1,loc_antenna1,10,20,30</def>
It is also possible to define specific values of the power per antenna
<?xml version="1.0" encoding="UTF-8"?>
<request>
<entries>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>
<deviceID>,1,1,0,0,,0,0,0</def>
<conf>
<class>ANTENNA_CONF</class>
<power>28</power>
</conf>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>
<deviceID>,1,2,0,0,,0,0,0</def>
<conf>
<class>ANTENNA_CONF</class>
<power>25</power>
</conf>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>
<deviceID>,1,3,0,0,,0,0,0</def>
<conf>
<class>ANTENNA_CONF</class>
<power>25</power>
</conf>
</entry>
<entry>
<class>ANTENNA_DEFINITION</class>
<def>
<deviceID>,1,4,0,0,,0,0,0</def>
<conf>
<class>ANTENNA_CONF</class>
<power>28</power>
</conf>
</entry>
</entries>
</request>
For more operations, please look into our REST Reference and our Java and C# examples.
Develop your own code: examples
In order to understand what you can do with the REST API, we provide some examples you can take a look at. They use AdvanNet REST API and can run on your PC:
Java examples
Download and find the instructions to run this example on the Java REST development page.
C# examples
Download and find the instructions to run this example on the C# REST development page.
Javascript & HTML5 & CSS
Download and find the instructions to run this example on the Basic Advannet App page.
Nodejs examples
Coming soon...
Embedded REST client
You can execute a custom application on the Linux Board inside (embedded) any standalone Keonn System. In order to do that, follow the instructions on the Embedded REST page.
Advanced REST development
You can use a simulator to start developing. For now, there are two simulators available: AdvanReader and AdvanSafe. You can find all the instructions, as well as other advanced options, on the Advanced development page.
Other things you can do
Receive real-time data
You can receive real-time data from the reader by listening to the TCP port 3177. There are many tools on the market you can use, depending on your Operating System:
For Windows: SocketTest, Putty
For Linux: Putty or command line nc
Support for several concurrent REST clients
Support for more than one concurrent client is added in AdvanNet-2.1.6_05.
In order to enable it, please make sure to remove the following configuration block from connectors.xml
<DEFAULT_ANLIB>
<class>com.keonn.impl.advannetlib.DefaultAdvanNetLib</class>
...
</DEFAULT_ANLIB>
Downloads
Manuals and other downloadable content.