nCube Rosemary

IoT Middle Node Device Platform based on Node.js.

Node Device

IoT

v2.4.0
May 31, 2018

nmsung@keti.re.kr
Sung, Nak-Myoung

Git Hub Project Link
&Cube:Rosemary

 

Gub Hub Release Direct DownLoad Link
Direct Link Revision Release Date
nCube-Rosemary-2.4.0.zip v2.4.0 May 2018
nCube-Rosemary-2.0.0.zip v2.0.0 July 2017

nCube:Rosemary Functionalities

As one of the oneM2M platforms, nCube:Rosemary provides common service functions (CSFs) to oneM2M applications and other oneM2M devices. nCube:Rosemary does have an implementation of MN-CSE defined in oneM2M Functional Architecture and thus it acts as gateway and provides proximity based IoT service.

nCube:Rosemary S/W Architecture

nCube:Rosemary shares the common source codes with Mobius platform since it has similarities of which it can act as a server (i.e., Mobius) and accept a registration request except being registered with other CSEs.

 

nCube:Rosemary Source Code Directory  

Source File Role and Function
rosemary.js It configures settings of nCube:Rosemary and also is used to run nCube:Rosemary.
app.js This file acts as role of flow router and it is the main code running Mobius-YT server.

① It handles initial processing of received packets.

② It initiates HTTP server with ‘listening’ mode to wait for HTTP requests target to the Mobius HTTP server.

③ It handles the parsing of URL of packets and evaluate the correctness of the request body resulted of parsing. It then sends the request to resource.js to continue the processing if the request is valid one, otherwise throws exceptions.

This file also implements the server clustering algorithms to improve the performance of HTTP server.

mobius/resource.js It is core file to process the CREATE, RETRIEVE, UPDATE, DELETE, NOTIFY and DISCOVERY operations for oneM2M resource primitives. This file undertakes the processing of parsed request URI and request body received from app.js according to corresponding operation. It converts the data into a format to process the data and connect to mysql database. The mysql database is initialized and handled by db_action.js and sql_action.js module.
mobius/responder.js It is responsible for handling the response process. It receives processing results from app.js and resource.js modules and generates responses from the processing results following format requested by originator either XML or JSON serialization.
mobius/db_action.js This file contains parameters used to connect and access to the database and parameters for returning response results from the database.
mobius/sql_action.js This file contains functions to receive data and parameters required for a series of database operations and functions to call db_action.js module to return data from database.
mobius/sgn.js This module file is responsible for checking the existence of <subscription> child resource under the requested target resource. If it exists, the module checks the event type and retrieves the field value of attribute notificationUril. Then it generates and sends a notification message to the address indicated by field value of attribute notificationUril.
mobius/security.js This file contains functions to check the access privileges of originators for a requested resource when the resource applies with <accessControlPolicy> resource. The originator ID is abstracted from request header field of X-M2MOrigin. The process checks the access right of current originator ID to a target resource and responds with ACESS_DENIED error when the originator ID has no privileges to access to the resource.
mobius/fopt.js
mobius/ts_agent.js This file contains functions to manage <timeSeriesInstance> resource. It monitors the mssing data in the <timeSeriesInstance> resource and then stores the missing data.
pxymqtt.js

This file contains functions implementing mqtt proxying function to handle mqtt protocol messages in http protocol manner as following procedures:

① It creates a oneM2M mqtt topic with configuration information of Mobius server and then subscribe to the topic to receive mqtt requests targeted to this topic later.

② Whenever receiving mqtt protocol messages, it generates and sends a http request wrapping mqtt request message to Mobius server and waits for http response from Mobius server. It then abstracts http response and generates a mqtt response message correspondingly.

③ It responds with mqtt protocol message.

pxy_coap.js

This file contains functions implementing coap proxying function to handle coap protocol messages with http protocol module.

pxu_ws.js

This file contains functions implementing websocket proxying function to handle websocket protocol messages with http protocol module.

