Tutorial On Eclipse Leshan v2: Eshan Nstallation On Inux
Tutorial On Eclipse Leshan v2: Eshan Nstallation On Inux
NL)
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Eclipse Leshan is an open source LWM2M programming framework in Java. This tutorial is about how to
install Leshan and to develop LWM2M client and LWM2M server using Eclipse Leshan for the Internet of
Things (21MN15) practical. This tutorial uses Leshan version 0.1.11-M15 which can be downloaded or
cloned from https://github.com/eclipse/leshan.
https://github.com/eclipse/leshan
Apache Maven 3.2.5 and JDK 7 have been installed on the Raspberry Pi and their directory have been set
to the PATH environment variable during any shell launch (.bashrc) and therefore can be called from
any location, as shown in Figure 1 and Figure 2. Figure 9 shows example of leshan-demo-client
execution with options.
Page 1 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Figure 2. Setting directory of Maven and JDK to the PATH environment variable in .bashrc
Page 2 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 3 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
MOBILE APP
WEB BROWSER
(ANDROID OR IOS)
HTTP HTTP
LESHAN-DEMO-SERVER
(PC/LAPTOP)
FILES
(/webapp) SERVLET CONTAINER
- JAVASCRIPT
(with Angular JS) EVENT CLIENT OBJECT SPEC SECURITY
- HTML SERVLET SERVLET SERVLET SERVLET
- CSS
Page 4 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Define your object specifications (from the IPSO smart objects expansion pack, or self-defined
objects) in an objectspec.json file. The standard objects (LWM2M objects and IPSO smart
objects starter pack) are already defined in /leshan-core/src/main/resources/oma-
objects-spec.json
Create a new system environment variable “MODELS_FOLDER” that reference the folder with the
objectspec.json file
In each object class, specify the actions for READ, WRITE, EXECUTE, DELETE requests on each
resources of the object.
Initialize the objects (under the // Initialize object list comment in the code)
Run the project as Java Application. You can also pass on arguments to the leshan-client-demo
execution by setting the arguments tab in run configuration. Right click on the leshan-client-
emo project -> run as -> run configurations … (see Figure 4)
The list of options can be found in the LeshanClientDemo.java source code or on Figure 8.
Page 5 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 6 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
To export the project into executable .jar file (to be deployed on Raspberry Pi for example), right
click on the project and click Export -> Java -> Runnable Jar File
Choose the first library handling option : Extract required libraries into generated file (see Figure 5)
Once you have your .jar file, extract the jar file into a directory.
Move the content of /resources directory, which consists of: oma-objects-spec.json
and simplelogger.properties to the root directory. The structure of the jar file should look
similar like leshan-client-demo-*-SNAPSHOT-jar-with-dependencies.jar as
shown in Figure 6.
Repackage the jar file. Figure 7 shows the repackaged jar file. We have now files oma-objects-
spec.json and simplelogger.properties in the root directory.
Page 7 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 8 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
To get the options of the leshan-demo-client execution, you can type: java –jar
jarfilename.jar –help as shown in Figure 8.
Page 9 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 10 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 11 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 12 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 13 of 14
RAHMAN, L.F. ([email protected])
12/22/16
TUTORIAL ON ECLIPSE LESHAN V2
Page 14 of 14