end-to-end iot solutions with java and eclipse iot
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
Benjamin Cabé Eclipse Foundation
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
Eclipse IoT A vivid open-source community
13* projects across the whole IoT chain
* and counting...
Your typical IoT solution
Actuators/Sensors +
Gateway +
[ Cloud ] +
User front-end
IOT
IOT
1. Sensors / Actuators • Sense the physical environment
• Act on it
1. Sensors / Actuators • Sense the physical environment
• Act on it
Well… that was easy!
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
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
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
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();
2. Gateway
Network by Nicholas Menghini from The Noun Project
2. Gateway
Network by Nicholas Menghini from The Noun Project
Connect sensors to the world
2. Gateway
Network by Nicholas Menghini from The Noun Project
Connect sensors to the world
Manage the hardware and software running
at the edge
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
CoAP with Californium CoapServer, CoapResource, CoapExchange
1. Implement custom resources (extend CoapResource)
2. Add resources to the CoAP server
3. Start the server
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) } }
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/
Manage? • Gateway itself
– wireless modem, firewall, … • Applications
– Install/Uninstall software packages – Start/Stop applications
• Sensors – H/W abstraction layer
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
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
Eclipse Kura
Eclipse Kura
Eclipse Kura
Eclipse Kura
Eclipse Kura
Eclipse Kura
Eclipse Kura
Eclipse Kura
Your typical Kura component • Uses Modbus, CAN-Bus, etc. built-in device
abstraction services – Or implement your own service
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
Your typical Kura component (3) • Implements ConfigurableComponent
– Enables configuration from the UI – … as well as from the cloud
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
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
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
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
4. End-user interaction Mobile
Web
Other IoT gadgets: wearables, …
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
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
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
Moaaar Eclipse IoT and Java!
See you soon!
See you soon!
http://www.meetup.com/Virtual-IoT
Show me the code!
JVM
OSGi runtime
Kura
DataTransportService
DataService
Cloud Service
Adm
inis
trat
ion
GU
I