mobius/acp.js It contains functions to parse accessControlPolicy request. The accessControlPolicy resource is used to manage the access control privileges to resources that apply with access control policy.
mobius/ae.js It contains functions to parse AE request.
mobius/cb.js It contains functions to parse CSEBase request. The CSEBase resource contains configuration information of Mobius server.
mobius/cin.js It contains functions to parse contentInstance request.
mobius/cnt.js It contains functions to parse container request.
mobius/csr.js It contains functions to parse remoteCSE request.
mobius/grp.js It contains functions to parse group request.
mobius/lcp.js It contains functions to parse locationPolicy request.
mobius/mms.js It contains functions to parse multimediaSession request.
mobius/mn.js It contains functions to register this CSE to the other CSE.
mobius/sd.js It contains functions to parse semanticDescriptor request.
mobius/sub.js It contains functions to parse subscription request.
mobius/ts.js It contains functions to parse timeSeries request.
mobius/tsi.js It contains functions to parse timeSeriesInstance request.

nCube-Rosemary


Introduction

The nCube-Rosemary is the open source IoT gateway platform based on the oneM2M (http://www.oneM2M.org) standard. As one of the oneM2M platforms, nCube-Rosemary provides common services functions to oneM2M applications and other oneM2M devices. So the nCube-Rosemary can be used to provide proximity based IoT services. As defined in the specifications, nCube-Rosemary as MN-CSE also provides interworking functionalities via IPE (Interworking Proxy Entity).

System stucture

nCube-Rosemary implementation of oneM2M MN-CSE which interconnects ASN-CSE or ADN-AE to IN-CSE.

Installation

The nCube-Rosemary is based on Node.js framework and uses MySQL for database.

 

  • MySQL Server
    The MySQL is an open source RDB database so that it is free and ligth. And RDB is very suitable for storing tree data just like oneM2M resource stucture. Most of nCube-Rosemary will work in a restricted hardware environment and the MySQL can work in most of embeded devices.
  • Node.js
    Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. Node.js is very powerful in service impelementation because it provide a rich and free web service API. So, we use it to make RESTful API base on the oneM2M standard.
  • Mosquitto
    Eclipse Mosquitto™ is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for “Internet of Things” messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers like the Arduino.
  • nCube-Rosemary
    nCube-Rosemary source codes are written in javascript. So they don’t need any compilation or installation before running.

Configuration

  • Import SQL script
    After installation of MySQL server, you need the DB Schema for storing oneM2M resources in nCube-Rosemary. You can find this file in the foloowing nCube-Rosemary source directory.
[nCube-Rosemary home]/mobius/mobiusdb.sql
  • Run Mosquitto MQTT broker
mosquitto -v
  • Open the nCube-Rosemary source home directory
  • Install dependent libraries as below
npm install
  • Modify the configuration file “conf_mn.json” per your setting
{
  "parent": {
    "cbname": "Mobius",             //CSEbase name
    "cbcseid": "/Mobius",           //CSEbase ID
    "cbhost": "203.253.128.161",    //CSEbase host IP
    "cbhostport": "7579",           //CSEbase http hosting port
    "cbprotocol": "http",           //CSEbase communication protocol
    "mqttbroker": "203.253.128.161" //MQTT Broker IP 
  },
  "csebaseport": "7599",            //MN-CSE HTTP hosting IP
  "dbpass": "dksklfdug2"            //Local MySQL root password
}

Run

Use node.js application execution command as below

node rosemary.js

 

Dependency Libraries

This is the list of library dependencies for nCube-Rosemary

  • body-parser
  • cbor
  • coap
  • crypto
  • events
  • express
  • file-stream-rotator
  • fs
  • http
  • https
  • ip
  • js2xmlparser
  • merge
  • morgan
  • mqtt
  • mysql
  • shortid
  • url
  • util
  • websocket
  • xml2js
  • xmlbuilder

Document

If you want more details please dowload the full installation guide document.

BSD 3-Clause License

Copyright (c) 2017, IoTKETI All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.