bjoern.butzin created page: home authored by Björn Butzin's avatar Björn Butzin
...@@ -190,10 +190,10 @@ Temperature < 21 -> off ...@@ -190,10 +190,10 @@ Temperature < 21 -> off
`resource.setObservable(true);` `resource.setObservable(true);`
2. Let server notify clients every 5 s about changed TemperatureResource (Server.java, TODO 11): 2. Let server notify clients every 5 s about changed TemperatureResource (Server.java, TODO 11):
* indicate a change for resource every 5 seconds * indicate a change for resource every 5 seconds
`while (true) { `while (true) {`
try {Thread.sleep(5000);} try {Thread.sleep(5000);}`
catch (InterruptedException e) {/*do nothing*/} catch (InterruptedException e) {/*do nothing*/}`
resource.changed(); resource.changed();`
}` }`
* Use the „Tasks“ view of Eclipse to find the right places * Use the „Tasks“ view of Eclipse to find the right places
* Solve only TODO 10-15 as described by the following instructions - ignore other TODOs or FIXMEs * Solve only TODO 10-15 as described by the following instructions - ignore other TODOs or FIXMEs
...@@ -202,16 +202,16 @@ resource.changed(); ...@@ -202,16 +202,16 @@ resource.changed();
“medium”, “low” or “off” (Client.java & Server.java, TODO 12-15): “medium”, “low” or “off” (Client.java & Server.java, TODO 12-15):
* Change exitAfterResponse to false (Client.java, TODO 12) * Change exitAfterResponse to false (Client.java, TODO 12)
* Add the observe-option to your CoAP-GET request (Client.java, TODO 13) * Add the observe-option to your CoAP-GET request (Client.java, TODO 13)
request.setObserveOption(0); `request.setObserveOption(0);`
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 14) * add a BasicCoapResource to the ResourceServer (Server.java, TODO 14)
resourceServer.createResource( newBasicCoapResource(“/ACControl”,”off”,CoapMediaType.text_plain)); resourceServer.createResource( newBasicCoapResource(“/ACControl”,”off”,CoapMediaType.text_plain));
* send PUT request (Client.java, TODO 15) * send PUT request (Client.java, TODO 15)
`CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT); `CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT);`
request.setUriPath(“/ACControl”); `request.setUriPath(“/ACControl”);`
request.setContentType(CoapMediaType.text_plain); `request.setContentType(CoapMediaType.text_plain);`
/*Depending on the received payload high, medium, low, off*/ `/*Depending on the received payload high, medium, low, off*/`
request.setPayload(“medium”.getBytes()); `request.setPayload(“medium”.getBytes());`
clientChannel.sendMessage(request);` `clientChannel.sendMessage(request);`
28 <= Temperature -> high 28 <= Temperature -> high
25 <= Temperature < 28 -> medium 25 <= Temperature < 28 -> medium
... ...
......