@@ -150,6 +157,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
#### 2. Create a CoapRequest & add some Options (Client.java, FIXME 7-9):
* A channel represents a single connection and is used to create and send requests
```java
Booleanreliable=false;
CoapRequestCodereqCode=CoapRequestCode.GET;
...
...
@@ -158,12 +166,14 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
```
#### 3. Send the CoapRequest (Client.java, FIXME 7-9):
```java
clientChannel.sendMessage(request);
```
#### 4. Wait for CoapResponse & Print the CoapResponse on the console
* A client has some callbacks that are invoked, when the corresponding event occurs
```java
publicvoidonConnectionFailed(...);
publicvoidonResponse(...);// = Unicast
...
...
@@ -177,6 +187,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
* GET the `/.well-known/core` resource (it is generated automatically by the server)
* GET the `/.well-known/core` resource using multicast (aka. Multicast Discovery)
* Multicast Adresses: `CoapConstants.COAP_ALL_NODES_IPV4_MC_ADDR`, `CoapConstants.COAP_ALL_NODES_IPV6_LL_MC_ADDR` and `CoapConstants.COAP_ALL_NODES_IPV6_SL_MC_ADDR`
```java
// add a (mandatory) token to match outgoing multicast message and incoming unicast messages
request.setToken("MCToken".getBytes());
...
...
@@ -191,11 +202,13 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
1. Use the eventing mechanism CoAP-Observe (Server.java, TODO 10):
* Mark the TemperatureResource as observable
```java
resource.setObservable(true);
```
2. Let server notify clients every 5 s about changed TemperatureResource (Server.java, TODO 11):
* indicate a change for resource every 5 seconds
```java
while(true){
try{Thread.sleep(5000);}
...
...
@@ -206,26 +219,31 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
3. Implement an Air Conditioner Resource with the path `/ACControl`, that can be set to `high`, `medium`, `low` or `off` (Client.java & Server.java, TODO 12-15):
* Change exitAfterResponse to false (Client.java, TODO 12)
* Add the observe-option to your CoAP-GET request (Client.java, TODO 13)
```java
request.setObserveOption(0);
```
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 14)