end-to-end iot solutions with java and eclipse iot

49
Benjamin Cabé Eclipse Foundation End-to-end IoT solutions with Java and Eclipse IoT

Upload: benjamin-cabe

Post on 15-Jan-2015

1.169 views

Category:

Technology


6 download

DESCRIPTION

The IoT market is poised to an exponential growth, but there are still lots of barriers that prevent building a real, open, Internet of Things. Over the last years, Eclipse has been growing an ecosystem of open-source projects for IoT, that are used in real-world solutions, from smart gateways bridging sensors to the cloud, to device management infrastructures or home automation systems. Java is a key-enabler for IoT, and this presentation provides you with concrete examples on how to build end-to-end solutions with the Eclipse IoT Java stack and projects like Paho, Kura, SmartHome, Californium, OM2M, Eclipse SCADA, Concierge ... This session will give you the keys to build a scalable IoT solution on top of open-source technology and open standards.

TRANSCRIPT

Page 1: End-to-end IoT solutions with Java and Eclipse IoT

Benjamin Cabé Eclipse Foundation

End-to-end IoT solutions with Java and Eclipse IoT

Page 2: End-to-end IoT solutions with Java and Eclipse IoT

Java for IoT? 9+ million Java developers

Java 8 & embedded are fun

Lots of IoT devices running on ARM

Tooling

Page 3: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse IoT A vivid open-source community

13* projects across the whole IoT chain

* and counting...

Page 4: End-to-end IoT solutions with Java and Eclipse IoT

Your typical IoT solution

Actuators/Sensors +

Gateway +

[ Cloud ] +

User front-end

Page 5: End-to-end IoT solutions with Java and Eclipse IoT
Page 6: End-to-end IoT solutions with Java and Eclipse IoT
Page 7: End-to-end IoT solutions with Java and Eclipse IoT

IOT

Page 8: End-to-end IoT solutions with Java and Eclipse IoT
Page 9: End-to-end IoT solutions with Java and Eclipse IoT

IOT

Page 10: End-to-end IoT solutions with Java and Eclipse IoT

1. Sensors / Actuators •  Sense the physical environment

•  Act on it

Page 11: End-to-end IoT solutions with Java and Eclipse IoT

1. Sensors / Actuators •  Sense the physical environment

•  Act on it

Well… that was easy!

Page 12: End-to-end IoT solutions with Java and Eclipse IoT

1. Sensors / Actuators •  Manipulate sysfs directly with the File API

•  Use Pi4J (hint: ♥︎) to have full support of GPIO/I2C/SPI

•  Use MIDlets with Java ME embedded

Page 13: End-to-end IoT solutions with Java and Eclipse IoT

1. Sensors / Actuators •  Manipulate sysfs directly with the File API

•  Use Pi4J (hint: ♥︎) to have full support of GPIO/I2C/SPI

•  Use MIDlets with Java ME embedded

Page 14: End-to-end IoT solutions with Java and Eclipse IoT

Pi4J – http://pi4j.com •  Complete access to GPIOs/I2C/SPI

•  Very mature codebase, based on WiringPi

•  Support for popular shields (PiFace, Gertboard, …)

•  Lots of code samples

Page 15: End-to-end IoT solutions with Java and Eclipse IoT

Pi4J in action GpioController gpio = GpioFactory.getInstance(); GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(

RaspiPin.GPIO_01, "MyLED", PinState.HIGH); Thread.sleep(5000); pin.low(); Thread.sleep(5000); pin.toggle(); gpio.shutdown();

Page 16: End-to-end IoT solutions with Java and Eclipse IoT

2. Gateway

Network by Nicholas Menghini from The Noun Project

Page 17: End-to-end IoT solutions with Java and Eclipse IoT

2. Gateway

Network by Nicholas Menghini from The Noun Project

Connect sensors to the world

Page 18: End-to-end IoT solutions with Java and Eclipse IoT

2. Gateway

Network by Nicholas Menghini from The Noun Project

Connect sensors to the world

Manage the hardware and software running

at the edge

Page 19: End-to-end IoT solutions with Java and Eclipse IoT

Connect? CoAP?

–  « HTTP over UDP » –  Expose your device as a resource to the Internet

of Things MQTT?

– Publish/Subscribe model – More room for local processing

Page 20: End-to-end IoT solutions with Java and Eclipse IoT

CoAP with Californium CoapServer, CoapResource, CoapExchange

1.  Implement custom resources (extend CoapResource)

2.  Add resources to the CoAP server

3.  Start the server

Page 21: End-to-end IoT solutions with Java and Eclipse IoT

CoAP with Californium import static org.eclipse.californium.core.coap.CoAP.ResponseCode.*; // shortcuts public class MyResource extends CoapResource { @Override public void handleGET(CoapExchange exchange) { exchange.respond("hello world"); // reply with 2.05 payload (text/plain) } @Override public void handlePOST(CoapExchange exchange) { exchange.accept(); // make it a separate response if (exchange.getRequestOptions() ...) { // do something specific to the request options } exchange.respond(CREATED); // reply with response code only (shortcut) } }

Page 22: End-to-end IoT solutions with Java and Eclipse IoT

