March 2012 - Business Confidential - Bitreactive AS
Frank Alexander Kraemer, Ph.D.
Bitreactive AS, Trondheim
@fralkr
Developing Robust IoT Gateway Applications from Building Blocks
HIPEAC CSW & BR Oslo, May 4-8, 2015
Internet of Things (IoT): Technology and Applications for a Good Society
March 2012 - Business Confidential - Bitreactive AS
Summary
Gateways are essential components in IoT systems. Apart from providing network access to the leaf nodes, they can also run applications. This is important to reduce response time, network traffic, keep sensitive data within local boundaries and keep the system up even if the network is down. Home gateways, industrial field agents, on board units and roadside stations are examples for gateways.
Application development for such gateways is hard. Since gateways tie together hardware and network resources, developers need a broad set of skills to begin with. Development is further complicated since applications must work autonomously, managed remotely and handle the incoming streams of events. To solve these challenges, we have developed Reactive Blocks, a tool to create applications from building blocks. Blocks can encapsulate protocols, hardware access and application patterns. This leads to increased reuse, enables automatic code generation and automated checking of designs.
March 2012 - Business Confidential - Bitreactive AS
Frank Alexander Frank Alexander Kraemer studied Electrical Engineering and Information Technology at the University of Stuttgart, Germany, and received his Ph.D. from the Norwegian University of Science and Technology (NTNU) in 2008. Frank has experience with the development of software tools, initiated by an internship at IBM, Germany, where he helped integrating tools into the Eclipse platform. During the research for his Ph.D. thesis, he developed an engineering method for the design of reactive systems at the Department for Telematics, NTNU. The results of this research are usable with the Reactive Blocks tool, which is currently applied to a number of industrial projects. Frank is co-founder of Bitreactive AS, which helps other companies to deliver new applications built with Reactive Blocks.
Title - edit manually in the normal master 4
A selection of gateways. All of them can run Linux and a
Java VM.
Title - edit manually in the normal master 5
Examples for use cases of application
gateways.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
A smart parking house that shows you where the last free spots are.
Gateway
Things
Cloud
BLE ZigBee Thread6LowPANMQTTCoAP
IPv6
MQTT HTTP CoAP AMQP …
A current basis architecture for IoT
systems, consisting of cloud, gateways and
the connected things.
IoT Application Gateways- roadside stations - onboard units - residential gateways - field agents
Gateway
Things
Cloud
Hardware
Operating System
JVM
A 1 A 2 A 3
Applications
Gateways can execute IoT applications. This can reduce latency,
reduce bandwidth, and keep data secure.
Gateway
Things
Cloud
Hardware
Operating System
JVM
A 2 A 3
Applications
A 1
life cycle
services
config changes
messages
network
hardware signalshardware changes
The challenge is that each application needs
to handle lots of events. And
concurrent, event-drivem programming
is difficult.
Title - edit manually in the normal master 11
That’s how a program looks like when we just
start coding, and concurrency is not handled correctly.
Title - edit manually in the normal master
two types of spaghetti
■ Spaghetti code ■ GOTO is not the problem, but unstructured programming is
■ lots of blocking code, because of communnication to network and interaction with HW, also events and interrupts. —> start with concurrent programming
■ Spaghetti threads ■ in concurrent programming, threads can build spaghetti as well ■ you really give up to understand it
12
You may think “Ahh, spaghetti code!”. But
it’s even worse. There’s two types of spaghetti. You also deal with spaghetti
threads.
So this is how it usually turn out with naïve
programming. Easy in the beginning, hard in
the end.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
Let’s instead solve this problem by cleaning up
the mess, and put everything into boxes, a.k.a. building blocks.
CoAP Resource
ok
getResponse
init
failed
get
post
Config Listener
initConfig
start
updatedConfig
Kura CloudClient
readypublish
start
stop
waiting
stopped
failed
msgArrived
MQTT Core
initOksubscribe
init
initFailed
publishOk
message
error
stopped
disconnected
unsubscribe
publish
stopRPi GPIO Digital In
valuestop
init
initError
initOk
isLow
isHigh
stopped
read
initPS
Config Listener
initConfig
start
updatedConfig
playing
Modbus
initOkexecutedReadIn
init
initFailed
readDone
writeDone
readFailed
stopped
writeFailed
deviceId
executedWrite
stop
executeReadHold
registerId
1 2 3Config Listener
initConfig
start
updatedConfig
Reactive Blocks
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
public void ledOn() {logInfo("Switching on LED");leds[0].setState(true);
}
public void ledOff() {logInfo("Switching off LED");leds[0].setState(false);
}
In Reactive Blocks, Java methods are the
smallest units of behavior. Here two
simple ones that turn an LED on and off.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
To let the LED blink, we just add a timer in between.
When an operation is called is determined graphically.
Its contents is still programmed.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
We can wrap that blink into a building block. (This is a very
simple block, there can be much more complex ones!)
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
We can add some logic to let the LED blink periodically.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
And also wrap that periodic timer as a new building
block.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
And the combination of these two blocks can in turn be a
building block.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
OSGi
Applications consist of a nice hierarchy of blocks, many of
them reused.
There are many libraries with blocks for typical IoT
functions.
Interfaces✔ Names✔ Types✘ Sequences✘ Timing Traditional interfaces cover
method names and types, but do not help us with
timing and sequences of methods.
INHOLD Corporate Identity Manual 7
X
X X
X/2
X/2
LOGO SCALE GUIDELINES
The logo must be surrounded with adequate clear space to ensuremaximum prominence and visual impact.
All scaling of the logo is to be proportional.
In case the logo needs to appear on a limited background, the minimum size allowed is not less than 15 mm.
min 15 mm
LOGO
Therefore, a reactive block has a contract, that
describes in which sequence we can use its pins. Here a
very simple example.
Model CheckingAutomatic
This enables a mathematical analysis called “model
checking”. And in Reactive Blocks, it works
automatically, without any extra effort.
Here the analysis finds if we abort a termination
sequence and hence do not reach the final state. Very
useful.
Reactive Blocks
bitreactive.com