Right Money Management App For Your Financial Goals
Â
IoTivity: From Devices to the Cloud
1. Samsung Open Source Group 1 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Philippe Coval + Ziran Sun
Samsung Open Source Group / SRUK
philippe.coval@osg.samsung.com
ziran.sun@samsung.com
From devices to cloud
Free and Open Source Developers' European Meeting
#FOSDEM, Brussels, Belgium <2017-02-04>
2. Samsung Open Source Group 2 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Bonjour tout le monde !
â We're software engineers from Samsung OSG
â Ask Philippe Coval for IoTivity, Tizen, Yocto, Automotive
â About OS/hardware support, build & usages (English, French)
â https://wiki.tizen.org/wiki/User:Pcoval
â Ask Ziran Sun for IoTivity, Web
â About internal, cloud (English, Chinese)
â https://fosdem.org/2016/schedule/speaker/ziran_sun/
3. Samsung Open Source Group 3 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Agenda
â A Vehicle to Infrastructure IoT demonstration
â What is OCF/IoTivity ?
â Prototyping using NodeJS
â Sensor monitoring
â Notification to cloud
â More cloud facilities
â Q&A or/and extras
?
4. Samsung Open Source Group 4
âAny sufficiently
advanced technology
is indistinguishable
from magic.â
~ Arthur C. Clarke
5. Samsung Open Source Group 5 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
How to track defectives street lights?
â 1: Measure if outside's lighting is too dark
â Embedded sensor in car (demo: I²C sensor)
â 2: Get position from satellites (GPS, Galileo)
â From: car, mobile or any (demo: simulated)
â 3: Send notice to Internet (Cloud)
â Using mobile data
â 4: Forward information to city services (pull or push)
â 5: Agent is assigned
â 6: to fix defective light
â 7: he can also check âopen dataâ base from his mobile
â ...
11
2
3
5
6
4
7
6. Samsung Open Source Group 6 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
From devices to cloud AutoLinux demo
https://vimeo.com/202478132#iotivity-artik-20170204rzr
7. Samsung Open Source Group 7 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
âSimplicity
is the ultimate sophistication.â
~Leonardo da Vinci
8. Samsung Open Source Group 8 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Open Connectivity Foundation
â âProviding the software Linking the Internet of Thingsâ
â Creating a specification, based on open standards:
â Resource based, RESTful architecture (Stateless. client/server...)
â IETF, CoAP protocol (Web on UDP), CBOR (JSON in binary)...
â Sponsoring an open source reference implementation (IoTivity)
â Join 190+ members to
â Discuss specification, propose RFC
â Test products in Plugfests & certify them
â Propose new data models (OneIoTA.org)
9. Samsung Open Source Group 9 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Flow: Create, Read, Update, Delete, Notify
IoTivity Server IoTivity Client(s)
Local IP Network
Registration of resource
Handling new requests Set/Get/ing properties values
Initialization as server Initialization as client
Handling new clients Discovery of resource
POST/PUT GET
UDP Multicast
+ CoAP
Notify updated resource Observe resource change
& Handling propertiesOBSERVE
10. Samsung Open Source Group 10 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity Framework for connecting devices
â Hardware: CPU, MCU, Desktop, SBC, Tizen devices
â OS: Many including Linux, Tizen, Yocto or baremetal...
â
C API: Data transmission (flash footprint ~128KiB-)
â Resource Model / Serialization (CBOR)
â Connectivity Abstraction: CoAP, Local IP Network, BT, BLE...
â Discovery (UDP, Multicast), Security (DTLS/TLS)
â C++ API
â C++11 OOP, Provisioning Service...
â + High level services (Mostly C++)
â Data/Device Management, Hosting, Encapsulation...
11. Samsung Open Source Group 11
âTalk is cheap.
Show me the code.â
~ Linus Torvalds
12. Samsung Open Source Group 12 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Welcome to JavaScript developers !
â IoT is not reserved for embedded (few) developers (many)
â NodeJS a run time environment of choice for prototyping
â Huge community = Consistent repository of many modules
â to be installed using node package manger
â Packaged for many OSes: GNU/Linux, Tizen, Yocto
â IoTivity-node: npm install iotivity-node
â binds IoTivity CSDK (Core Library) to Javascript
â Of course is interoperable with native servers or clients
â Let's get started, with a yocto distro with node, npm, iotivity-node
13. Samsung Open Source Group 13 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
BH1750 Digital Light Sensor
â Illuminance: [1 â 65535] lx
â Datasheet: bh1750fvi-e.pdf
â Uses I²C bus interface
â 5P: GND, ADD (to GND), SDA, SCL, VCC
â Check presence:
â /dev/i2c-1 on Raspberry Pi2
â I2cdetect -y 1 : will tell the address to use
â NodeJS package(s) available:
â https://www.npmjs.com/search?q=bh1750
â npm install bh1750
//Â https://www.npmjs.com/package/bh1750
var BH1750 = require('bh1750');
var device = '/dev/i2cÂ1';
var address = 0x23;
var options = {Â
    address: address, device: device,
    command: 0x10, // 1 lx resolution
    length: 2
};
var sensor = new BH1750( { options } )
sensor.readLight(function(value){
   console.log(value);
   // emit('update', value);
});
14. Samsung Open Source Group 14 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
OCF: Resources Data Models: oneIoTa
â Resource is identified by an URI
â Composed of properties
â Declared by a ResourceType
â Operations: CRUD+N
â Create, Read, Update, Delete+ Notify
â Use existing known resource models
â From oneIoTa.org repository
â Ie: sensors, geolocation...
â Or create new ones (new names)
â Share for interoperability
â http://www.oneiota.org/revisions/1863
â oic.r.sensor.illuminance.json
â /* âŚÂ */ "definitions": {
  "oic.r.sensor.illuminance": {
    "properties": {
      "illuminance": {
        "type": "number",
        "readOnly": true,
        "description":
    "Sensed luminous flux in lux."
}  }  } /* âŚÂ */Â
15. Samsung Open Source Group 15 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity-node Server notifies
â Intialize server and register resource:
iotivityÂ
=Â require("iotivityÂnode/lowlevel");
iotivity.OCInit(null, 0, OC_SERVER);
iotivity.OCCreateResource(
   handleReceptacle,
   resourceType,
   OC_RSRVD_INTERFACE_DEFAULT,
   "/IlluminanceResUri", // URL
   handleEntity,
   OC_DISCOVERABLE | OC_OBSERVABLE);
â resourceType define Payload's data and format:
â //Â ie:Â "oic.r.sensor.illuminance"
â {Â âilluminanceâ:Â 42Â }Â
â
handleEntity Is a callback on client(s) requests
â Register observers
â Respond to requests (GET, POST, PUT)
â notify(value) to observers using:
â iotivity.OCNotifyListOfObservers
â Integrate ambient sensor by trapping events:
â source.on("update", notify )
â Processing loop:
setInterval(function(
 {iotivity.OCProcess();}, 1000);
16. Samsung Open Source Group 16 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity-node Client observes
var client = require("iotivityÂnode").client;
client.on("resourcefound", function(resource) {
    if ("/IlluminanceResUri" === resource.resourcePath){
        resource.on("update", function(resource) {
            console.log(JSON.stringify(resource.properties));Â
            // OR update UI, forward elsewhere?
        };
    }
});
client.findResources().catch(Â function(error)Â {Â process.exit(1);Â }Â );
17. Samsung Open Source Group 17 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Forward data to a cloud backend
â Login your artik.io dashboard
â Select or define data models
â https://developer.artik.cloud/dashboard/devicetypes
â Declare devices: (Copy IDs)
â https://my.artik.cloud/devices
â Monitor:
â https://my.artik.cloud/data
â Send data: (REST, WS, CoAP, MQTT)
â From iotivity's resource âupdateâ event
â Using http REST
require("node-rest-client").Client;
client.post(url, message, callback);
â https://api.artik.cloud/v1.1/messages
â message = {Â
  headers: {
    'ContentÂType': 'application/json',Â
     Authorization: 'bearerÂ
                BADC0DE(...)DEADBEEF42'
}, data: {
    sdid:'deadbeef(...)badc0de13',
    ts: 1485178599672,
    type: 'message',
    data: { illuminance: 42 }Â
}Â }
18. Samsung Open Source Group 18 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
/GeoLocationResURI
{
latitude: 52.165,
longitude: -2.21,
}
A Vehicle to Infrastructure notification service
function handle(illuminance) {
  if (gThreshold > illuminance) {
    var data= { illuminance: illuminance,
                latitude: gGeo.latitude, longitude: gGeo.longitude };
    sender.send(data); // { ARTIK's client.post(url...); }
}Â }
client.on("resourcefound", function(resource) {
  if ("/IlluminanceResURI" === resource.resourcePath) {
    resource.on("update", handle);
  } else if ("/GeolocationResURI" === resource.resourcePath) {
    resource.on("update",
      function(resource) { gGeo = resource.properties; });
}Â };
1
2
/IlluminanceResURI
{
illuminance: 42
}
https://api.artik.cloud/
{
illuminance: 42,
latitude: 52.165,
longitude: -2.21
}
3
1
20. Samsung Open Source Group 20 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity Clouds
â Cloud Interface
â Authentication
â OAuth2
â Message Queue
â Publish
â Subscribe
â Directory (RD)
21. Samsung Open Source Group 21 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity Services
â A common set of functionalities to application development.
â Resource Container
â Notification
â Resource Encapsulation
â Scene Manager
â Easy setup
â
22. Samsung Open Source Group 22 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Summary
â OCF establishes a standard for interconnecting things
â Open Source project IoTivity implements it in C and C++
â NodeJS is a nice tool to prototype a scenario
â IoTivity node to use CSDK core implementation of OCF
â + npm modules to support, hardware, cloud API
â ARTIK Cloud is providing a backend
â IoTivity native cloud extends connectivity to global
â IoTivity Service make app development easier
23. Samsung Open Source Group 23 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
References
â Entry points:
â https://wiki.iotivity.org/examples : git clone iotivity-example
â https://wiki.iotivity.org/docker : cloud images from Ondrej Tomcik
â http://wiki.iotivity.org/automotive
â Going further:
â https://openconnectivity.org/resources/iotivity
â https://openconnectivity.org/resources/oneiota-data-model-tool
â https://news.samsung.com/global/samsung-contributes-to-open-iot-showcase-at-ces-2017
â Keep in touch online:
â https://wiki.iotivity.org/community
â https://wiki.tizen.org/wiki/Meeting
â https://blogs.s-osg.org/author/pcoval/
25. Samsung Open Source Group 25 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Use GeoLocation resource in Tizen apps
https://vimeo.com/164000646#tizen-genivi-20160424rzr
26. Samsung Open Source Group 26 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
CES2017: Smart Home & Automotive demos
https://youtu.be/3d0uZE6lHvo
27. Samsung Open Source Group 27 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
IoTivity native cloud
â Cloud Interface
â Account Server
â to support multi-user (secured connection)
â OAuth2 over CoAP
â Message Queue Server
â broker to support PUB/SUB
â Resource Directory Server
â CoAP over TCP
â encoder/decoder with TLS
â CoAP HTTP Proxy
â for message mapping/parsing
28. Samsung Open Source Group 28 https://fosdem.org/2017/schedule/event/iot_iotivity/Samsung Open Source Group
Merci / 谢谢
Thanks / ęł ë§ěľëë¤
Samsung OSG, SRUK, SEF, SSI,
Open Connectivity Foundation and members, LinuxFoundation,
FLOSS Communities: Tizen, Yocto, EFL, AGL, GENIVI, eLinux,
Resources: xkcd.com, FlatIcons
(CC BY 3.0: Freepik,Scott de Jonge, Gregor Cresnar)
Tools: Libreoffice, openshot,
FOSDEM attendees & YOU !
Contact:
https://wiki.tizen.org/wiki/User:Pcoval