O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Picking suitable devices

Each thing in the search result, apart from being public, is also returned with the complete set of metadata tags it has registered with the registry. We loop through the things found, and analyze the TYPE tag to identify which things correspond to our sensor and actuator:

foreach (SearchResultThing Thing in e.Things) 
{ 
   foreach (MetaDataTag Tag in Thing.Tags) 
   { 
         if (Tag.Name == "TYPE" && 
               Tag is MetaDataStringTag StringTag) 
         { 
               switch (Tag.StringValue) 
               { 
                     case "MIoT Sensor": 
                           if (string.IsNullOrEmpty( 
                                 this.sensorJid)) 
                           { 
                                 this.sensorJid = Thing.Jid; 
                                 this.sensor = Thing.Node; 
Only the sensor case will be demonstrated. The actuator case is completely analogous.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required