SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Mastering The IoT
With JavaScript And C++
Günter Obiltschnig
Applied Informatics Software Engineering GmbH
guenter@appinf.com
@obiltschnig, @macchina_io
About Me
hard-core C++ developer (20+ years), 

who also likes JavaScript
“full stack++”, embedded, hardware 

to web frontend + cloud
POCO C++ Libraries (2004)
Applied Informatics GmbH (2006)
my-devices.net (2010)
AIS Radar for iOS (2011)
macchina.io (2013)
m .ioacchina
|‘makkina| – A modular open source toolkit for building
embedded IoT applications that connect sensors, devices 

and cloud services.
IoT Gateway
devices.netCloud Services
AirVantage, Amazon, 

Bluemix, Carriots, etc.
HTTP(S), REST
MQTT
Remote Access
my-devices.net
device apps
local“business logic”
web services
web visualization
database
discoverability
Mobile/Web
Clients
Devices/Sensor Networks
CoAP, IEEE 802.15.4,
Modbus, USB,
Bluetooth LE,
RS-232
POCO
C++ LIBRARIES
platform abstraction, multithreading, XML and JSON processing, filesystem access,

stream, datagram and multicast sockets, HTTP server and client, crypto, SSL/TLS, etc.
Remoting
serialization, remote methods and events, IPC
Open Service Platform
dynamic module system
service registry
web application server
user authentication/authorization
Platform
JavaScript
V8 JavaScript engine and C++ bindings/bridging
Devices and Sensors
Sensors, Serial Port, GNSS/GPS, Accelerometer, I/O, …
Protocols
MQTT, CoAP, Modbus, Bluetooth LE, XBee, …
Services
WebEvent, DeviceStatus, NetworkEnvironment, …
WebUI
Login, Launcher, Bundles, Playground, etc.
IoT Components
> open source (Apache 2.0 License)
> built in C++ for best performance and efficiency 

(JavaScript for parts of web interface)
> modular and extensible
> mature, proven codebase: 

POCO C++ Libraries, Google V8, Eclipse Paho, SQLite

AngularJS, jQuery, OpenLayers, Ace (text editor),

+ Applied Informatics OSP and Remoting frameworks
> C++-to-JavaScript bridge
> Raspberry Pi, Beaglebone, Edison, RED, MangOH, etc.
> prototype on Linux or OS X host, easily deploy to device
> web interface with JavaScript editor
Why JavaScript?
> Popular and widely known*
> Standardized
> Easy to integrate into an existing framework
> Multiple embeddable engines available
> Good performance (for a scripting language)
> I like it ;-)
* but not necessarily universally liked
Sensors & Devices Protocols Cloud Services
Temperature, Ambient Light, 

Humidity, Air Pressure, etc.
HTTP, HTTPS AirVantage
I/O, LED, Trigger, 

Rotary Encoder
MQTT Bluemix
Accelerometer CoAP* Twitter
GNSS/GPS WebEvent Amazon IoT
Barcode Reader, RFID* WebTunnel Twilio (SMS)
XBee (ZigBee, IEEE 802.15.4) XBee API my-devices.net
TI SensorTag Bluetooth LE any with MQTT API
Serial Port Modbus any with HTTP/REST API
* planned
Pro Users and Device Manufacturers
> add device specific APIs
> make devices programmable in JavaScript for partners or end users
> device specific app store (sell additional software features)
> additional frameworks (Shell, UPnP, Remoting SOAP and JSON-RPC)
> customizable web user interface
> improved user authentication and authorization
> signed bundles
> pro support
Usage Examples
> Building Automation
> Vehicle Telematics/Connected Cars
> Energy Manager

(photovoltaics and battery controller)
> Industrial Internet of Things Platform
Demo
Inside macchina.io
POCO
C++ LIBRARIES
platform abstraction, multithreading, XML and JSON processing, filesystem access,

stream, datagram and multicast sockets, HTTP server and client, crypto, SSL/TLS, etc.
Remoting
serialization, remote methods and events, IPC
Open Service Platform
dynamic module system
service registry
web application server
user authentication/authorization
Platform
JavaScript
V8 JavaScript engine and C++ bindings/bridging
Devices and Sensors
Sensors, Serial Port, GNSS/GPS, Accelerometer, I/O, …
Protocols
MQTT, CoAP, Modbus, Bluetooth LE, XBee, …
Services
WebEvent, DeviceStatus, NetworkEnvironment, …
WebUI
Login, Launcher, Bundles, Playground, etc.
IoT Components
POCO C++ Libraries
> Started 2004
> ~300.000 LOC
> 1000+ classes
> on GitHub since 2012 