MQTT with Paho MqttClient c = new MqttClient("tcp://m2m.eclipse.org:1883",

MqttClient.generateClientId()); mqttClient.setCallback(new MqttCallback() {

@Override public void messageArrived(String topic, MqttMessage message) throws Exception { // process received message // ... }

}); mqttClient.connect(); mqttClient.subscribe("mygateway/#");

Read more: https://www.eclipse.org/paho/clients/java/

Page 23: End-to-end IoT solutions with Java and Eclipse IoT

Manage? •  Gateway itself

– wireless modem, firewall, … •  Applications

–  Install/Uninstall software packages – Start/Stop applications

•  Sensors – H/W abstraction layer

Page 24: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Java VM

OSGi Application Container

Device Abstraction

Gateway Basic Services

Network Configuration Network Management Field

Protocols

Connectivity and Delivery

Adm

inis

trat

ion

GU

I

Ope

ratio

n &

Man

agem

ent

Linux

Hardware

App 1 App 2 App n . . . .

Applications

Page 25: End-to-end IoT solutions with Java and Eclipse IoT

OSGi with Concierge OSGi?

– A dynamic component system for Java – Many standard services

•  Eventing, configuration management, UPnP, … – A target of choice for modular IoT software

Eclipse Concierge provides low footprint implementation (~300-400kb JAR files)

http://eclipse.org/concierge

Page 26: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 27: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 28: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 29: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 30: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 31: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 32: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 33: End-to-end IoT solutions with Java and Eclipse IoT

Eclipse Kura

Page 34: End-to-end IoT solutions with Java and Eclipse IoT

Your typical Kura component •  Uses Modbus, CAN-Bus, etc. built-in device

abstraction services – Or implement your own service

Page 35: End-to-end IoT solutions with Java and Eclipse IoT

Your typical Kura component (2) •  Uses Kura built-in transport services to talk

to the cloud –  TransportService – « raw » protocol –  DataService – local storage, auto reconnect –  CloudService – optimized binary payload,

advanced device management

Page 36: End-to-end IoT solutions with Java and Eclipse IoT

Your typical Kura component (3) •  Implements ConfigurableComponent

–  Enables configuration from the UI – … as well as from the cloud

Page 37: End-to-end IoT solutions with Java and Eclipse IoT

Your typical Kura component (4) •  Bundled with other bundles/components in

a deployment package –  Zip file containing a Manifest & OSGi bundles

•  Can be deployed from Kura Web UI or over the air

Read more: https://wiki.eclipse.org/Kura/Getting_Started

Page 38: End-to-end IoT solutions with Java and Eclipse IoT

3. Cloud backend •  Allow virtual point-to-point communication

between the IoT devices

•  Provide device management capabilities to manage fleets of devices on the field

Page 39: End-to-end IoT solutions with Java and Eclipse IoT

MQTT broker with Moquette •  Supports QoS 0, 1 and 2

•  Aligned with latest MQTT 3.1.1 specification

•  Ready to be deployed in OSGi containers

•  WebSockets

•  Leverages LMAX Disruptor buffer

Page 40: End-to-end IoT solutions with Java and Eclipse IoT

MQTT broker with Moquette https://code.google.com/p/moquette-mqtt/

Very simple to install: tar zxf distribution-0.6-bundle-tar.tar.gz cd bin ./moquette.sh

Note: Moquette has been recently proposed as an Eclipse IoT project

Page 41: End-to-end IoT solutions with Java and Eclipse IoT

4. End-user interaction Mobile

Web

Other IoT gadgets: wearables, …

Page 42: End-to-end IoT solutions with Java and Eclipse IoT

Android Developing for IoT on Android is dead simple

– MQTT Android service https://www.eclipse.org/paho/clients/android

– Android Wear: you can easily bridge Google Play’s DataLayer to MQTT

Page 43: End-to-end IoT solutions with Java and Eclipse IoT

Web MQTT over Websockets enables direct MQTT communication from noBackend web-apps

–  https://www.eclipse.org/paho/clients/js/

Eclipse Ponte is also a good way to bridge MQTT or CoAP to HTTP

–  https://eclipse.org/ponte

Page 44: End-to-end IoT solutions with Java and Eclipse IoT

Tooling •  Java support in the Eclipse IDE from day 1

•  Remote debug

•  Java 8 (lambdas, …)

•  OSGi

– PDE (Plug-in Development Environment) – Remote OSGi with mToolkit

Page 45: End-to-end IoT solutions with Java and Eclipse IoT

Moaaar Eclipse IoT and Java!

Page 46: End-to-end IoT solutions with Java and Eclipse IoT

See you soon!

Page 47: End-to-end IoT solutions with Java and Eclipse IoT

See you soon!

http://www.meetup.com/Virtual-IoT

Page 48: End-to-end IoT solutions with Java and Eclipse IoT

Thanks! <[email protected]>

@kartben

http://iot.eclipse.org

Page 49: End-to-end IoT solutions with Java and Eclipse IoT

Show me the code!

JVM

OSGi runtime

Kura

DataTransportService

DataService

Cloud Service

Adm

inis

trat

ion

GU

I