{"id":78,"date":"2017-11-14T12:10:48","date_gmt":"2017-11-14T11:10:48","guid":{"rendered":"http:\/\/people.unipi.it\/giacomo_tanganelli\/?page_id=78"},"modified":"2017-11-15T12:24:38","modified_gmt":"2017-11-15T11:24:38","slug":"om2m-development","status":"publish","type":"page","link":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/","title":{"rendered":"OM2M Development"},"content":{"rendered":"<h1 id=\"prerequisites\">Prerequisites<\/h1>\n<h3 id=\"postman\">RESTClient<\/h3>\n<p>RESTClient\u00a0is a firefox\u00a0extensions which allows to send http REST requests with custom headers.<\/p>\n<ul>\n<li>Install <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/restclient\/\">RESTClient<\/a>\u00a0extension<\/li>\n<\/ul>\n<h3 id=\"californium\">Californium<\/h3>\n<p>In order to simulate CoAP connected devices, you must download Californium.<\/p>\n<ul>\n<li>Open Eclipse<\/li>\n<li>Select Window -&gt; Show View -&gt; Other.<\/li>\n<li>In the dialog box, select the Git view.<\/li>\n<li>Click on \u201cClone a Git repository\u201d.<\/li>\n<li>In the URI form type: https:\/\/github.com\/eclipse\/californium.git<\/li>\n<li>In the second page, keep\u00a0<strong>ONLY<\/strong>\u00a0the \u201cmaster\u201d branch checkbox selected and click Next.<\/li>\n<li>Click \u201cFinish\u201d.<\/li>\n<li>This will clone the oM2M repository inside:\u00a0<code class=\"highlighter-rouge\">$HOME\/git\/californium\/<\/code>.<\/li>\n<li>Select File -&gt; Import<\/li>\n<li>In the dialog box, select Maven -&gt; Existing Maven Project.<\/li>\n<li>In the Root Directory type:\u00a0<code class=\"highlighter-rouge\">$HOME\/git\/californium\/<\/code>.<\/li>\n<li>Click \u201cFinish\u201d.<\/li>\n<\/ul>\n<h1 id=\"create-your-new-application-dedicated-node-adn\">Create your new Application Dedicated Node (ADN)<\/h1>\n<ul>\n<li>Open Eclipse<\/li>\n<li>Select File -&gt; New -&gt; Project.<\/li>\n<li>In the dialog box, select Maven -&gt; Maven Project.<\/li>\n<li>Click on \u201cNext\u201d.<\/li>\n<li>Check the \u201cCreate a simple project\u201d and click Next.<\/li>\n<li>In the second page, choose a Group id and an artifact id (e.g. it.unipi.iot.om2m and lamp, respectively).<\/li>\n<li>Click \u201cFinish\u201d.<\/li>\n<\/ul>\n<h3 id=\"add-californium-dependencies\">Add Californium dependencies<\/h3>\n<ul>\n<li>Open the\u00a0<code class=\"highlighter-rouge\">pom.xml<\/code>\u00a0file of your project.<\/li>\n<li>Switch to the last tab called\u00a0<code class=\"highlighter-rouge\">pom.xml<\/code><\/li>\n<li>Add the following dependencies and Maven repository to your pom.xml (without the dots) inside the project tag:<\/li>\n<\/ul>\n<div class=\"language-xml highlighter-rouge\">\n<pre class=\"highlight\"><code><span class=\"nt\">&lt;dependencies&gt;<\/span>\r\n...\r\n    <span class=\"nt\">&lt;dependency&gt;<\/span>\r\n            <span class=\"nt\">&lt;groupId&gt;<\/span>org.eclipse.californium<span class=\"nt\">&lt;\/groupId&gt;<\/span>\r\n            <span class=\"nt\">&lt;artifactId&gt;<\/span>californium-core<span class=\"nt\">&lt;\/artifactId&gt;<\/span>\r\n            <span class=\"nt\">&lt;version&gt;<\/span>1.1.0-SNAPSHOT<span class=\"nt\">&lt;\/version&gt;<\/span>\r\n    <span class=\"nt\">&lt;\/dependency&gt;<\/span>\r\n...\r\n<span class=\"nt\">&lt;\/dependencies&gt;<\/span>\r\n...\r\n<span class=\"nt\">&lt;repositories&gt;<\/span>\r\n...\r\n    <span class=\"nt\">&lt;repository&gt;<\/span>\r\n      <span class=\"nt\">&lt;id&gt;<\/span>repo.eclipse.org<span class=\"nt\">&lt;\/id&gt;<\/span>\r\n      <span class=\"nt\">&lt;name&gt;<\/span>Californium Repository<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n      <span class=\"nt\">&lt;url&gt;<\/span>https:\/\/repo.eclipse.org\/content\/repositories\/californium\/<span class=\"nt\">&lt;\/url&gt;<\/span>\r\n    <span class=\"nt\">&lt;\/repository&gt;<\/span>\r\n    ...\r\n<span class=\"nt\">&lt;\/repositories&gt;<\/span>\r\n<\/code><\/pre>\n<\/div>\n<h3 id=\"create-the-main-class\">Create the Main Class<\/h3>\n<ul>\n<li>Right click on your project folder in the Project Structure Tab (on the left)<\/li>\n<li>Select New -&gt; Class<\/li>\n<li>In the dialog box type the name of your class and set the package according to the Group id selected for the project (it is not required but it is a good practice).<\/li>\n<li>Check the \u201cpublic static void main(String[] args)\u201d in the stub creation section and click Finish.<\/li>\n<li>Finally to make your jar executable modify the\u00a0<code class=\"highlighter-rouge\">pom.xml<\/code>\u00a0adding the following before the\u00a0<code class=\"highlighter-rouge\">&lt;\/project&gt;<\/code>\u00a0closing tag:<\/li>\n<\/ul>\n<div class=\"language-xml highlighter-rouge\">\n<pre class=\"highlight\"><code>&lt;build&gt;\r\n\r\n  &lt;plugins&gt;\r\n    &lt;!-- download source code in Eclipse, best practice --&gt;\r\n    &lt;plugin&gt;\r\n      &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;maven-eclipse-plugin&lt;\/artifactId&gt;\r\n      &lt;version&gt;2.9&lt;\/version&gt;\r\n      &lt;configuration&gt;\r\n        &lt;downloadSources&gt;true&lt;\/downloadSources&gt;\r\n        &lt;downloadJavadocs&gt;false&lt;\/downloadJavadocs&gt;\r\n      &lt;\/configuration&gt;\r\n    &lt;\/plugin&gt;\r\n\r\n    &lt;!-- Set a compiler level --&gt;\r\n    &lt;plugin&gt;\r\n      &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\r\n      &lt;version&gt;2.3.2&lt;\/version&gt;  \r\n    &lt;\/plugin&gt;\r\n\r\n    &lt;!-- Maven Assembly Plugin --&gt;\r\n    &lt;plugin&gt;\r\n      &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;maven-assembly-plugin&lt;\/artifactId&gt;\r\n      &lt;version&gt;2.4.1&lt;\/version&gt;\r\n      &lt;configuration&gt;\r\n        &lt;!-- get all project dependencies --&gt;\r\n        &lt;descriptorRefs&gt;\r\n          &lt;descriptorRef&gt;jar-with-dependencies&lt;\/descriptorRef&gt;\r\n        &lt;\/descriptorRefs&gt;\r\n        &lt;!-- MainClass in mainfest make a executable jar --&gt;\r\n        &lt;archive&gt;\r\n          &lt;manifest&gt;\r\n            &lt;mainClass&gt;$PACKAGE.$MAINCLASS&lt;\/mainClass&gt;\r\n          &lt;\/manifest&gt;\r\n        &lt;\/archive&gt;\r\n      &lt;\/configuration&gt;\r\n      &lt;executions&gt;\r\n        &lt;execution&gt;\r\n          &lt;id&gt;make-assembly&lt;\/id&gt;\r\n          &lt;!-- bind to the packaging phase --&gt;\r\n          &lt;phase&gt;package&lt;\/phase&gt;\r\n          &lt;goals&gt;\r\n            &lt;goal&gt;single&lt;\/goal&gt;\r\n          &lt;\/goals&gt;\r\n        &lt;\/execution&gt;\r\n      &lt;\/executions&gt;\r\n    &lt;\/plugin&gt;\r\n  &lt;\/plugins&gt;\r\n&lt;\/build&gt;\r\n<\/code><\/pre>\n<\/div>\n<p>where in my example\u00a0<code class=\"highlighter-rouge\">$PACKAGE = it.unipi.iot.om2m<\/code>\u00a0while\u00a0<code class=\"highlighter-rouge\">$MAINCLASS = Lamp<\/code>.<\/p>\n<h4 id=\"run-your-application\">Run your application<\/h4>\n<ul>\n<li>Go inside your project root folder, e.g.\u00a0<code class=\"highlighter-rouge\">$HOME\/workspace\/lamp<\/code>.<\/li>\n<li>Type\u00a0<code class=\"highlighter-rouge\">mvn package<\/code>. It will generate the jar file inside the target folder.<\/li>\n<li>Execute your application by issuing:<\/li>\n<\/ul>\n<div class=\"language-bash highlighter-rouge\">\n<pre class=\"highlight\"><code><span class=\"gp\">$ <\/span>java -jar target\/<span class=\"nv\">$ARTIFACTID<\/span>-0.0.1-SNAPSHOT-jar-with-dependencies.jar\u00a0\r\n<\/code><\/pre>\n<\/div>\n<p>where in my example\u00a0<code class=\"highlighter-rouge\">$ARTIFACTID = lamp<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites RESTClient RESTClient\u00a0is a firefox\u00a0extensions which allows to send http REST requests with custom headers. Install RESTClient\u00a0extension Californium In order&hellip;<\/p>\n<p><a class=\"btn btn-dark btn-sm unipi-read-more-link\" href=\"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":450,"featured_media":0,"parent":80,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-78","page","type-page","status-publish","hentry"],"acf":[],"featured_image_src":null,"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OM2M Development - Giacomo Tanganelli<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OM2M Development - Giacomo Tanganelli\" \/>\n<meta property=\"og:description\" content=\"Prerequisites RESTClient RESTClient\u00a0is a firefox\u00a0extensions which allows to send http REST requests with custom headers. Install RESTClient\u00a0extension Californium In order&hellip;Read More...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/\" \/>\n<meta property=\"og:site_name\" content=\"Giacomo Tanganelli\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-15T11:24:38+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/om2m-development\\\/\",\"url\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/om2m-development\\\/\",\"name\":\"OM2M Development - Giacomo Tanganelli\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/#website\"},\"datePublished\":\"2017-11-14T11:10:48+00:00\",\"dateModified\":\"2017-11-15T11:24:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/om2m-development\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/om2m-development\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/om2m-development\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Teaching\",\"item\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"OM2M\",\"item\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/teaching\\\/om2m\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"OM2M Development\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/#website\",\"url\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/\",\"name\":\"Giacomo Tanganelli\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/people.unipi.it\\\/giacomo_tanganelli\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OM2M Development - Giacomo Tanganelli","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/","og_locale":"en_US","og_type":"article","og_title":"OM2M Development - Giacomo Tanganelli","og_description":"Prerequisites RESTClient RESTClient\u00a0is a firefox\u00a0extensions which allows to send http REST requests with custom headers. Install RESTClient\u00a0extension Californium In order&hellip;Read More...","og_url":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/","og_site_name":"Giacomo Tanganelli","article_modified_time":"2017-11-15T11:24:38+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/","url":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/","name":"OM2M Development - Giacomo Tanganelli","isPartOf":{"@id":"https:\/\/people.unipi.it\/giacomo_tanganelli\/#website"},"datePublished":"2017-11-14T11:10:48+00:00","dateModified":"2017-11-15T11:24:38+00:00","breadcrumb":{"@id":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/om2m-development\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/people.unipi.it\/giacomo_tanganelli\/"},{"@type":"ListItem","position":2,"name":"Teaching","item":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/"},{"@type":"ListItem","position":3,"name":"OM2M","item":"https:\/\/people.unipi.it\/giacomo_tanganelli\/teaching\/om2m\/"},{"@type":"ListItem","position":4,"name":"OM2M Development"}]},{"@type":"WebSite","@id":"https:\/\/people.unipi.it\/giacomo_tanganelli\/#website","url":"https:\/\/people.unipi.it\/giacomo_tanganelli\/","name":"Giacomo Tanganelli","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/people.unipi.it\/giacomo_tanganelli\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/pages\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/users\/450"}],"replies":[{"embeddable":true,"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":5,"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/pages\/78\/revisions"}],"predecessor-version":[{"id":97,"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/pages\/78\/revisions\/97"}],"up":[{"embeddable":true,"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/pages\/80"}],"wp:attachment":[{"href":"https:\/\/people.unipi.it\/giacomo_tanganelli\/wp-json\/wp\/v2\/media?parent=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}