March 2018
Beginner to intermediate
410 pages
10h 40m
English
Out actuator will have a simpler interface. We will only register one observable resource called Output. It will return the current state of the output. Clients can subscribe to changes to the resource to be notified whenever the output changes, for any reason. Apart from adding a GET method handler, we will also add a POST method handler, allowing clients to change the output from the network. We begin by adding the GET method handler:
this.outputResource = this.coapEndpoint.Register("/Output",
(req, resp) =>
{
string s;
if (this.output.HasValue)
s = this.output.Value ? "true" : "false";
else
s = "-";
resp.Respond(CoapCode.Content, s, 64);
The resource returns a simple Boolean value (true or false ...
Read now
Unlock full access