an introduction to eclipse kura - eclipse day florence 2014
DESCRIPTION
Deploying and configuring one device to act as a node in the Internet of Things is relatively easy. Doing the same for hundreds or thousands of devices is not so easy though. This is where the new Eclipse project Kura comes in. Kura is a Java/OSGi-based container for M2M applications running in service gateways. Kura was contributed to Eclipse by Eurotech who developed the original technology to run on everything from general purpose devices, rugged mobile computers, wearable devices, service gateways and vehicle consoles, all the way down to the Raspberry Pi.TRANSCRIPT
Eclipse Kura: an Introduction
Cristiano De Alti, EUROTECH
Eclipse Day Florence
23 May 2014
Eclipse IoT
Applying open source to end-to-end IoT solutions
Kura Project – Java/OSGi-based container for M2M applications
running in service gateways
– http://projects.eclipse.org/projects/technology.kura
– Kura code available since March 2014
– 12 committers
– Open source version of the Everyware Software
Framework (ESF)
– Most of the ESF codebase contributed to Kura. Some
parts waiting for IP approval
OSGi
on
IoT Gateway Software Stack
Linux
Hardware
Application
Java VM
Application
• Built-in OSGi Services for IoT Apps
• High-level Programming Language
• Software Modularity
• Configuration Management
• Application Management
• Shorter Time-to-Market
• Device Abstraction
• Application Portability
• Investment Protection
• Integrated Device Cloud features
Application
Functional Overview
Java VM
OSGi Application Container
Device Abstraction
Gateway Basic Services
Network Configuration Network Management Field
Protocols
Connectivity and Delivery
Ad
min
istra
tion
GU
I
Op
era
tion
& M
an
ag
em
en
t
Linux
Hardware
Multi-
Service
Gateway
App 1 App 2 App n . . . .
Applications
on
Java VM
OSGi Application Container
Field
Protocols
Connectivity and
Delivery
Ad
min
istra
tion
GU
I
Applications
Op
era
tion
& M
an
ag
em
en
t
Gateway Basic Services
Network
Configuration Network Management
Device Abstraction
Device Abstraction
USB
javax.usb
Other GPIO I2C
Ready to use OSGi bundles
exposing Java APIs for device
access and with the native code
dependencies pre-compiled.
Serial
javax.comm Bluetooth
javax.bluetooth Device Abstraction
Gateway Basic Services
on
Java VM
OSGi Application Container
Field
Protocols
Connectivity and
Delivery
Ad
min
istra
tion
GU
I
Applications
Op
era
tion
& M
an
ag
em
en
t
Network
Configuration Network Management
Device Abstraction
Gateway Basic Services
Gateway Basic Services
Watchdog
Service
Clock
Service
GPS Position
Service
Embedded
Database
Service
Process
Service
Device Profile
Service
Configurable OSGi Services
available to the applications to
interact with the basic gateway
functionality.
Configuration Service
Network Management
Network Management
Link Monitor
Ethernet
on
Java VM
OSGi Application Container
Field
Protocols
Connectivity and
Delivery
Ad
min
istra
tion
GU
I
Applications
Op
era
tion
& M
an
ag
em
en
t
Gateway Basic Services
Device Abstraction
Network
Configuration Network Management
WiFi Cellular
DHCP NAT DNS
Firewall
Configurable OSGi Services to
access the current network
configuration and administer it.
It interacts with the Linux system to
configure network interfaces
including WiFi access points and
PPP connections.
Connectivity and Delivery
on
Java VM
OSGi Application Container
Field
Protocols
Ad
min
istra
tion
GU
I
Applications
Op
era
tion
& M
an
ag
em
en
t Gateway Basic Services
Network
Configuration Network Configuration
Device Abstraction
Connectivity and
Delivery
Connectivity & Delivery
Eclipse Paho (MQTT) Other Client
Data Transport
Data Service
Cloud Service
Configurable OSGi Services which
greatly simplify the development of
telemetry M2M applications
interacting with a remote Cloud
server.
Operation & Management
on
Java VM
OSGi Application Container
Field
Protocols
Connectivity and
Delivery
Ad
min
istra
tion
GU
I
Applications
Gateway Basic Services
Network
Configuration Network Configuration
Device Abstraction
Op
era
tion
& M
an
ag
em
en
t
Remote System Command
Remote Configuration Management
Operation & Management
Remote Software Updates
Remote Log Retrieval
Device Diagnostic Service
Remote VPN Access
Administration UI
Developer’s Experience
Greenhouse Demo Architecture
Mqtt
Broker
Web
Application
MQTT
Mosquitto
HTTP
Light
Modbus
Greenhouse Demo
MQTT Topics and Payloads
greenhouse/
sensors
• Timestamp
• Metrics:
• request ID
• Timestamp
• Metrics:
• temperature
• humidity
• luminosity
• open
Kura Payload Kura Payload
EXEC/window/open
EXEC/window/close
REPLY/<request ID>
• Timestamp
• Metrics:
• Reply code
Kura Payload
Greenhouse Demo
Anatomy of a Kura Cloud Application
public class GreenHouse extends Cloudlet implements
ConfigurableComponent
Greenhouse Demo
Anatomy of a Kura Cloud Application (Metatype)
A ConfigurableComponent has a metatype...
<?xml version="1.0" encoding="UTF-8"?>
<MetaData xmlns="http://www.osgi.org/xmlns/metatype/v1.2.0" localization="en_us">
<OCD id="org.eclipse.kura.demo.greenhouse.v2.GreenHouse"
name="GreenHouse"
description="Greenhouse example application.">
<AD id="modbus.serialMode"
name="modbus.serialMode"
type="String"
cardinality="0"
required="true"
default="RS232"
description="Serial Mode (RS232 or RS485), or TCP for TCP-encapsulated Modbus.">
<Option label="RS-232" value="RS232"/>
<Option label="RS-485" value="RS485"/>
<Option label="TCP" value="ETHERTCP"/>
</AD>
...
...describing its configuration
Greenhouse Demo
Anatomy of a Kura Cloud Application (Configuration)
Metatype is used to display the configuration dinamically
Greenhouse Demo
Anatomy of a Kura Cloud Application (Configuration)
Configuration received in DS activate/updated methods
protected void activate(ComponentContext componentContext,
Map<String, Object> properties)
protected void updated(Map<String, Object> properties)
Greenhouse Demo
Anatomy of a Kura Cloud Application (Publishing)
public void setCloudService(CloudService cloudService) {
m_cloudService = cloudService;
}
protected void activate(ComponentContext componentContext, Map<String, Object> properties) {
...
// Acquire a Cloud Application Client for this Application
m_cloudClient = m_cloudService.newCloudClient("greenhouse");
m_cloudClient.addCloudClientListener(this);
...
}
protected void doPublish() {
...
KuraPayload kuraPayload = new KuraPayload();
kuraPayload.addMetric("temperature", temperature);
kuraPayload.addMetric("luminosity", luminosity);
kuraPayload.addMetric("humidity", humidity);
kuraPayload.addMetric("open", open);
m_cloudClient.publish("sensors", kuraPayload, DFLT_QOS, DFLT_RETAIN,DFLT_PRIORITY);
...
}
Greenhouse Demo
Anatomy of a Kura Cloud Application (Requests) public class GreenHouse extends Cloudlet implements ConfigurableComponent
public GreenHouse()
{
super("greenhouse");
}
@Override
protected void doExec(CloudletTopic reqTopic,
KuraRequestPayload reqPayload,
KuraResponsePayload respPayload) throws KuraException {
String[] resources = reqTopic.getResources();
if (resources == null || resources.length < 2 || !resources[0].equals("window")) {
respPayload.setResponseCode(KuraResponsePayload.RESPONSE_CODE_NOTFOUND);
return;
}
boolean open = false;
if (!((open = resources[1].equals("open")) || resources[1].equals("close"))) {
respPayload.setResponseCode(KuraResponsePayload.RESPONSE_CODE_NOTFOUND);
return;
}
...
}
Where to start?
www.eurotech.com
Thank You!