Embedded REST development
The following is an example of a custom Java application that uses the REST API of AdvanNet to control the reader:
Be careful about consuming all the Linux Board resources (CPU, memory...)
In particular, you must ensure the Java application handles properly object allocation in order to avoid garbage collection pauses.
Before following the next steps, make sure you have Eclipse IDE and Java 8 installed.
Requirements
You can find our examples in our GitHub page: https://github.com/Keonn-Technologies/JavaRestExamples
Download the following files:
Eclipse project
Decompress the zip file TestEmbedded and import the project:
The project contains the following:
Start.java: Java application that connects to AdvanNet, starts an inventory and shows the EPC reads.
util: A package with the implementation of a REST client to communicate with AdvanNet.
JCLAP-1.1.jar: Library for the handling of arguments.
This project can be run from eclipse by setting the argument -h to the IP address of the reader:
Embedded applications can use the localhost name, instead of an IP address that may change.
Creating the JAR file
One way to wrap all the files in the Eclipse Project and make runnable is to export the project into a runnable JAR file:
File -> Export
Execute the sample in the Linux Board
Copy the resulted JAR file (TestEmbedded.jar) into the folder /home/keonn/ of the Keonn System Linux Board.
Copy the script to run the JAR file (start-embedded-app.sh) into /home/keonn/.
Connect by SSH (PuTTy, ...) to the System and run the following commands:
cd /home/keonn/
sudo su
put the same password as to enter as keonn
chmod +x start-embedded-app.sh
Execute the embedded Java program:
./start-embedded-app.sh
The log of the sample project should be displayed by executing this command:
tail -f /home/keonn/testEmbedded/log.log
Run from boot
If the application needs to be started on boot, follow the next steps:
Copy the file daemon-test-embedded.sh into /home/keonn
Connect by SSH (PuTTy, ...) to the System and run the following commands:
cd /home/keonn
sudo su
3. put the same password as to enter as keonn
mv daemon-test-embedded.sh /etc/init.d/daemon-test-embedded.sh
cd /etc/init.d
update-rc.d daemon-test-embedded.sh defaults
The embedded application should start when rebooting the System.