March 2018
Beginner to intermediate
410 pages
10h 40m
English
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 ...
Read now
Unlock full access