1730+ stars

640+ forks

40-200 clones/day
> ~100 contributors
> Boost License
> http://pocoproject.org
POSIX, WIN32, other (RT)OS API
Foundation
C++ and C Standard LibrariesApplication
Zip
Net
Crypto
Data
SQLite
ODBC
MySQL
NetSSL
Util
Tools, Utilities and
additional Libraries
XML JSON
V8
> Google’s JavaScript Engine
> Used by Chrome/Chromium and node.js
> C++ library, (reasonably) easy to integrate and to extend
> Compiles JavaScript to native code (x86, ARM, MIPS)
> Great performance
> BSD License
Remoting
> Similar to .NET Remoting or Java RMI, but for C++
> Code generator parses annotated C++ header files and generates code

(serialization/deserialization, method dispatching, helpers)
> Supports different transports (binary TCP, SOAP, JSON-RPC)
> Used for automatic C++-to-JavaScript bridging
> Will also be used to implement sandbox mechanism
Open Service Platform (OSP)
> Inspired by OSGi, but for C++ (also JavaScript, Python, etc.)
> Dynamic module system based on bundles

(Zip files with metadata, 

shared libs, other files)
> Dependency and 

lifecycle management
> Services and service registry
> Web Server
POCO Core Libraries
(Foundation,XML,Util,Net)
Operating
System
API
Std.C/C++
Libraries
Service
Registry
Portable Runtime
Environment
Life
C
ycle
M
anagem
ent
Bundle
M
anagem
ent
Standard
Services
Bundles
install,resolve,start,stop
and uninstall bundles
provide services to other
bundles and find services
provided by other bundles
manage bundle versions
and dependencies
web server,
web- and console-
based management,
user authentication
and authorization,
preferences,etc.
application-specific
functionality and services
Combining POCO C++ Libraries and V8
> JavaScript is single-threaded and garbage-collected
> POCO is multithreaded (specifically web server)
> Make C++ object available to JavaScript

easy for static objects, just provide Wrapper
> Allow JavaScript code to create C++ objects

easy if you don’t care about memory/resource leaks
> Register a callback function called by GC when object is deleted

allows you to properly delete underlying c++ object
> However, V8 does not do callbacks when script ends

