OM2M Installation

Prerequisites

  • Git
  • Apache Maven
  • Oracle Java 8

Install Git

$ sudo apt-get install git

Install Apache Maven

$ sudo apt-get install maven

Install Oracle Java 8

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Configure JAVA_HOME

To set this environment variable, we will first need to find out where Java is installed. You can do this by executing:

$ sudo update-alternatives --config java

Copy the path from your preferred installation and then open /etc/environment using nano or your favorite text editor.

$ sudo nano /etc/environment

At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path.

JAVA_HOME="/usr/lib/jvm/java-8-oracle"

Save and exit the file, and reload it.

$ source /etc/environment

You can now test whether the environment variable has been set by executing the following command:

$ echo $JAVA_HOME

This will return the path you just set.

Configure Eclipse for developing oM2M

First of all, install the lastest Eclipse for RCP and RAP Developers (at time of writing Eclipse Neon 1).

Install Tycho Plugin

Click Window -> Preferences -> maven -> discovery -> open catalog and type Tycho. Check the “Tycho Configurator” checkbox and install the connector.

Clone oM2M repository

  • Select Window->Show View -> Other.
  • In the dialog box, select the Git view.
  • Click on “Clone a Git repository”.
  • In the URI form type: https://git.eclipse.org/r/om2m/org.eclipse.om2m
  • In the second page, keep ONLY the “master” branch checkbox selected and click Next.
  • In the third page, check the “import all existing projects after clone finishes” and click “Finish”.
  • This will clone the oM2M repository inside: $HOME/git/

Enable CoAP on MN

In order to enable CoAP an the MN edit the $HOME/git/om2m/org.eclipse.om2m/org.eclipse.om2m.site.mn-cse/om2m.product:

<plugins>
...
<plugin id="org.eclipse.jetty.util"/>
<plugin id="org.eclipse.om2m.binding.coap"/>
<plugin id="org.eclipse.om2m.binding.http"/>
...
</plugins>
...
<configurations>
...
<plugin id="org.eclipse.equinox.http.jetty" autoStart="true" startLevel="1" />
<plugin id="org.eclipse.om2m.binding.coap" autoStart="true” startLevel="2" />
<plugin id="org.eclipse.om2m.binding.http" autoStart="true" startLevel="2" />
...
</configurations>
...

Then edit the code of $HOME/git/org.eclipse.om2m/org.eclipse.om2m.binding.coap/src/main/java/org/eclipse/om2m/binding/coap/CoAPServer.java, change line 145 from:

requestPrimitive.setTo(request.getUri());

to:

requestPrimitive.setTo(targetId);

CoAP Notifications

Edit the code of $HOME/git/org.eclipse.om2m/org.eclipse.om2m.binding.coap/src/main/java/org/eclipse/om2m/binding/coap/CoAPClient.java, at line 334 change the switch statements according to:


 case 69: return ResponseStatusCode.OK;
 case 68: return ResponseStatusCode.ACCEPTED;
 case 65: return ResponseStatusCode.CREATED; 
 case 66: return ResponseStatusCode.DELETED;
 case 128: return ResponseStatusCode.BAD_REQUEST;
 case 131: return ResponseStatusCode.ACCESS_DENIED;
 case 132: return ResponseStatusCode.NOT_FOUND;
 case 133: return ResponseStatusCode.OPERATION_NOT_ALLOWED;
 case 134: return ResponseStatusCode.CONFLICT;
 case 160: return ResponseStatusCode.INTERNAL_SERVER_ERROR;
 case 161: return ResponseStatusCode.NOT_IMPLEMENTED;
 case 163: return ResponseStatusCode.SERVICE_UNAVAILABLE;
 default: return ResponseStatusCode.INTERNAL_SERVER_ERROR;

Finally, change the code of $HOME/git/org.eclipse.om2m/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java, change line 310 from:

if(ResponseStatusCode.OK.equals(response.getResponseStatusCode())){

to:

if(ResponseStatusCode.CREATED.equals(response.getResponseStatusCode())){

Build oM2M

Build from shell

Replace the $HOME with your home folder path.

$ cd $HOME/git
$ mvn clean install

Build from Eclipse

  • Select “org.eclipse.om2m” package and right click
  • Select “Run as -> maven install”

Build Results

Two Eclipse products will be generated after a successful built: * The IN product can be found on this generic directory:

$HOME/git/om2m/org.eclipse.om2m/org.eclipse.om2m.site.in-cse/target/products/in-cse/<os>/<ws>/<arch>
  • The MN product can be found on this generic directory:
$HOME/git/om2m/org.eclipse.om2m/org.eclipse.om2m.site.mn-cse/target/products/mn-cse/<os>/<ws>/<arch>
  • The ASN product can be found on this generic directory:
$HOME/git/om2m/org.eclipse.om2m/org.eclipse.om2m.site.asn-cse/target/products/asn-cse/<os>/<ws>/<arch>

where on a linux environment running in a 64 bit machine the last part of each URI is translated to:

linux/gtk/x86_64

Università di Pisa
Lungarno Pacinotti 43, 56126 Pisa
P.I. 00286820501
C.F. 80003670504

Servizio a cura del
SIA - Sistema Informatico di Ateneo
help@people.unipi.it

Back to top