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

Returning momentary values

We can use the event arguments provided in the handler to learn things about the original request, such as who made the request (the Actor) and which types of data are desired. The interface is loosely coupled, so we just return a set of fields. We don't have to be exact unless it saves processing time. Interfaces will filter the contents not desired or permitted anyway, to avoid information leaks because checks were omitted:

if (e.IsIncluded(FieldType.Identity)) Fields.Add(new StringField(ThingReference.Empty, Now, "Device ID", this.deviceId, FieldType.Identity, FieldQoS.AutomaticReadout)); if (this.lastLight.HasValue) Fields.Add(new QuantityField(ThingReference.Empty, Now, "Light", this.lastLight.Value, 2, "%", ...

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