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

Publishing event-based observable data

Similarly, we add a resource for our motion detector. But for this resource, we will use the acknowledged service, since missing a value when expecting one might have serious consequences:

this.motionResource = this.coapEndpoint.Register("/Motion", 
   (req, resp) => 
   { 
         string s; 
 
         if (this.lastMotion.HasValue) 
               s = this.lastMotion.Value ? "true" : "false"; 
               else 
               s = "-"; 
 
         resp.Respond(CoapCode.Content, s, 64); 
   }, Notifications.Acknowledged, "Motion detector.", null, null, 
   new int[] { PlainText.ContentFormatCode }); 

We will use this resource to illustrate event-based observable data. When the motion detector changes value, we don't want a delay in the sending of the new value to any subscribers, as we want the ...

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