Reader small image

You're reading from  Mastering Internet of Things

Product typeBook
Published inMar 2018
PublisherPackt
ISBN-139781788397483
Edition1st Edition
Right arrow
Author (1)
Peter Waher
Peter Waher
author image
Peter Waher

Peter Waher is the founder of Little Sister®, a standards-based distributed social network, based on the principles of edge computing, privacy & information ownership, for humans and machines. Currently, Peter advises companies on topics such as privacy, the IoT and Smart Cities. He has worked for 24 years with computers and device communication, including low-level development in assembler for resource-constrained devices to high-level system design and architecture. His award-winning applications has attracted global attention, and he has been invited to speak at prestigious events.
Read more about Peter Waher

Right arrow

Chapter 9. Social Interaction with Your Devices Using XMPP

In the previous chapters of this book, we discussed different relatively simple protocols and communication patterns to illustrate how communication can be done with devices, in different ways. In the second part of this book, we will introduce a more advanced paradigm of communication that allows us to do much more interesting things with our devices, in a more secure and interoperable, yet flexible, manner. The following chapters will be dedicated to the Extensible Messaging and Presence Protocol (XMPP). Since it provides such a rich set of tools that Internet of things (IoT) developers can use, the scope of the XMPP protocol will be presented throughout several of the following chapters.

This chapter will focus on social interaction with things. It covers:

  • An introduction to XMPP
  • The basics of XMPP Extension Protocols (XEPs)
  • Trust-based communication
  • Request/response pattern using XMPP
  • Event subscription pattern using XMPP
  • Publish/subscribe...

Introducing XMPP


The XMPP was developed within the Jabber project in the late 1990s as a means to provide the necessary communication infrastructure for instant messaging (or chat) applications. These kinds of applications required an open, flexible, and extensible protocol that allowed peers to communicate with each other, even if they were residing behind separate firewalls.

The protocol has since grown and covers a lot of different use cases requiring instant messaging (that is, asynchronous messaging between peers) that are not related to chat. The protocol is also maintained by a separate organization, called the XMPP Standards Foundation (XSF). The core of the XMPP protocol is also standardized by the Internet Engineering Task Force (IETF). XMPP Extension Protocols (XEPs) are maintained and published by the XSF.

Using XML

The XMPP protocol is based on the Extensible Markup Language, or XML. It is XML that makes the protocol extensible, in a well-defined manner. Since XML elements are...

Adding XMPP to our devices


We now have sufficient information to begin using XMPP in our projects. To do this, we create two new projects, which we will call SensorXmpp and ActuatorXmpp, copying the corresponding code from the Sensor and Actuator projects as we have done earlier. As with the previous chapters, we use the same hardware.

Note

For reference, the projects are available on GitHub at https://github.com/PeterWaher/MIoT.

We also add a series of NuGet packages to our projects:

NuGet

Description

Waher.Networking.XMPP.UWP

XMPP client library.

Waher.Networking.XMPP.Sensor.UWP

XMPP IoT sensor data plugin. Added to both projects.

Waher.Networking.XMPP.Chat.UWP

XMPP IoT chat plugin.

Waher.Networking.XMPP.Control.UWP

XMPP IoT control plugin. Only added to the ActuatorXmpp project.

Waher.Networking.XMPP.Provisioning.UWP

Added to both projects. We will discuss this module in a later chapter.

Note

For .NET Standard, .NET Core, second-generation UWP, or traditional .NET Framework projects, you can use the package...

Summary


In this chapter, you’ve been shown the basic principles of how XMPP works, and how XMPP can be used to provide a flexible, extensible, and scalable infrastructure for devices. You’ve learned how brokers help devices cross topology barriers such as firewalls, and how stanzas are related to important communication patterns. You’ve also learned the basics of trust-based communication and loosely coupled interfaces for the IoT. You know how to publish sensor data and control parameters over XMPP and how to test your sensors and actuators using XMPP. In the following chapters, you will learn how to interact with your devices with code.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Internet of Things
Published in: Mar 2018Publisher: PacktISBN-13: 9781788397483
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Peter Waher

Peter Waher is the founder of Little Sister®, a standards-based distributed social network, based on the principles of edge computing, privacy & information ownership, for humans and machines. Currently, Peter advises companies on topics such as privacy, the IoT and Smart Cities. He has worked for 24 years with computers and device communication, including low-level development in assembler for resource-constrained devices to high-level system design and architecture. His award-winning applications has attracted global attention, and he has been invited to speak at prestigious events.
Read more about Peter Waher