Connecting devices to IBM's Internet of Things Foundation. The foundation is a PaaS service allowing you to get devices connected quicker than ever before.
3. Agenda
• The Internet of Things and its Ecosystem
• The IBM IoT Foundation and the IoT Foundation Quickstart
• Quickstart device recipes and demonstration
• How is Quickstart implemented?
• Writing your own device code
• Signing up and registering a device
3
5. The Internet of Things is the next Internet Frontier
Source:http://www.digitalcommunities.com/articles/FutureStructure-The-New-Framework-for-Communities.html
7. What is the IoT being used for today?
Extend the value of goods and services, e.g.
Lock/Unlock/Find your car
Tell me when my washing is done
How well am I cleaning my teeth?
Monetize through new business models
Ad-hoc care hire
Pay-as-you-drive insurance
Optimize by understanding behaviour and anticipating
most optimal actions
White goods manufacturer understanding
customer behaviour
Improved product support and maintenance
Smarter Supply Chain
Control remote behaviour with automation
Home automation / remote control
Energy Demand Management
Smarter Cities
Manufacturing
Key areas
Agriculture
Automotive
Consumer products
Energy and Utilities
Government
Healthcare
Home Automation
Insurance
Manufacturing
Transport
Oil and Gas
8. Consumers lead the Internet of things
Today Tomorrow Integration
A few connected
devices per
person…
Almost every device that consumers own will be connected, and
many new ones will be created to leverage the value created by
consumer connections.
Cross-platform
integrators will
connected devices
and automate
Door Lock personal activity:
Dishwasher
Clothes Washer
Clothes Dryer
Window Lock
Garage Door
Toothbrush
Garden Moisture
Coffee Maker
Home Lights
Examples:
Ifttt.com
Zapier.com
Just as consumers have led enterprises in embracing new mobile services, we believe they will
lead the adoption of connected devices & integrated services
9. Ecosystem & Partners are crucial
Solutions & Applications
Oil
& Gas
Smarter
Cities
Energy
& Utilities
Consumer
Electronics
Transport
& Rail
Connected
Vehicle
Life Science
& Healthcare
Industrial
Manufacturing
Streams
Devices Gateways Networks Clouds
IBM Industry
Solutions
IBM SWG
MessageSight
SDK SDK Partnerships
Maximo
IoC
10. IoT use cases have many common requirements
Core Requirements:
Easily on-board connected “things”
Create a real-time communication channel with the “thing”
Begin capturing data from the “thing”
Visualize data from the “thing”
Collect data in a historian DB
Provide access to the collected data
Manage the “things” and the connectivity to them
Secure the data from the “thing” and control access to that that data
Pay for the service based on usage
Extended Requirements:
Perform analytics both in real-time and on historical trend data
Trigger events based on specific data conditions
Interact with the “thing” from business apps and/or from mobile devices
Send commands to the “thing”
12. IBM Internet of Things Foundation
Secure + Connect
(Messaging)
Collect Data
(Historian)
Manage Connections
(IoTF Portal)
22
AAnnaallyyttiiccss
AAsssseemmbbllee
IBM IoT
Foundation
IBM Bluemix
MMoobbiillee
1. Management API
2. Real-time data API
3. Historical data API
11
33
13. IBM Internet of Things Foundation Quickstart
What Users Can Do:
Connect devices, collect, route, and visualize data
Build internet of things applications to analyze data
Customize and add further devices
Key Capabilities:
• Extremely rapid device onboarding
• Real-time collection of data from devices
• Visualization of data from devices
• Communications api to allow custom devices to be added
• Access to data for Bluemix applications via the IoT Service
Platform
as a Service
Note: IoT Foundation Quickstart is a tool to let embedded device developers
connect to the IoT and see data from their device, and to provide data for IoT
application developers to use. It is not intended for production use.
It is a free service, there is no device or user registration step, and all data sent to
the Quickstart service could potentially be viewed by any internet user.
15. What You Can Do with Quickstart
• Select from a growing list of device recipes
• Simply connect & “recognize” device types
• Visualize real-time data stream
• Visually define logic flows
using Node-RED
• Mix with other services in BlueMix
• Build applications that incorporate IoT
17. Simple Connection for Internet of Things
Unpack device and connect it to the Internet
Install software* on the device
Start collecting and visualizing data
* We provide source code samples for a variety of devices on
https://github.com/ibm-messaging
19. The parts of each Recipe
• Ingredients
– The hardware that you need
• Preparation
– Unpacking the device, installing the OS if necessary, connecting
it to your Computer, etc.
• Connecting
– Installing the QuickStart software and starting it up
• Visualization
– Type in your device’s MAC address and see the results
27. Quickstart - how is it implemented?
Bluemix
applications
Softlayer cloud
MQTT Server infrastructure
(based on IBM MessageSight)
MQTT
MQTT
Embedded
device app
C, C++ or
JavaScript
Visualization
app – HTML5
28. MQTT - Open Connectivity for Mobile, M2M and IoT
High volumes of data/events
Lossy or
Constrained
Network
Lossy or
Constrained
Network
IT Systems
Monitoring &
Analytics
Server
Commands or Data Visualisation
A lightweight publish/subscribe protocol with predictable bi-directional message delivery
In the era of a Smarter Planet, open
source and standards are essential
1999 Invented by Dr. Andy Stanford-Clark (IBM),
Arlen Nipper (now Cirrus Link Solutions)
2011 - Eclipse PAHO MQTT open
source project
2004 MQTT.org open community
2013 – MQTT Technical
Committee formed
Cimetrics, Cisco, Eclipse, dc-Square,
Eurotech, IBM, INETCO Landis & Gyr,
LSI, Kaazing, M2Mi, Red Hat, Solace,
Telit Comms, Software AG, TIBCO,
WSO2
Evolution of an open technology
29. Publish / Subscribe Messaging (One to Many)
A producer publishes a message (publication) on a topic (subject)
A consumer subscribes (makes a subscription) for messages on a topic (subject)
A message server matches publications to subscriptions
If none of them match the message is discarded
If one or more matches the message is delivered to each matching consumer
Publish / Subscribe has three important characteristics:
1. It decouples message senders and receivers, allowing for more flexible applications
2. It can take a single message and distribute it to many consumers
3. This collection of consumers can change over time, and vary based on the nature
of the message.
30. MQTT and HTTP
• The HTTP standard revolutionized how we consume data
‒ A single simple model: Send a request, read the response
‒ Available via any tablet, laptop, phone, PC etc.
‒ Good for requesting data from a known source
• MQTT brings features specifically designed for mobile or M2M use…
HTTP MQTT
Style/Paradigm Synchronous,
request/response
Asynchronous, event-driven
Design Point Web browsers M2M / IoT
Message size Rich headers 2 bytes in minimum header
Reliability over fragile
networks
Need to implement by
custom code on top of
HTTP
Built-in
Push client->server Yes Yes
Push server->client Polling has to used on
top of HTTP
Efficient, scalable push is built
into the protocol
Ubiquity Widely available Growing number of OSS and
commercial implementations
Standards IETF OASIS
Data distribution 1-to-1 only Supports 1-to-none, 1-to-1, 1-
to-n, n-to-1
31. MQTT Clients and APIs
You can develop an MQTT client application by programming directly to the MQTT
protocol specification, however it is more convenient to use a prebuilt client
Client libraries provide some or all of the following:
• Functions to build and parse the MQTT protocol control packets
• Threads to handle receipt of incoming control packets
• QoS 1 and QoS 2 delivery using a local persistence store
• KeepAlive handling
• Simple API for developers to use
Open Source clients available in Eclipse Paho project
• C, C++, Java, JavaScript, Lua, Python and Go
Clients for other languages are available, see mqtt.org/software
• E.g. Delphi, Erlang, .Net, Objective-C, PERL, PHP, Ruby
• Not all of the client libraries listed on mqtt.org are current. Some are at an early or
experimental stage of development, whilst others are stable and mature.
32. Eclipse Paho clients
• C / C++
– MQTT C Client for Posix and Windows
– MQTT C++ Client for Posix and Windows
– Embedded MQTT C Client
• Java
– J2SE client
– J2ME client
– Android service
• Others
– JavaScript (for browser and hybrid applications)
– Lua
– Python
– Go
33. Paho C Client libraries
• Linux (Posix) or Windows
– Full featured clients providing an MQTT api with QoS1, QoS2 and keepAlive
handling
– Synchronous client (fully synchronous mode)
• Connect, Disconnect, Publish, Subscribe and Unsubscribe calls block until they
receive a response from the server
• Applications use mqtt_receive() to read inbound messages
• Client library runs entirely on the calling application’s thread
– Synchronous client (asynchronous mode)
• Selected by registering a messageReceived, messageDelivered or connectionLost
callback.
• Library starts a separate thread to handle these callbacks
– Asynchronous (use MqttAsynch )
• All API calls are processed asynchronously and invoke a callback when complete
• Embedded Client
– Limited to the construction and parsing of MQTT control packets
– Client runs entirely on the calling application’s thread
– Intended for embedded devices that don’t run Linux (e.g. ARM mbed)
34. Programming your own device to use Quickstart
You must
• Use MQTT 3.1 or MQTT 3.1.1 (3.1.1 is preferable)
• Connect to quickstart.messaging.internetofthings.ibmcloud.com, port 1883
• Supply a client-id of the form d:<org-id>:<device-type>:<device-id>, where:
• <org-id> = “quickstart”
• <device-type> = an identifier you provide, e.g. “acme-thing”
• <device-id> = a 12 hexadecimal character mac address in lower case, without
delimiting : (colon) characters. For example, a36d7c91bf9e.
• Publish to the topic “iot-2/evt/status/fmt/json”
• Publish at QoS=0 only
You should be aware that...
• The retained flag will not be honoured
• Subscribing to receive messages isn’t supported.
35. Programming your own device – Quickstart message format
The message payload must be in JSON and must not exceed 4096 bytes
(that’s the QuickStart limit).
The message payload must contain a single top-level property called "d".
This property may contain an arbitrary number of child properties, these
having either integer or string datatypes:
{ "d": { "name1": "stringvalue", "name2": intvalue, ... } }
Here's an example:
{ "d": { "myName": "Stuart's Pi", "cputemp": 46, "sine": -10, "cpuload",
1.45 } }
"myName" is optional – but if you supply it, it’s displayed as a title on the
visualization page.
36. Security Considerations
As we have already noted, the IBM IoT Cloud Quickstart service is free and does
not provide any security features.
When designing an IoT application for production use, you need to consider its
security implications, including:
1. Do I need to secure the data coming from the devices? This could mean
• Authenticating the devices when they connect, to protect against an
attacker who attempts to impersonate them
• Using TLS to protect the data as it travels from the device, to prevent the
data from being modified in transit
• Protecting the devices and the software that runs on them from being
subverted by an attacker.
2. Do I need to restrict access to the data itself, for privacy or other reasons?
• Use TLS to encrypt the data as it travels from the device
• Authenticate any applications that try to access the device data
38. Signing up to the IoT Foundation Service
Signing up allows permanent usage of the IoTF service in a secure fashion.
• Administration dashboard that lets you register devices and monitor their
status
• Security of data, the device and the communications channel (TLS +
authentication and authorisation for devices & applications)
• Inbuilt historian with API for time series data access
• Allows publishing of information to registered devices (i.e. sending commands to
devices)
Available Plans
30-day Free Trial: Available from IBM Marketplace
Free plan: Available from IBM Bluemix
Bronze: Get started quickly and move to production with a small number of
devices
Silver: For standard needs: development, test and production use
Gold: For advanced needs and large-scale production use
39. Two ways to sign up for an IoT account
1. Via IBM Bluemix
• Sign up to Bluemix itself
• Open the Bluemix Catalog and scroll
down till you find Internet of Things
• Create an instance of the IoT Service
• You may bind it to a Bluemix application
or leave it unbound
1. Via IBM Cloud Marketplace
• Log in to marketplace
• Select 30-day Free Trial or paid
subscription
You can start on either route from
https://internetofthings.ibmcloud.com/dashboard/#/signup
Signing up (by either route) creates an “IoT Foundation
Organization”. This represents you usage of the Foundation
40. Registering Devices with and IoTF Organization
When registering a device with an IoTF organization you must provide
• A Device Type - this describes the kind of device it is
• A Device Identifier – unique for this device (within its Device Type)
41. Registering devices – Credentials
When you have successfully registered your device, the IoT Foundation
generates a Token for it to use on the MQTT Connect call.
The UI provides a block of credentials (including this token) as shown below
The id of the owning organization
The device type that you provided
The device id that you provided
Indicates that authentication is to
be by token
Secret token to be used by your
device.
42. Registering devices – using the
Credentials
• The recipes that come with the Quickstart devices tell
you how to update the device code so that it uses the
credentials generated by the IoTF
– In some cases this is simply a question of downloading a
file onto the device.
• If you are writing your own device code, you need to
connect as follows:
– Make the MQTT connection to
<org-id>xyzzyz.messaging.internetofthings.ibmcloud.com:1883, or
<org-id>xyzzyz.messaging.internetofthings.ibmcloud.com:8883 (TLS)
– Use an MQTT client identifier of the form:
d:<org-id>:<device-type>:<device-id>
– Supply the literal "use-token-auth" as the MQTT username
– Supply the authorization token as the MQTT password
43. Registered devices – receiving commands
• Once a device has been registered, it can subscribe to receive commands
sent to it by IoT Foundation applications
• The device connects as described on the previous slide
• It can subscribe to any topic of the form
– iot-2/cmd/<cmd-type>/fmt/<format-id>
• <cmd-type> is used to distinguish between different types of command. A
device that supports more than one type of command can make more
than one subscription. Alternatively it can subscribe to all commands that
are targeted to it by using the ‘+’ MQTT wildcard character in this topic
element.
• <format-id> is used to distinguish different payload encodings. Multiple
formats might be published and this distinction subscribes the device only
to a relevant encoding format. If possible, applications and devices should
use a format-id of “json” and encode the command as a JSON object.
However, no constraints are imposed on the message structure or
encoding, or on the content of the commands.
44. Summary
Internet of Things
Rapidly growing space, across nearly every industry
Partner ecosystem plays a vital part
IoT Foundation
Connect devices, collect, route, and visualize data
Build internet of things applications to analyze data
Customize and add further devices
MQTT
Messaging optimized for mobile, smart sensors and telemetry devices
Simple APIs for Java, JavaScript and other languages
instrumented interconnected intelligent
45. Useful Links
IBM IoT Foundation and Quickstart
- http://internetofthings.ibmcloud.com
Quickstart recipes on developerWorks
- https://www.ibmdw.net/iot/recipes
Quickstart code on GitHub
- https://github.com/ibm-messaging
MQTT information
- http://mqtt.org
MQTT 3.1.1 Specification
• http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/cos02/mqtt-v3.1.1-cos02.pdf
48. WebSphere Technical University and Digital Experience Europe 2014
Your feedback is valuable - please complete your session or lab evaluation!
Session number
A34
Provide your evaluations by:
Evaluation forms:
Fill out a form at the end of each session
Paper forms are located in each of the session or lab rooms
Place the completed form in the tray as you exit the room
- Or –
Complete the session survey on Event Connect Portal: ibmeventconnect.eu/euxdx
Select Sessions, then Session Finder, and complete the survey
Notes de l'éditeur
Advanced options:
Restrict access to certain IP addresses (firewall security)
Your own dedicated space in our cloud (completely isolated environment) – “security” = layers of many small things
Some limitations on the developer access..., for example:
Development devices store data for 30 days.
Developer API limit: 25 API calls per minute (on 3 minute moving average)
Freemium: Sandbox, enough for a PoC, full function (incl. add-on‘s), limited in # devices, data transferred, redundancy, backup
1$/mo for 1.000.000 messages == 0.01$ for 10.000 messages
Notes:
Focus on Messages + Data Transferred = Message Data Volume
APIs make more sense for value-add custom services on top
Alternatively could count: Rest APIs (history, config, ...) + publish + receive as subscribed
Most messages will be small in size (up to 8K).
Need to count number of messages for meaningful limits.
Focus on Connections (rather than devices),
Encourage “always-on“ „all-the-time“ connections
Push in a timely fashion
More efficient than reconnect, esp if SSL
Data per message: Typically &lt; 8KB, (and 1MB data rental plan per device)
Bigger messages require more storage and memory
Avoid that people minimize amount of data to fit into a pricing plan
Scenarios:
Sometimes connected, eg pace maker:
Dial-Up + Publish list from device + Pickup data published
Regular data: 1 msg every 3-5 min with low latency
Variable data rate: eg Car2Go
Always connected
Heartbeat messages while waiting to be picked up
Unlock door messages when starting to be used
Many messages while driving
A few links to find out more info.
Mqtt.org is a great starting point and central repository for all things mqtt.
Markus: hold up the agenda book and show the attendees.