iot meets security - archive.fosdem.org · –module system: native (c) and javascript modules –...

15
1 Samsung Open Source Group Ziran Sun [email protected] Samsung Open Source Group Samsung Research, UK FOSDEM 2018 Brussels, Belgium, February 3 &4, 2018. IoT.js A JavaScript platform for the Internet of Things

Upload: others

Post on 12-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

1 Samsung Open Source Group

Ziran Sun [email protected]

Samsung Open Source Group

Samsung Research, UK

FOSDEM 2018 Brussels, Belgium, February 3 &4, 2018.

IoT.js A JavaScript platform for the Internet of Things

Page 2: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

2 Samsung Open Source Group

Overview

• IoT.js Blinkt! light demo

• Demo walk-through

IoT.js

Blinkt! module

• Questions

Page 3: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

3 Samsung Open Source Group

IoT.js Blinkt! Light Demo

Page 4: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

4 Samsung Open Source Group

IoT.js Blinkt! Light Demo

Blinkt Light

GPIO

Raspberry Pi Zero W (512k RAM, 8GB flash)

Blinkt Module IoT.js

JerryScript Linux

OpenWeatherMapAPI from

Openweathermap.org

Weather data

https.request

Page 5: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

5 Samsung Open Source Group

IoT.js Blinkt! Light Demo

Demo implemented

Fully in JavaScript

Page 6: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

6 Samsung Open Source Group

IoT.js

Page 7: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

7 Samsung Open Source Group

IoT.js

• IoT.js aims to provide inter-operable service platform in the world of IoT. • Based on web technology and run on top of JerryScript • Designed to bring the success of Node.js to constrained IoT devices. • Runs ECMASCript application which can access device resource (network, File system)

Page 8: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

8 Samsung Open Source Group

IoT.js architecture

Page 9: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

9 Samsung Open Source Group

JerryScript

• An ultra lightweight JavaScript engine

• Originally developed from scratch by Samsung

• Heavily optimized for low memory footprint

• Self-contained and extremely portable

Page 10: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

10 Samsung Open Source Group

JerryScript

• Transferred to JS Foundation in 2016

• Lightweight, modular, ECMAScript

• Features added:

– Introduced a debugger

– ES6 related features:

promise, TypedArray

– More hardware support:

e.g. ARM m-bed

Page 11: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

11 Samsung Open Source Group

IoT.js

• Released 1.0 (July 2017) – Asynchronous, event driven I/O (libtuv)

– Module system: native (C) and JavaScript modules

– Node.js friendly architecture

– Supports a subset of core Node.js modules, e.g. fs, events, http, net and stream etc

– Provide a list of I/O control hardware modules

Page 12: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

12 Samsung Open Source Group

Blinkt! Light Module

Page 13: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

13 Samsung Open Source Group

Blinkt! Light Module

• A JavaScript library to Interact with Blinkt! LEDs on RPi

• Use GPIO interfaces in IoT.js

var gpio = require('gpio');; Blinkt.prototype.setup = function setup() { gpio_dat = gpio.open({ pin: DAT, direction: gpio.DIRECTION.OUT }, function(err) { }); } function writeByte(byte) { var bit; … gpio_dat.write(bit); … }

Page 14: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

14 Samsung Open Source Group

Integrate Blinkt! Module in IoT.js

• Add module in iotjs/src/modules.json

"blinkt": {

"js_file": "js/blinkt.js“,

"require": [“gpio"]

}

• Enable module in Build

-- ENABLE_MODULE_BLINKT

Page 15: IoT Meets Security - archive.fosdem.org · –Module system: native (C) and JavaScript modules – Node.js friendly architecture – Supports a subset of core Node.js modules, e.g

Thank you.

15 Samsung Open Source Group