Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

IBM Bluemix and the Internet of Things - Workshop

3,891 views

Published on

Workshop about IBM Bluemix and Internet of Things, using different brokers (Mosquito, Internet of Things Foundation) and clients (Node.js, Eclipse Paho, Mosquitto command line), with code samples

Published in: Software
  • Be the first to comment

IBM Bluemix and the Internet of Things - Workshop

  1. 1. 1 POLITECNICO DI BARI April 28-29, 2015 Bari IBM Bluemix and the Internet of Things Giulio Santoli (@gjuljo) ibm.biz/Bluemix2015
  2. 2. 2 © 2015 IBM Corporation A new economic paradigm...
  3. 3. 3 © 2015 IBM Corporation Jeremy Rifkin: the Third Industrial Revolution Herbie Airbus Phantom Eye
  4. 4. 4 © 2015 IBM Corporation Hype cycle for emerging technologies 2014 Internet of Things is here!
  5. 5. 5 © 2015 IBM Corporation EveryTHING is connected My tells my that the is over My tells my to open the garage and start my My tells my that an intruder is entred A tells my to tell my that a arrived
  6. 6. 6 © 2015 IBM Corporation Internet of Things: Many different technologies
  7. 7. 7 © 2015 IBM Corporation MQTT, a messaging protocol for IoT Open (standard, 40+ client implementations) Lightweight (minimal overhead, efficient format, tiny clients) Reliable (QoS for reliability in unrealiable neworks) Simple (43-pages specification, connect/publish/subscribe) Late 90s Aug 2010 Nov 2011 Sep 2014 Invented by and Published by Eclipse M2m Standard (v. 3.1.1)
  8. 8. 8 © 2015 IBM Corporation MQTT v.s. HTTP
  9. 9. 9 © 2015 IBM Corporation MQTT: publis/subscribe Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  10. 10. 10 © 2015 IBM Corporation MQTT: payload agnostic Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  11. 11. 11 © 2015 IBM Corporation MQTT: wildcard subscriptions Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  12. 12. 12 © 2015 IBM Corporation MQTT: quality of service Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  13. 13. 13 © 2015 IBM Corporation MQTT: retained message for last value caching Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  14. 14. 14 © 2015 IBM Corporation MQTT: cleanSession for session state Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  15. 15. 15 © 2015 IBM Corporation MQTT: last will and testament Thanks to Bryan Boyd (http://www.slideshare.net/BryanBoyd/mqtt-austin-api)
  16. 16. 16 © 2015 IBM Corporation MQTT Brokers Appliance Cloud Open Source • IBM Message Sight • IBM IoT Foundation • HiveMQ • Eurotech EDC • Litmus Loop • ... • Mosquitto (C) • Mosca (NodeJS) • Moquette (Java) • RSMB (C) • ...Up & running in <30 minutes 1 rack = 273M msg/sec 21M concurrent connections DMZ-ready, FIPS 140-2 deny-based access control http://mosquitto.org http://www.mosca.io https://eclipse.org/paho
  17. 17. 17 © 2015 IBM Corporation IBM MessageSight Virtual Appliance https://developer.ibm.com/messaging/messagesight
  18. 18. 18 © 2015 IBM Corporation Example: simple moquitto > mosquitto -v > mosquitto_sub -d -t hello/world > mosquitto_pub -d -t hello/world -m "Hello, MQTT. This is my first message." > mosquitto_sub -d -t hello/+ > mosquitto_pub -d -t hello/aaa -m "Hello, MQTT. This is my first message." > mosquitto_pub -d -t hello/bbb -m "Hello, MQTT. This is my first message."
  19. 19. 19 © 2015 IBM Corporation Example: node.js & mosquitto mosquitto-server.js mosquitto-client.js
  20. 20. 20 © 2015 IBM Corporation Example: Eclipse Paho MosquittoClient.java
  21. 21. 21 © 2015 IBM Corporation > mosquitto_passwd -c mypasswords.txt sender > mosquitto_passwd mypasswords.txt receiver Example: moquitto with configuration > mosquitto -v -c mymosquitto.conf > mosquitto_sub -d -t hello/world -u receiver -P receiver > mosquitto_pub -d -t hello/world -u sender -P sender -m "Hello message" … password_file mypasswords.txt … mymosquitto.conf sender:$6$25Z4WgbWINtzGhC7$Ro78KKiitIjMJ YcWL88OJC/6gQhXYVc5eduomTwzvUC2Ictax/r 3X9c8S4CW3f5ZhPwmRKkaXJNOGWBz84nGB Q== receiver:$6$ceVsPkVtifa5+ITe$7vpPSJZTWc6W 6EnUMbHyinXelp7ziv+MHbBasu5ffaZ+ke7LU8gg jC34okcPOAHFTOSKCmVhxZMmAC5SbOaBsA == mypassword.txt
  22. 22. 22 © 2015 IBM Corporation IBM Internet of Things Cloud IBM BluemixIBM IoT Foundation + =
  23. 23. 23 © 2015 IBM Corporation IoT Foundation: Apps, Devices and APIs Devices IBM IoT Foundation Apps PUBLISH RECEIVE events commands PUBLISH commands REGISTER devices GENERATE API keys HTTP HTTP RECEIVE events (and services) MQTT MQTT
  24. 24. 24 © 2015 IBM Corporation IoT Foundation: MQTT and Apps https://developer.ibm.com/iot/recipes/improvise-application-development username  <key> password  <token> clientid  a:<orgid>:<app-id> publishes  iot-2/type/<type-id>/id/<device-id>/cmd/<cmd-id>/fmt/<format-id> subscribes  iot-2/type/<type-id>/id/<device-id>/evt/<event-id>/fmt/<format-id> Apps & Services key: a-myorg-hketyuionf token: AB3ur51jL+3awe0kl Example tcp://<org-id>.messaging.internetofthings.ibmcloud.com:1883 ssl://<org-id>.messaging.internetofthings.ibmcloud.com:8883 MQTT Host
  25. 25. 25 © 2015 IBM Corporation IoT Foundation: Devices Devices https://developer.ibm.com/iot/recipes/improvise-registered-devices https://developer.ibm.com/iot/recipes/improvise-commands username  use-token-auth password  <auth-token> clientid  d:<orgid>:<type-id>:<divice-id> publishes  iot-2/evt/<event-id>/fmt/<format> subscribes  iot-2/cmd/<cmd-type>/fmt/<format-id> payload  {"d": {"name1": "value1", "name2": intvalue } } org=myorg type=mydevicetype id=mydeviceid auth-method=token auth-token=Gh3e(EA998fart4 Example
  26. 26. 26 © 2015 IBM Corporation IoT Foundation: REST APIs View an organization (GET): https://internetofthings.ibmcloud.com/api/v0001/organizations/<org-id> List all devices (GET) / Registr a device (POST): https://internetofthings.ibmcloud.com/api/v0001/organizations/<org-id>/devices Historical data for a device (GET): https://internetofthings.ibmcloud.com/api/v0001/historian/<org-id>/<type-id>/<id>?filter REST API Examples https://developer.ibm.com/iot/recipes/api-documentation curl --user "<key>:<token>" https://internetofthings.ibmcloud.com/api/v0001/organizations/<org-id>/devices Example: get all devices
  27. 27. 27 © 2015 IBM Corporation IoT Foundation: MQTT Starfighter http://m2m.demos.ibm.com/collaboration.html#starfighter https://hub.jazz.net/project/spirit/MQTT%20Starfighter%20Server/overview
  28. 28. 28 © 2015 IBM Corporation IBM Connected Car http://m2m.demos.ibm.com/connectedCar.html#connectedCar http://tiny.cc/ws0zpx
  29. 29. 29 © 2015 IBM Corporation IBM Connected Car: some more pictures
  30. 30. 30 © 2015 IBM Corporation IoT Foundation: Quick Start https://quickstart.internetofthings.ibmcloud.com https://github.com/ibm-messaging/iot-arduino
  31. 31. 31 © 2015 IBM Corporation Example: moquitto & node.js clients > c:bluemixiot>echo {"d":{"temperature": 33 }} 2>&1 | mosquitto_pub -d -h quickstart.messaging.internetofthings.ibmcloud.com -i "d:quickstart:example:aa00bb11cc88" -q 0 -t "iot-2/evt/status/fmt/json" -l quickstart.js
  32. 32. 32 © 2015 IBM Corporation Example: java Paho client Quickstart.java
  33. 33. 33 © 2015 IBM Corporation IoT Foundation Organization
  34. 34. 34 © 2015 IBM Corporation Example: app (subscriber) & device (publisher) > mosquitto_sub -d -h org.messaging.internetofthings.ibmcloud.com -p 1883 -i "a:org:myapp" -u "key" -P "token" -t "iot-2/type/+/id/+/evt/+/fmt/json" > mosquitto_pub -d -h org.messaging.internetofthings.ibmcloud.com -p 1883 -i "d:org:type:id" -u "use-token-auth" -P "auth-token" -q 0 -t "iot-2/evt/status/fmt/json" -m "hello" org=myorg type=mydevicetype id=mydeviceid auth-method=token auth-token=Gj6e(EA998fart4 device key: a-myorg-hketyuionf token: AB3ddr51jL+3ape0kl app publish subscribedevice app
  35. 35. 35 © 2015 IBM Corporation Example: device (subscriber) & app (publisher) > mosquitto_sub -d -h org.messaging.internetofthings.ibmcloud.com -p 1883 -i "d:org:type:id" -u "use-token-auth" -P "auth-token" -t "iot-2/cmd/reboot/fmt/json" > mosquitto_pub -d -h org.messaging.internetofthings.ibmcloud.com -p 1883 -i "a:org:myapp" -u "key" -P "token" -t "iot-2/type/type/id/id/cmd/reboot/fmt/json" -m "test123" org=myorg type=mydevicetype id=mydeviceid auth-method=token auth-token=Gj6e(EA118fart4 device key: a-myorg-hjetyuionf token: AB3ffr51jL+3ape0kl app publishsubscribedevice app
  36. 36. 36 © 2015 IBM Corporation Example: Visualization Application https://github.com/ibm-messaging/iot-visualization
  37. 37. 37 © 2015 IBM Corporation Example: node.js registered client registered.js
  38. 38. 38 © 2015 IBM Corporation Example: java Paho registered client Registered.java
  39. 39. 39 © 2015 IBM Corporation Writing IoT-enabled applications is challenging Spaghetti-code is around the corner, debugging is a hell
  40. 40. 40 © 2015 IBM Corporation UML is dead, long live to UML IBM Rhapsody for Model-Driven Development in C, C++, Java and Ada
  41. 41. 41 © 2015 IBM Corporation IBM Rhapsody and Arduino Uno Demo
  42. 42. 42 © 2015 IBM Corporation Connected Train Demo – Overview IBM Bluemix IBM IoT Foundation IBM Rhapsody Raspberry Pi HTTP/HTTPS MQTT IR
  43. 43. 43 © 2015 IBM Corporation Raspberry-Pi Setup & Configuration 43
  44. 44. 44 © 2015 IBM Corporation IBM Rhapsody Developer http://www.ibm.com/developerworks/downloads/r/rhapsodydeveloper
  45. 45. 45 © 2015 IBM Corporation IBM Redbooks http://www.redbooks.ibm.com Redpaper: MQTT and Arduino Devices http://www.redbooks.ibm.com/abstracts/redp4929.html?Open
  46. 46. 46 © 2015 IBM Corporation Jeremy Rifkin
  47. 47. 47 © 2015 IBM Corporation Bluemix works. Start a free trial today ibm.biz/Bluemix2015

×