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 12. Concentrators and Bridges

Real-world devices are sometimes complex. They often host multiple logical entities or logical devices providing different functionalities inside themselves. This encapsulation of virtual devices inside one communicating entity is called a concentrator. A concentrator concentrates multiple virtual or logical devices into one physical device. A method is presented that allows you to work with virtual devices seamlessly, as if they were standalone devices on the network. The same technique can be used to bridge between protocol islands, either using the same or different types of communication protocols, or to integrate backend systems into the network. This chapter covers:

  • An introduction to the concept of concentrators
  • How concentrators can be used to model embedded devices
  • How concentrators can be used to bridge between protocols
  • How concentrators can be used to integrate backend systems
  • How embedded nodes are referenced
  • How concentrators are managed
  • How to...

Introducing concentrators


Up to this point, we've studied relatively simple devices, each fitting neatly into a physical device. But often, you can add value to your physical device, if you divide it into multiple logical devices. A simple example may be our sensor. It senses two different things: ambient light and motion. These two things are independent of each other and could be modeled as individual sensors logically. But running them on different Raspberry Pi would be more expensive and would only make sense if the actual sensors were separated by some distance. For that reason, it is more cost efficient to implement them into one single unit. They share the same Raspberry Pi, operating system, and network connection.

Dividing a device into multiple logical devices permits you to do things you normally would not do with a single device: you can manage and operate them separately on the network. You can also provision them differently and assign different owners to the different logical...

Referencing embedded nodes


In the previous chapters, we've used different classes from different NuGet packages to perform different tasks on the XMPP network. Depending on whether we've implemented a sensor, an actuator, a controller, or a combination of these, different classes have been used. The following table gives an overview of the different classes that we have used, together with their most important methods and events:

Class

Methods

Events

SensorClient

RequestReadout()

Subscribe()

SensorServer

OnExecuteReadoutRequest

ControlClient

Set()

GetForm()

CancelForm()

ControlServer

OnGetControlParameters

ThingRegistryClient

RegisterThing()

UpdateThing()

Mine()

Remove()

Unregister()

Disown()

Search()

Claimed

Removed

Disowned

ProvisioningClient

GetToken()

GetCertificate()

IsFriend()

CanRead()

CanControl()

IsFriendResponse()

CanReadResponse*()

CanControlResponse*()

ClearDeviceCaches()

ClearDeviceCache()

GetDevices()

DeleteDeviceRules()

IsFriendQuestion

CanReadQuestion

CanControlQuestion

Referencing embedded sensor nodes

Referencing...

Managing a concentrator


Referencing embedded nodes is only one part of managing a concentrator. While the preceding interfaces might be sufficient for interacting with small devices with a fixed number of embedded nodes, there are many cases where management of embedded devices is required.

The Waher.Networking.XMPP.Concentrator and .UWP NuGet packages define a ConcentratorClient and ConcentratorServer class that will help you with these tasks. They will help with:

  • Management and discovery of data sources
  • Management of nodes in data sources, including browsing, searching, updating, adding, and removing embedded nodes, including large sets of nodes
  • Access management
  • Execution of commands and queries
  • Management of sensor data databases

All concentrator functions are optional, and the concentrator can choose which features to support. This allows the interface to support very simple concentrators (such as PLCs), medium-sized concentrators (such as bridges), and large concentrators (such as backend...

Implementing a concentrator


We are now ready to implement our first concentrator. The goal will be to create a concentrator that includes both our sensor and our actuator into a single physical device. It will work seamlessly with the controller application developed in Chapter 10, The Controller, since each embedded node registers itself as a separate thing. The details of this implementation can be found in the ConcentratorXmpp project, in the Mastering Internet of Things GitHub repository.

Instantiating the concentrator

Instantiating the concentrator is easy. We first add a reference to the Waher.Networking.XMPP.Concentrator.UWP NuGet package to our project (if we're not doing an UWP app, we add the Waher.Networking.XMPP.Concentrator NuGet). We then simply create the object, with a reference to the XMPP client object we use, and reference to all the root data sources we define. We will define only one data source, the MeteringTopology data source. It is the default data source for embedded...

Adding provisioning support to the concentrator


If you're familiar with the concepts of provisioning, as described in the previous chapter, and concentrators as described in this chapter, adding provisioning support to a concentrator is straightforward and will be left to the reader. The details are available in the ConcentratorXmpp2 project in the Mastering Internet of Things GitHub repository. The outline of the implementation is as follows:

  • After finding a provisioning server, you create an instance of the ProvisioningClient class pointing to the provisioning server, with a reference to the XMPP client being used. This action will provision presence subscription requests (or friendship requests) for your device.
  • If you want each embedded node to be provisioned as well, you provide a reference to the provisioning client to the ConcentratorServer instance when you create it. It will pass it on to the SensorServer and ControlServer instances it creates.
  • If you provision embedded nodes, you...

Summary


In this chapter, you've been shown the basic principles of how to create a concentrator to embed functionality as nodes. You've learned the fundamental use cases for concentrators, the basic object model for a concentrator, and how to publish data sources and nodes in a concentrator. You've also learned the basic principles of managing nodes in a concentrator, how to register embedded nodes in a Thing Registry, and the basic principles of provisioning for embedded nodes in a concentrator. You've seen how to interact with nodes in a concentrator as if they were standalone devices on the network. In the next chapter, we will analyze how an Internet of Things Service Platform can help you with many of the repetitive tasks required to implement services for the Internet of Things.

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