wrapped C++ objects won’t be deleted, leaks resulting
> Need to track every C++ object a script creates and clean up afterwards :-(
Automatic JavaScript
Wrappers for C++ Objects
// Sensor.h
//@ remote
class Sensor: public Device
{
public:
Poco::BasicEvent<const double> valueChanged;
virtual double value() const = 0;
virtual bool ready() const = 0;
};
Sensor.h
RemoteGen
lots of generated source files
RemoteGen.xml
Service
<<generatedFrom>>
IService
ServiceProxy
Service
RemoteObject
The interface class has
all @remote methods
from the service class.
Service
Skeleton
<<invokes>>
<<generated>>
<<generated>><<generated>>
<<generated>>
Service
ServerHelper
<<generated>>
Registers
Skeleton, RemoteObject
and EventDispatcher (if
needed) with the Object
Request Broker.
Service
ProxyFactory
<<creates>>
<<generated>>
Service
ClientHelper
<<generated>>
Registers ProxyFactory
with the Object Request
Broker.
<<registers>><<registers>>
<<registers>>
Service
EventSubscriber
<<generated>>
Service
EventDispatcher
<<generated>>
<<registers>>
var tempSensor = ...;
tempSensor.on(‘valueChanged', function(ev) {
var temp = ev.data;
// ...
});
if (tempSensor.ready())
{
var temp = tempSensor.value();
// ...
}
JavaScript Samples
// sensors.js (search sensors by physical quantity)
var sensors = {};
var illuminanceRefs = serviceRegistry.find(
'io.macchina.physicalQuantity == "illuminance"');
if (illuminanceRefs.length > 0)
{
sensors.illuminance = illuminanceRefs[0].instance();
}
var temperatureRefs = serviceRegistry.find(
'io.macchina.physicalQuantity == "temperature"');
if (temperatureRefs.length > 0)
{
sensors.temperature = temperatureRefs[0].instance();
}
var humidityRefs = serviceRegistry.find(
'io.macchina.physicalQuantity == "humidity"');
if (humidityRefs.length > 0)
{
sensors.humidity = humidityRefs[0].instance();
}
module.exports = sensors;
// sensors.js (search sensors by ID)
var sensors = {};
var illuminanceRef = serviceRegistry.findByName(
'io.macchina.xbee.sensor.illuminance#0013A20040A4D7F7');
if (illuminanceRef)
{
sensors.illuminance = illuminanceRef.instance();
}
var temperatureRef = serviceRegistry.findByName(
'io.macchina.xbee.sensor.temperature#0013A20040A4D7F7');
if (temperatureRef)
{
sensors.temperature = temperatureRef.instance();
}
var humidityRef = serviceRegistry.findByName(
'io.macchina.xbee.sensor.humidity#0013A20040A4D7F7');
if (humidityRef)
{
sensors.humidity = humidityRef.instance();
}
module.exports = sensors;
// database.js
var data = require('data');
module.exports = {
path: bundle.persistentDirectory + 'logger.db',
session: new data.Session('SQLite', database.path),
logIntervalSeconds: application.config.getInt(
'datalogger.intervalSeconds', 30),
keepDataSeconds: application.config.getInt(
'datalogger.keepDataSeconds', 3600)
};
// logger.js
var sensors = require('sensors');
var db = require('database');
db.session.execute('PRAGMA journal_mode=WAL');
db.session.execute('CREATE TABLE IF NOT EXISTS datalog ( 
timestamp INTEGER, 
illuminance FLOAT, 
temperature FLOAT, 
humidity FLOAT 
)');
setInterval(
function()
{
db.session.execute('INSERT INTO datalog VALUES (?, ?, ?, ?)',
DateTime().epoch,
sensors.illuminance.value(),
sensors.temperature.value(),
sensors.humidity.value());
},
db.logIntervalSeconds*1000);
// logger.js (continued)
setInterval(
function()
{
var cutoffTime = DateTime().epoch - db.keepDataSeconds;
db.session.execute('DELETE FROM datalog WHERE timestamp < ?',
cutoffTime);
},
db.keepDataSeconds*1000);
// history.jss - GET /history.jss?item=temperature&maxItems=10
var db = require('database');
var validItems = ['temperature', 'humidity', 'illuminance'];
var data = [];
db.session.pageSize = form.maxItems ? parseInt(form.maxItems) : 20;
var item = form.item;
if (validItems.indexOf(item) > -1)
{
var recordSet = db.session.execute(
'SELECT timestamp, ' + item + ' FROM datalog ORDER BY timestamp DESC');
// history.jss (continued)
for (var row = 0; row < recordSet.rowCount; row++)
{
var time = recordSet.getValue('timestamp');
var value = recordSet.getValue(item);
var date = new LocalDateTime(1970, 1, 1);
date.addSeconds(time);
data[recordSet.rowCount - row - 1] = {
timestamp: date.format('%H:%M:%S'),
value: value
};
recordSet.moveNext();
}
recordSet.close();
}
response.contentType = 'application/json';
response.write(JSON.stringify(data));
response.send();
// MQTT to AirVantage
var sensors = require('sensors');
var mqttClientRefs = serviceRegistry.find('io.macchina.mqtt.id == "airvantage"');
if (mqttClientRefs.length > 0)
{
console.log('MQTT Client found');
var mqttClient = mqttClientRefs[0].instance();
setInterval(function() {
var epoch = "" + 1000*DateTime().epoch; // seconds to milliseconds
var payload = {};
payload[epoch] = {
"sensors.temperature": sensors.temperature.value(),
"sensors.humidity": sensors.humidity.value()
"sensors.illuminance": sensors.illuminance.value()
};
mqttClient.publish('JA347400060803/messages/json', 

JSON.stringify(payload), 0);
}, 10000);
// twilio.js
var net = require('net');
module.exports = {
sendSMS: function(to, message) {
var accountSID = application.config.getString("twilio.accountSID");
var authToken = application.config.getString("twilio.authToken");
var from = application.config.getString("twilio.from");
var twilioHttpRequest = new net.HTTPRequest(
"POST",
"https://api.twilio.com/2010-04-01/Accounts/"
+ accountSID
+ "/SMS/Messages"
);
twilioHttpRequest.authenticate(accountSID, authToken);
twilioHttpRequest.contentType = "application/x-www-form-urlencoded";
twilioHttpRequest.content =
"From=" + encodeURIComponent(from) +
"&To=" + encodeURIComponent(to) +
"&Body=" + encodeURIComponent(message);
twilioHttpRequest.send(function(result) {
console.log("Twilio SMS Response: %O", result);
});
};
var sensors = require('sensors');
var twilio = require('twilio');
var enableSMS = true;
sensors.illuminance.on('valueChanged', function(ev) {
logger.notice("valueChanged: " + ev.data);
if (ev.data < 10)
{
logger.warning("Lights out!");
if (enableSMS)
{
twilio.sendSMS("+4367612345678", "Lights out!");
enableSMS = false;
}
}
else if (ev.data > 50)
{
enableSMS = true;
}
});
Q&A
guenter@appinf.com | @obiltschnig | obiltschnig.com
macchina.io | my-devices.net | pocoproject.org | www.appinf.com

Más contenido relacionado

Similar a Mastering the IoT With JavaScript and C++ - Günter Obiltschnig

Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Amazon Web Services
 
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksEssential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksAmazon Web Services
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWTArnaud Tournier
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRVladimir Georgiev
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"Volker Linz
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global dominationStfalcon Meetups
 
Architecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureArchitecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureAlon Fliess
 
Shindig in 2 hours
Shindig in 2 hoursShindig in 2 hours
Shindig in 2 hourshanhvi
 
Cloud Connectivity Service
Cloud Connectivity ServiceCloud Connectivity Service
Cloud Connectivity Servicejhpark
 
IoT on Blockchain Solution Overview
IoT on Blockchain Solution OverviewIoT on Blockchain Solution Overview
IoT on Blockchain Solution OverviewProvide Technologies
 
Meego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLalMeego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLalRaj Lal
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchMongoDB
 
Deep Dive into SpaceONE
Deep Dive into SpaceONEDeep Dive into SpaceONE
Deep Dive into SpaceONEChoonho Son
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshSiddhesh Bhobe
 
.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and TomorrowJon Galloway
 

Similar a Mastering the IoT With JavaScript and C++ - Günter Obiltschnig (20)

Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
 
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksEssential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalR
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
 
Frontend. Global domination.
Frontend. Global domination.Frontend. Global domination.
Frontend. Global domination.
 
Architecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureArchitecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft Azure
 
Shindig in 2 hours
Shindig in 2 hoursShindig in 2 hours
Shindig in 2 hours
 
Cloud Connectivity Service
Cloud Connectivity ServiceCloud Connectivity Service
Cloud Connectivity Service
 
IoT on Blockchain Solution Overview
IoT on Blockchain Solution OverviewIoT on Blockchain Solution Overview
IoT on Blockchain Solution Overview
 
Meego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLalMeego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLal
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB Stitch
 
Sergey Stoyan 2016
Sergey Stoyan 2016Sergey Stoyan 2016
Sergey Stoyan 2016
 
Sergey Stoyan 2016
Sergey Stoyan 2016Sergey Stoyan 2016
Sergey Stoyan 2016
 
Deep Dive into SpaceONE
Deep Dive into SpaceONEDeep Dive into SpaceONE
Deep Dive into SpaceONE
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net Siddhesh
 
.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and Tomorrow
 
Elefrant [ng-Poznan]
Elefrant [ng-Poznan]Elefrant [ng-Poznan]
Elefrant [ng-Poznan]
 

Más de WithTheBest

Riccardo Vittoria
Riccardo VittoriaRiccardo Vittoria
Riccardo VittoriaWithTheBest
 
Recreating history in virtual reality
Recreating history in virtual realityRecreating history in virtual reality
Recreating history in virtual realityWithTheBest
 
Engaging and sharing your VR experience
Engaging and sharing your VR experienceEngaging and sharing your VR experience
Engaging and sharing your VR experienceWithTheBest
 
How to survive the early days of VR as an Indie Studio
How to survive the early days of VR as an Indie StudioHow to survive the early days of VR as an Indie Studio
How to survive the early days of VR as an Indie StudioWithTheBest
 
Mixed reality 101
Mixed reality 101 Mixed reality 101
Mixed reality 101 WithTheBest
 
Unlocking Human Potential with Immersive Technology
Unlocking Human Potential with Immersive TechnologyUnlocking Human Potential with Immersive Technology
Unlocking Human Potential with Immersive TechnologyWithTheBest
 
Building your own video devices
Building your own video devicesBuilding your own video devices
Building your own video devicesWithTheBest
 
Maximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityMaximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityWithTheBest
 
Haptics & amp; null space vr
Haptics & amp; null space vrHaptics & amp; null space vr
Haptics & amp; null space vrWithTheBest
 
How we use vr to break the laws of physics
How we use vr to break the laws of physicsHow we use vr to break the laws of physics
How we use vr to break the laws of physicsWithTheBest
 
The Virtual Self
The Virtual Self The Virtual Self
The Virtual Self WithTheBest
 
You dont have to be mad to do VR and AR ... but it helps
You dont have to be mad to do VR and AR ... but it helpsYou dont have to be mad to do VR and AR ... but it helps
You dont have to be mad to do VR and AR ... but it helpsWithTheBest
 
Omnivirt overview
Omnivirt overviewOmnivirt overview
Omnivirt overviewWithTheBest
 
VR Interactions - Jason Jerald
VR Interactions - Jason JeraldVR Interactions - Jason Jerald
VR Interactions - Jason JeraldWithTheBest
 
Japheth Funding your startup - dating the devil
Japheth  Funding your startup - dating the devilJapheth  Funding your startup - dating the devil
Japheth Funding your startup - dating the devilWithTheBest
 
Transported vr the virtual reality platform for real estate
Transported vr the virtual reality platform for real estateTransported vr the virtual reality platform for real estate
Transported vr the virtual reality platform for real estateWithTheBest
 
Measuring Behavior in VR - Rob Merki Cognitive VR
Measuring Behavior in VR - Rob Merki Cognitive VRMeasuring Behavior in VR - Rob Merki Cognitive VR
Measuring Behavior in VR - Rob Merki Cognitive VRWithTheBest
 
Global demand for Mixed Realty (VR/AR) content is about to explode.
Global demand for Mixed Realty (VR/AR) content is about to explode. Global demand for Mixed Realty (VR/AR) content is about to explode.
Global demand for Mixed Realty (VR/AR) content is about to explode. WithTheBest
 
VR, a new technology over 40,000 years old
VR, a new technology over 40,000 years oldVR, a new technology over 40,000 years old
VR, a new technology over 40,000 years oldWithTheBest
 

Más de WithTheBest (20)

Riccardo Vittoria
Riccardo VittoriaRiccardo Vittoria
Riccardo Vittoria
 
Recreating history in virtual reality
Recreating history in virtual realityRecreating history in virtual reality
Recreating history in virtual reality
 
Engaging and sharing your VR experience
Engaging and sharing your VR experienceEngaging and sharing your VR experience
Engaging and sharing your VR experience
 
How to survive the early days of VR as an Indie Studio
How to survive the early days of VR as an Indie StudioHow to survive the early days of VR as an Indie Studio
How to survive the early days of VR as an Indie Studio
 
Mixed reality 101
Mixed reality 101 Mixed reality 101
Mixed reality 101
 
Unlocking Human Potential with Immersive Technology
Unlocking Human Potential with Immersive TechnologyUnlocking Human Potential with Immersive Technology
Unlocking Human Potential with Immersive Technology
 
Building your own video devices
Building your own video devicesBuilding your own video devices
Building your own video devices
 
Maximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityMaximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unity
 
Wizdish rovr
Wizdish rovrWizdish rovr
Wizdish rovr
 
Haptics & amp; null space vr
Haptics & amp; null space vrHaptics & amp; null space vr
Haptics & amp; null space vr
 
How we use vr to break the laws of physics
How we use vr to break the laws of physicsHow we use vr to break the laws of physics
How we use vr to break the laws of physics
 
The Virtual Self
The Virtual Self The Virtual Self
The Virtual Self
 
You dont have to be mad to do VR and AR ... but it helps
You dont have to be mad to do VR and AR ... but it helpsYou dont have to be mad to do VR and AR ... but it helps
You dont have to be mad to do VR and AR ... but it helps
 
Omnivirt overview
Omnivirt overviewOmnivirt overview
Omnivirt overview
 
VR Interactions - Jason Jerald
VR Interactions - Jason JeraldVR Interactions - Jason Jerald
VR Interactions - Jason Jerald
 
Japheth Funding your startup - dating the devil
Japheth  Funding your startup - dating the devilJapheth  Funding your startup - dating the devil
Japheth Funding your startup - dating the devil
 
Transported vr the virtual reality platform for real estate
Transported vr the virtual reality platform for real estateTransported vr the virtual reality platform for real estate
Transported vr the virtual reality platform for real estate
 
Measuring Behavior in VR - Rob Merki Cognitive VR
Measuring Behavior in VR - Rob Merki Cognitive VRMeasuring Behavior in VR - Rob Merki Cognitive VR
Measuring Behavior in VR - Rob Merki Cognitive VR
 
Global demand for Mixed Realty (VR/AR) content is about to explode.
Global demand for Mixed Realty (VR/AR) content is about to explode. Global demand for Mixed Realty (VR/AR) content is about to explode.
Global demand for Mixed Realty (VR/AR) content is about to explode.
 
VR, a new technology over 40,000 years old
VR, a new technology over 40,000 years oldVR, a new technology over 40,000 years old
VR, a new technology over 40,000 years old
 

Último

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Último (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Mastering the IoT With JavaScript and C++ - Günter Obiltschnig

  • 1. Mastering The IoT With JavaScript And C++ Günter Obiltschnig Applied Informatics Software Engineering GmbH guenter@appinf.com @obiltschnig, @macchina_io
  • 2. About Me hard-core C++ developer (20+ years), 
 who also likes JavaScript “full stack++”, embedded, hardware 
 to web frontend + cloud POCO C++ Libraries (2004) Applied Informatics GmbH (2006) my-devices.net (2010) AIS Radar for iOS (2011) macchina.io (2013)
  • 3. m .ioacchina |‘makkina| – A modular open source toolkit for building embedded IoT applications that connect sensors, devices 
 and cloud services.
  • 4. IoT Gateway devices.netCloud Services AirVantage, Amazon, 
 Bluemix, Carriots, etc. HTTP(S), REST MQTT Remote Access my-devices.net device apps local“business logic” web services web visualization database discoverability Mobile/Web Clients Devices/Sensor Networks CoAP, IEEE 802.15.4, Modbus, USB, Bluetooth LE, RS-232
  • 5. POCO
C++ LIBRARIES platform abstraction, multithreading, XML and JSON processing, filesystem access,
 stream, datagram and multicast sockets, HTTP server and client, crypto, SSL/TLS, etc. Remoting serialization, remote methods and events, IPC Open Service Platform dynamic module system service registry web application server user authentication/authorization Platform JavaScript V8 JavaScript engine and C++ bindings/bridging Devices and Sensors Sensors, Serial Port, GNSS/GPS, Accelerometer, I/O, … Protocols MQTT, CoAP, Modbus, Bluetooth LE, XBee, … Services WebEvent, DeviceStatus, NetworkEnvironment, … WebUI Login, Launcher, Bundles, Playground, etc. IoT Components
  • 6. > open source (Apache 2.0 License) > built in C++ for best performance and efficiency 
 (JavaScript for parts of web interface) > modular and extensible > mature, proven codebase: 
 POCO C++ Libraries, Google V8, Eclipse Paho, SQLite
 AngularJS, jQuery, OpenLayers, Ace (text editor),
 + Applied Informatics OSP and Remoting frameworks > C++-to-JavaScript bridge > Raspberry Pi, Beaglebone, Edison, RED, MangOH, etc. > prototype on Linux or OS X host, easily deploy to device > web interface with JavaScript editor
  • 7. Why JavaScript? > Popular and widely known* > Standardized > Easy to integrate into an existing framework > Multiple embeddable engines available > Good performance (for a scripting language) > I like it ;-) * but not necessarily universally liked
  • 8. Sensors & Devices Protocols Cloud Services Temperature, Ambient Light, 
 Humidity, Air Pressure, etc. HTTP, HTTPS AirVantage I/O, LED, Trigger, 
 Rotary Encoder MQTT Bluemix Accelerometer CoAP* Twitter GNSS/GPS WebEvent Amazon IoT Barcode Reader, RFID* WebTunnel Twilio (SMS) XBee (ZigBee, IEEE 802.15.4) XBee API my-devices.net TI SensorTag Bluetooth LE any with MQTT API Serial Port Modbus any with HTTP/REST API * planned
  • 9. Pro Users and Device Manufacturers > add device specific APIs > make devices programmable in JavaScript for partners or end users > device specific app store (sell additional software features) > additional frameworks (Shell, UPnP, Remoting SOAP and JSON-RPC) > customizable web user interface > improved user authentication and authorization > signed bundles > pro support
  • 10. Usage Examples > Building Automation > Vehicle Telematics/Connected Cars > Energy Manager
 (photovoltaics and battery controller) > Industrial Internet of Things Platform
  • 11. Demo
  • 13. POCO
C++ LIBRARIES platform abstraction, multithreading, XML and JSON processing, filesystem access,
 stream, datagram and multicast sockets, HTTP server and client, crypto, SSL/TLS, etc. Remoting serialization, remote methods and events, IPC Open Service Platform dynamic module system service registry web application server user authentication/authorization Platform JavaScript V8 JavaScript engine and C++ bindings/bridging Devices and Sensors Sensors, Serial Port, GNSS/GPS, Accelerometer, I/O, … Protocols MQTT, CoAP, Modbus, Bluetooth LE, XBee, … Services WebEvent, DeviceStatus, NetworkEnvironment, … WebUI Login, Launcher, Bundles, Playground, etc. IoT Components
  • 14. POCO C++ Libraries > Started 2004 > ~300.000 LOC > 1000+ classes > on GitHub since 2012 
 1730+ stars
 640+ forks
 40-200 clones/day > ~100 contributors > Boost License > http://pocoproject.org POSIX, WIN32, other (RT)OS API Foundation C++ and C Standard LibrariesApplication Zip Net Crypto Data SQLite ODBC MySQL NetSSL Util Tools, Utilities and additional Libraries XML JSON
  • 15. V8 > Google’s JavaScript Engine > Used by Chrome/Chromium and node.js > C++ library, (reasonably) easy to integrate and to extend > Compiles JavaScript to native code (x86, ARM, MIPS) > Great performance > BSD License
  • 16. Remoting > Similar to .NET Remoting or Java RMI, but for C++ > Code generator parses annotated C++ header files and generates code
 (serialization/deserialization, method dispatching, helpers) > Supports different transports (binary TCP, SOAP, JSON-RPC) > Used for automatic C++-to-JavaScript bridging > Will also be used to implement sandbox mechanism
  • 17. Open Service Platform (OSP) > Inspired by OSGi, but for C++ (also JavaScript, Python, etc.) > Dynamic module system based on bundles
 (Zip files with metadata, 
 shared libs, other files) > Dependency and 
 lifecycle management > Services and service registry > Web Server POCO Core Libraries (Foundation,XML,Util,Net) Operating System API Std.C/C++ Libraries Service Registry Portable Runtime Environment Life C ycle M anagem ent Bundle M anagem ent Standard Services Bundles install,resolve,start,stop and uninstall bundles provide services to other bundles and find services provided by other bundles manage bundle versions and dependencies web server, web- and console- based management, user authentication and authorization, preferences,etc. application-specific functionality and services
  • 18. Combining POCO C++ Libraries and V8 > JavaScript is single-threaded and garbage-collected > POCO is multithreaded (specifically web server) > Make C++ object available to JavaScript
 easy for static objects, just provide Wrapper > Allow JavaScript code to create C++ objects
 easy if you don’t care about memory/resource leaks > Register a callback function called by GC when object is deleted
 allows you to properly delete underlying c++ object > However, V8 does not do callbacks when script ends
 wrapped C++ objects won’t be deleted, leaks resulting > Need to track every C++ object a script creates and clean up afterwards :-(
  • 20. // Sensor.h //@ remote class Sensor: public Device { public: Poco::BasicEvent<const double> valueChanged; virtual double value() const = 0; virtual bool ready() const = 0; };
  • 21. Sensor.h RemoteGen lots of generated source files RemoteGen.xml
  • 22. Service <<generatedFrom>> IService ServiceProxy Service RemoteObject The interface class has all @remote methods from the service class. Service Skeleton <<invokes>> <<generated>> <<generated>><<generated>> <<generated>> Service ServerHelper <<generated>> Registers Skeleton, RemoteObject and EventDispatcher (if needed) with the Object Request Broker. Service ProxyFactory <<creates>> <<generated>> Service ClientHelper <<generated>> Registers ProxyFactory with the Object Request Broker. <<registers>><<registers>> <<registers>> Service EventSubscriber <<generated>> Service EventDispatcher <<generated>> <<registers>>
  • 23. var tempSensor = ...; tempSensor.on(‘valueChanged', function(ev) { var temp = ev.data; // ... }); if (tempSensor.ready()) { var temp = tempSensor.value(); // ... }
  • 25. // sensors.js (search sensors by physical quantity) var sensors = {}; var illuminanceRefs = serviceRegistry.find( 'io.macchina.physicalQuantity == "illuminance"'); if (illuminanceRefs.length > 0) { sensors.illuminance = illuminanceRefs[0].instance(); } var temperatureRefs = serviceRegistry.find( 'io.macchina.physicalQuantity == "temperature"'); if (temperatureRefs.length > 0) { sensors.temperature = temperatureRefs[0].instance(); } var humidityRefs = serviceRegistry.find( 'io.macchina.physicalQuantity == "humidity"'); if (humidityRefs.length > 0) { sensors.humidity = humidityRefs[0].instance(); } module.exports = sensors;
  • 26. // sensors.js (search sensors by ID) var sensors = {}; var illuminanceRef = serviceRegistry.findByName( 'io.macchina.xbee.sensor.illuminance#0013A20040A4D7F7'); if (illuminanceRef) { sensors.illuminance = illuminanceRef.instance(); } var temperatureRef = serviceRegistry.findByName( 'io.macchina.xbee.sensor.temperature#0013A20040A4D7F7'); if (temperatureRef) { sensors.temperature = temperatureRef.instance(); } var humidityRef = serviceRegistry.findByName( 'io.macchina.xbee.sensor.humidity#0013A20040A4D7F7'); if (humidityRef) { sensors.humidity = humidityRef.instance(); } module.exports = sensors;
  • 27. // database.js var data = require('data'); module.exports = { path: bundle.persistentDirectory + 'logger.db', session: new data.Session('SQLite', database.path), logIntervalSeconds: application.config.getInt( 'datalogger.intervalSeconds', 30), keepDataSeconds: application.config.getInt( 'datalogger.keepDataSeconds', 3600) };
  • 28. // logger.js var sensors = require('sensors'); var db = require('database'); db.session.execute('PRAGMA journal_mode=WAL'); db.session.execute('CREATE TABLE IF NOT EXISTS datalog ( timestamp INTEGER, illuminance FLOAT, temperature FLOAT, humidity FLOAT )'); setInterval( function() { db.session.execute('INSERT INTO datalog VALUES (?, ?, ?, ?)', DateTime().epoch, sensors.illuminance.value(), sensors.temperature.value(), sensors.humidity.value()); }, db.logIntervalSeconds*1000);
  • 29. // logger.js (continued) setInterval( function() { var cutoffTime = DateTime().epoch - db.keepDataSeconds; db.session.execute('DELETE FROM datalog WHERE timestamp < ?', cutoffTime); }, db.keepDataSeconds*1000);
  • 30. // history.jss - GET /history.jss?item=temperature&maxItems=10 var db = require('database'); var validItems = ['temperature', 'humidity', 'illuminance']; var data = []; db.session.pageSize = form.maxItems ? parseInt(form.maxItems) : 20; var item = form.item; if (validItems.indexOf(item) > -1) { var recordSet = db.session.execute( 'SELECT timestamp, ' + item + ' FROM datalog ORDER BY timestamp DESC');
  • 31. // history.jss (continued) for (var row = 0; row < recordSet.rowCount; row++) { var time = recordSet.getValue('timestamp'); var value = recordSet.getValue(item); var date = new LocalDateTime(1970, 1, 1); date.addSeconds(time); data[recordSet.rowCount - row - 1] = { timestamp: date.format('%H:%M:%S'), value: value }; recordSet.moveNext(); } recordSet.close(); } response.contentType = 'application/json'; response.write(JSON.stringify(data)); response.send();
  • 32. // MQTT to AirVantage var sensors = require('sensors'); var mqttClientRefs = serviceRegistry.find('io.macchina.mqtt.id == "airvantage"'); if (mqttClientRefs.length > 0) { console.log('MQTT Client found'); var mqttClient = mqttClientRefs[0].instance(); setInterval(function() { var epoch = "" + 1000*DateTime().epoch; // seconds to milliseconds var payload = {}; payload[epoch] = { "sensors.temperature": sensors.temperature.value(), "sensors.humidity": sensors.humidity.value() "sensors.illuminance": sensors.illuminance.value() }; mqttClient.publish('JA347400060803/messages/json', 
 JSON.stringify(payload), 0); }, 10000);
  • 33. // twilio.js var net = require('net'); module.exports = { sendSMS: function(to, message) { var accountSID = application.config.getString("twilio.accountSID"); var authToken = application.config.getString("twilio.authToken"); var from = application.config.getString("twilio.from"); var twilioHttpRequest = new net.HTTPRequest( "POST", "https://api.twilio.com/2010-04-01/Accounts/" + accountSID + "/SMS/Messages" ); twilioHttpRequest.authenticate(accountSID, authToken); twilioHttpRequest.contentType = "application/x-www-form-urlencoded"; twilioHttpRequest.content = "From=" + encodeURIComponent(from) + "&To=" + encodeURIComponent(to) + "&Body=" + encodeURIComponent(message); twilioHttpRequest.send(function(result) { console.log("Twilio SMS Response: %O", result); }); };
  • 34. var sensors = require('sensors'); var twilio = require('twilio'); var enableSMS = true; sensors.illuminance.on('valueChanged', function(ev) { logger.notice("valueChanged: " + ev.data); if (ev.data < 10) { logger.warning("Lights out!"); if (enableSMS) { twilio.sendSMS("+4367612345678", "Lights out!"); enableSMS = false; } } else if (ev.data > 50) { enableSMS = true; } });
  • 35. Q&A
  • 36. guenter@appinf.com | @obiltschnig | obiltschnig.com macchina.io | my-devices.net | pocoproject.org | www.appinf.com