This document discusses using Java and the Eclipse IoT project for end-to-end IoT solutions. It describes how Java can be used for sensors/actuators, gateways to connect devices to networks, and cloud backends for device management. It also outlines how the Eclipse IoT projects like Kura, Paho, Californium, and Moquette can be used at each level of a typical IoT solution.
10. 1. Sensors / Actuators
• Sense the physical environment
• Act on it
11. 1. Sensors / Actuators
• Sense the physical environment
• Act on it
Well… that was easy!
12. 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
13. 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
14. 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
17. 2. Gateway
Connect
sensors to the world
Network by Nicholas Menghini from The Noun Project
18. 2. Gateway
Connect
sensors to the world
Network by Nicholas Menghini from The Noun Project
Manage the hardware
and software running
at the edge
19. 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
20. CoAP with Californium
CoapServer, CoapResource, CoapExchange
1. Implement custom resources
(extend CoapResource)
2. Add resources to the CoAP server
3. Start the server
21. 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)
}
}
22. 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/
24. Eclipse Kura
Applications
App 1 App 2 . . . . App n
Network Configuration
Network Management Field
Gateway Basic Services
Device Abstraction
OSGi Application Container
Java VM
Protocols
Connectivity and Delivery
Administration GUI
Operation & Management
Linux
Hardware
25. 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
34. Your typical Kura component
• Uses Modbus, CAN-Bus, etc. built-in device
abstraction services
– Or implement your own service
35. 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
36. Your typical Kura component (3)
• Implements ConfigurableComponent
– Enables configuration from the UI
– … as well as from the cloud
37. 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
38. 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
39. 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
40. 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
42. 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
43. 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
44. 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