iot studio #1: protocols introduction and connected jukebox

22
IoT Studio #1 16th February 2016 Mickaël Rémond, @mickael

Upload: mickael-remond

Post on 22-Jan-2018

968 views

Category:

Technology


1 download

TRANSCRIPT

IoT Studio #1

16th February 2016 Mickaël Rémond, @mickael

Questions

Connected Things

• What are the main classes of protocols for the Internet of Things ?

• What are the strengths of XMPP for the Internet of things ?

• What are the main XMPP Extensions for building the Internet of Things ?

• How can I leverage XMPP to build a real device / appliance ? => Tutorial / Demo

What are the Main Classes of Protocols for the Internet of Things ?• There are numerous protocols for the Internet of Things.

• They act at different levels and fill different needs.

• We can split IoT protocols into two classes: • Infrastructure protocols • Messaging protocols

IoT Infrastructure Protocols

• Infrastructure protocols focus on low level communications.

• Long range / Low power: • Sigfox (Proprietary) • LoRA • LTE-M • Wi-Fi HaLow • Weightless, On-Ramp, …

• Short range communication: • ZigBee • NFC • Bluetooth • Wifi • ...

IoT Messaging Protocols

• Messaging protocols are higher level and can be transported on various lower level protocols.

• Most typical uses cases are: • Sensors / metrics reporting (upstream) • Control: Control device parameters and behaviours (downstream)

• Examples: • MQTT for example over TCP/IP or MQTT-SN variant over UDP • XMPP • STOMP • Statsd • Riemann protocol • ...

IoT Messaging Protocols

• An IoT Messaging platform typical speak several protocols.

• The underlying semantic is the same: Broadcast, control, reporting, …

• The platform act as a bridge.

• Over time, we are seeing a shift from lower level messaging protocols to higher level protocols, as things are spreading and get more and more powerful.

• For example: • Raspberry Pi Zero is demonstrating how a whole Linux computer is now going

down the stack to power smaller and smaller devices.

What are the Strengths of XMPP for the Internet of things ?

• XMPP is very good as a hub / platform for things. It can support both sensor reading / reporting and access.

• However, its main strengths are very unique in the IoT protocol landscape. XMPP natively and easily supports:

• Identity: Ability to manage things identity thanks to Jabber ID (global / universal identity).

• Federation: Things from different manufacturer, plugged on different platform can interoperate.

• Delegation: Ability to trust user ID on the network and this thus simplify provisioning / delegation of rights to interact with devices.

What are the main XMPP Extensions for Building the Internet of Things ?• XMPP core contains features that play well with IoT:

• SASL Authentication • Federation • Encryption • Synchronous (iq) and asynchronous messaging support (message / presence) • Offline message store / delayed delivery • ...

• Additionally, many general purpose extensions are very relevant to the IoT topic: • XEP-0060: Pubsub • XEP-0178: Best Practices for Use of SASL EXTERNAL with Certificates • XEP-0050: Ad-Hoc Commands • XEP-0004 and others: Data forms • XEP-0115: Entity capabilities • XEP-0184: Message delivery receipts • XEP-0280: Message carbons • ...

What are the main XMPP Extensions for Building the Internet of Things ?• An XMPP IoT Initiative is working on extending the protocol for the purpose of the Internet of Things.

• Some XMPP Extensions have been designed with the Internet of Things in mind, with the purpose of supporting sensors or controllers:

• XEP-0322: Efficient XML Interchange (EXI) Format • XEP-0323: Internet of Things - Sensor Data • XEP-0324: Internet of Things - Provisioning • XEP-0325: Internet of Things - Control • XEP-0326: Internet of Things - Concentrators • XEP-0347: Internet of Things - Discovery

• ejabberd also brings some important features to the table by supporting important feature to handle a large number of devices:

• Clustering • Massive scalability

How can I leverage XMPP to Build a real device / appliance ?• I have prepared a demo showing how to plug various things together.

• I will demonstrate building a Jukebox to play songs from SoundCloud by simply sending control instruction to a Raspberry Pi 2 base device.

• I will use the following technologies: • XMPP protocol. • ejabberd as messaging platform. • Go programming language with my Go XMPP Library (Gox) to write the Jukebox

software. • Raspberry Pi 2 hardware running with our own custom minimal Linux image, with a

speaker connected to the analog sound output.

Architecture diagram

ejabberd serverJukebox

�����

Client Control Operation

• Client can be a simple chat bot:

• It will play a URL when receiving it in chat message:

<message type="chat" to="test@localhost" id="aac9a"> <body>https://soundcloud.com/radiohead/spectre</body></message>

• It will stop the stream when receive the command “stop” in chat message:

<message type="chat" to="test@localhost" id="aacaa"> <body>stop</body></message>

Implementing IoT XMPP Control

• Our XMPP Jukebox is also able to play using IOT control operations as defined in XEP-0325:

<iq type='set'     to='test@localhost/jukebox'     id='2'>    <set xmlns='urn:xmpp:iot:control' xml:lang='en'>      <string name='action' value='play'/>      <string name='url' value='https://soundcloud.com/radiohead/spectre'/>    </set> </iq>

Jukebox broadcasts User Tune

<message from="test@localhost" type="headline" to="admin@localhost/MacBook-Pro-de-Mickael"> <event xmlns="http://jabber.org/protocol/pubsub#event"> <items node="http://jabber.org/protocol/tune"> <item id="5AFB0605CB069"> <tune xmlns="http://jabber.org/protocol/tune"> <artist>Radiohead</artist> <title>Spectre</title> </tune> </item> </items> </event> <addresses xmlns="http://jabber.org/protocol/address"> <address type="replyto" jid="test@localhost/jukebox"/> </addresses></message>

Go XMPP Jukebox client

Main function

Go XMPP Jukebox client

XMPP Client Connect

Go XMPP Jukebox client

Message Processing

Go XMPP Jukebox client

IoT Control IQ Processing

Go XMPP Jukebox client

Sending PEP User Tune

Go XMPP Jukebox client

Playing Song with mpg123 player

Demo

See you at next