AlbaniaDreamin24 - How to easily use an API with Flows
M2M Protocol Interoperability Using IoT Toolkit
1. M2M
Protocol
Interoperability
MQTT
CoAP
HTTP
REST
Bridge
Using
IoT
Toolkit
and
the
Smart
Object
API
Michael
J
Koster
michaeljohnkoster@gmail.com
2. IoT
Toolkit
Goals
• Interoperability
–
Any
ApplicaJon,
any
connected
object,
using
any
M2M
protocol
• Simple
API
arJculated
through
data
models
and
high
level
informaJon
models
• PlaOorm-‐as-‐a-‐Service
and
gateway
enabled
• Open
Source,
IPR-‐free
• Distributed,
event-‐driven
applicaJon
soSware
runs
anywhere
in
the
network
• Web
standard
protocols
and
best
pracJces
3. API
IoT
1.0
–
Things
Connected
to
Apps
M2M
CoAP
M2M
MQ
M2M
XMPP
M2M
HTTP
App
API
App
API
App
API
App
• App
runs
on
single
service
–
Single
Points
Of
Failure
• Each
app
wriYen
to
a
custom
API
• Diverse
M2M
is
someJmes
required
but
can
inhibit
interoperability
• SoSware,
User
data,
and
Things
are
trapped
in
Silos
• Difficult
to
connect
new
types
of
things
and
deploy
new
plaOorms
• Very
difficult
to
share
resources
or
connect
across
plaOorms
• Apps
are
not
network-‐
effect
enabled
Connected
Things,
Sensors,
Actuators,
Data
Sources
4. IoT
2.0
–
Interoperability
M2M
CoAP
M2M
MQTT
M2M
XMPP
M2M
HTTP
Smart
Object
API
IoT
Toolkit
Discovery
ApplicaJons
Data
Models
• Object
Model
• REST
+
Event
Model
• M2M
Abstrac9ons
IoT
Toolkit
Connected
Things,
Sensors,
Actuators,
Data
Sources
Model
Database
• Easy
to
deploy
new
things
and
applicaJons
using
data
models
• Write
once,
run
anywhere
soSware
• Any
app
to
any
thing
via
any
M2M,
use-‐
case
appropriate
M2M
• Network
effect
enabled
Machine
Models
5. Graph-‐Structured,
Event-‐Driven,
Real
Time
Distributed
ApplicaJons
SO
SO
SO
Gateways
Server
Cloud
Endpoints
• Sensors
• Devices
ApplicaJon
Components
And
Resources
Databases
Registry
-‐
Instances
Repository
-‐
Models
Models
• Discovery
• Persistence
• ReplicaJon
• Resource
Access
• Data
Models
• Sensor
Models
• Machine
Models
• Templates
HTTP
MQTT
CoAP
XMPP
HTTP
CoAP
MQTT
Smart
Objects
6. What
Is
The
Smart
Object
API?
• Virtual
RepresentaJon
of
a
physical
Smart
Object
• Object
Model
–
Web
Object
EncapsulaJon
of
properJes
• REST
API
using
JSON,
XML,
RDF,
core-‐link-‐format
representaJons
• Data
Models
–
Linked
Data
descripJons,
Resource
Discovery
and
Linkage
• Event
Model
–
Asynchronous
M2M
and
applicaJon
soSware
event
handlers
7. Object
Model
Web
Object
EncapsulaJon
Smart
Object
Web
protocol
interfaces,
also
M2M
e.g.
MQTT,
XMPP,
…
Event
Model
Links
data
with
acJons
Pub-‐Sub
and
event
handlers
Encapsulates
local
soSware
components
and
handlers
Self-‐describing
data
model
For
Resource
Discovery
and
Linkage,
RDF
and
core-‐
link-‐format
Sensor
or
other
data
JSON,
XML,
data
feeds
8. API
–
DescripJon
(Data
Model)
• Contains
graphs
describing
the
resource
data
model
• RDF
triples
in
many
popular
representaJons
– create
(POST)
loads
a
graph
into
the
descripJon
delete
(DELETE)
removes
a
graph
or
subgraph
from
the
descripJon
– set
(PUT)
updates
a
graph
or
subgraph
– get
(GET)
returns
a
graph
or
subgraph
• SemanJc
Proxy
for
core-‐link-‐format
compaJbility
9. API
–
Observable
Property
• Represents
sensor
data
or
a
data
feed
• Can
be
JSON,
xml,
text,
or
other
content
type
– create
(POST):
make
new
observable
property
– delete
(DELETE)
remove
observable
property
– set
(PUT)
update
ObservaJon
Value
or
data
feed
– get
(GET)
returns
the
current
ObservaJon
Value
• Formats
for
embedded
Jme
+
locaJon
data
10. API
–
Agent
• Container
for
Event
Handlers,
soSware
components
invoked
within
the
local
context
of
a
Smart
Object
• Observer
class
invokes
Event
Handler
code
in
the
Agent
• Reference
ImplementaJon
– create
(POST)
make
a
new
code
object
instance
• handler
or
daemon
– delete
(DELETE)
remove
code
instance
– set
(PUT)
updates
segng
of
a
code
instance
– get
(GET)
returns
segng
of
a
code
instance
11. API
–
Observers
• Contains
graphs
which
define
the
nodes
and
endpoints
of
event
driven
processing
• Publish,
Subscribe,
and
Event
Handler
paYerns
• Reference
ImplementaJon
– create
(POST)
make
a
new
Observer
– set
(PUT)
update
an
Observer’s
segngs
– get
(GET)
return
an
Observer’s
segngs
– delete
(DELETE)
remove
an
Observer
13. REST
API
• Python
API
–
Local
SoSware,
Agents
and
Handlers
– Resources
(objects)
are
hierarchical
properJes
of
other
resources
– self.indoorTempValue = sensors.weather.indoor_temp.get()!
• Web
API
–
HYp
and
CoAP
REST
Client
access,
MQTT
topics
– Resources
are
organized
in
hierarchical
path
– GET http:my_server:8000/sensors/weather/indoor_temp!
– GET coap:my_server:5683/sensors/weather/indoor_temp!
– MQTT subscribe my_server:1883 /sensors/weather/indoor_temp!
• Default
Property
– Returns
a
resource
associated
with
a
higher
level
resource
– GET
of
Smart
Object
returns
it’s
DescripJon;
GET
of
Observable
Property
returns
it’s
ObservaJon
Value
14. Protocol
Bridge
Examples
• MQTT
Endpoints
and
Bridge
using
Observer
• CoAP
Server
Endpoint
and
link-‐data
Proxy
15. MQTT
Observer
MQTT
Broker
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
Publish
from
data
producer
Publish
From
REST
API
Publish
to
Other
Subscribers
SUB
Publish
to
REST
API
Connects
REST
Resource
to
MQTT
Topic
Publish
and
Subscribe
16. MQTT
Observer
MQTT
Broker
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
Publish
from
data
producer
Publish
From
REST
API
Publish
to
Other
Subscribers
SUB
Publish
to
REST
API
Publisher
Publishes
REST
Resource
updates
to
the
broker
17. MQTT
Observer
MQTT
Broker
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
Publish
from
data
producer
Publish
From
REST
API
Publish
to
Other
Subscribers
SUB
Publish
to
REST
API
Subscriber
Makes
last
published
data
available
at
the
REST
endpoint
18. MQTT
Observer
MQTT
Broker
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
Publish
from
data
producer
Publish
From
REST
API
Publish
to
Other
Subscribers
SUB
Publish
to
REST
API
Pub+Sub
Repeats
data
updates
in
both
direcJons
19. MQTT
Bridge
to
mulJple
REST
endpoints
MQTT
Broker
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
Publish
from
data
producer
Publish
to
Other
Subscribers
REST
Endpoint
ObservableProperty
mqYObserver
PUT
GET
22. IoT
Toolkit
• IoT
Toolkit
is
a
reference
implementaJon
of
the
Smart
Object
API
and
related
tools
• REST
API
with
real-‐Jme
event
model
for
the
Internet
of
Things
• Lightweight
server
that
can
run
on
small
computers
e.g.
Raspberry
Pi,
ARM/Linux
PC,
AWS
t1.micro
• M2M
using
HTTP,
MQTT,
and
CoAP,
others
23. IoT
Toolkit
Project
Status
• Smart
Object
API
is
complete
and
stable
• IoT
Toolkit
Demo
• M2M
interoperability:
MQTT,
CoAP,
HTTP
interfaces
• Development
Roadmap
Examples
– Harden
code,
excepJon
handling,
API
Tests
– Scalable
server,
mulJ-‐tenancy,
persistence
models
– Graph-‐based
resource
access
control
– Data
model
API
for
resource
discovery
and
linkage
– XMPP
endpoint
and
proxy
for
XEP-‐0060,
XEP-‐0323,
XEP-‐0325
– Programming
model
UI
e.g.
Node
Red
– Web
UI
for
debug
and
demo,
applicaJons
• Navigator,
Dashboard,
AnalyJcs,
Graphs
and
Charts