Commit bbb07b38 authored by Björn Butzin's avatar Björn Butzin
Browse files

Updated ToDo numbering and README respectively

parent cdbb839b
......@@ -101,27 +101,27 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
CoapData get(List<String> query, List<CoapMediaType> mediaTypesAccepted);
```
#### 2. Instantiate a new ResourceServer (Server.java, FIXME 0):
#### 2. Instantiate a new ResourceServer (Server.java, FIXME 1.1):
* Need a CoapResourceServer to maintain resources
```java
CoapResourceServer resourceServer = new CoapResourceServer();
```
#### 3. Instantiate a new TemperatureResource (Server.java, FIXME 1):
#### 3. Instantiate a new TemperatureResource (Server.java, FIXME 1.2):
* Resources are created like normal objects
```java
CoapResource resource = new CoapResource();
```
#### 4. Add the TemperatureResource to the ResourceServer (Server.java, FIXME 2):
#### 4. Add the TemperatureResource to the ResourceServer (Server.java, FIXME 1.3):
```java
resourceServer.createResource(resource);
```
#### 5. Start the ResourceServer (Server.java FIXME 3):
#### 5. Start the ResourceServer (Server.java FIXME 1.4):
```java
resourceServer.start(port);
......@@ -143,7 +143,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
4. Wait for CoapResponse & Print the CoapResponse on the console (already done in our example)
5. Test
#### 1. Establish a connection to the Server using the ChannelManager (Client.java, FIXME 4-5):
#### 1. Establish a connection to the Server using the ChannelManager (Client.java, FIXME 2.1 & 2.2):
* A client must implement CoapClient interface
```java
......@@ -156,7 +156,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
clientChannel = channelManager.connect(CoapClient client,InetAddress serverIP, int serverPort);
```
#### 2. Create a CoapRequest & add some Options (Client.java, FIXME 6-8):
#### 2. Create a CoapRequest & add some Options (Client.java, FIXME 2.3 - 2.5):
* A channel represents a single connection and is used to create and send requests
```java
......@@ -166,7 +166,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
request.setUriPath("/temperature");
```
#### 3. Send the CoapRequest (Client.java, FIXME 9):
#### 3. Send the CoapRequest (Client.java, FIXME 2.6):
```java
clientChannel.sendMessage(request);
......@@ -207,13 +207,13 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
![Task 2 - Sequence diagram](https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap/raw/master/ws4d-jcoap-handsOn/img/Task2Sequence.png)
### 1. Use the eventing mechanism CoAP-Observe (Server.java, TODO 10):
### 1. Use the eventing mechanism CoAP-Observe (Server.java, TODO 3.1):
* Mark the TemperatureResource as observable
```java
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 3.2):
* indicate a change for resource every 5 seconds
```java
......@@ -223,19 +223,19 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn
resource.changed(); // Notify
}
```
### 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)
### 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 4.1 - 5.2):
* Change exitAfterResponse to false (Client.java, TODO 4.1)
* Add the observe-option to your CoAP-GET request (Client.java, TODO 4.2)
```java
request.setObserveOption(0);
```
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 14)
* add a BasicCoapResource to the ResourceServer (Server.java, TODO 5.1)
```java
resourceServer.createResource(newBasicCoapResource("/ACControl","off",CoapMediaType.text_plain));
```
* send PUT request (Client.java, TODO 15)
* send PUT request (Client.java, TODO 5.2)
```java
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT);
......
......@@ -14,8 +14,8 @@ import org.ws4d.coap.core.messages.api.CoapResponse;
public class Client implements CoapClient {
// TODO 12: Skip for now! In the 2nd step we change this to false.
/** should program terminate after the first response? */
// TODO 4.1: Skip for now! In the 2nd step we change this to false.
/** Shall the program terminate after the first response? */
private boolean exitAfterResponse = true;
/** A manager to keep track of our connections */
......@@ -27,13 +27,13 @@ public class Client implements CoapClient {
/** The method containing the creation of our requests */
public void start(String serverAddress, int serverPort) {
/* FIXME 4: Get the ChannelManager instance */
/* FIXME 2.1: Get the ChannelManager instance */
// this.channelManager = BasicCoapChannelManager.getInstance();
this.clientChannel = null;
try {
/* FIXME 5: Create a channel to the server */
/* FIXME 2.2: Create a channel to the server */
// this.clientChannel = this.channelManager.connect(this, InetAddress.getByName(serverAddress), serverPort);
/* Make sure that the channel is not null */
......@@ -48,19 +48,19 @@ public class Client implements CoapClient {
/* Create an request and prepare parameters */
/* FIXME 6: What kind of request do we want to send? */
/* FIXME 2.3: What kind of request do we want to send? */
// CoapRequestCode requestCode = CoapRequestCode.<CTRL><SPACE>;
// do we want an acknowledgement?
boolean reliable = true;
/* FIXME 7: Create the request */
/* FIXME 2.4: Create the request */
// CoapRequest request = this.clientChannel.createRequest(reliable, requestCode);
/* FIXME 8: Set the resource path */
/* FIXME 2.5: Set the resource path */
// request.setUriPath(???);
/* TODO 13: Skip for now! In the 2nd step we add the observe option here
/* TODO 4.2: Skip for now! In the 2nd step we add the observe option here
* Tip: the Parameter sequenceNumber is recommended to be 0
* */
// request.set<CTRL><SPACE>;
......@@ -72,7 +72,7 @@ public class Client implements CoapClient {
// request.addAccept(CoapMediaType.text_plain); // only accept certain media types as response; you can add multiple
// request.setProxyUri(proxyUri); // send this request through a proxy
/* FIXME 9: Send your message */
/* FIXME 2.6: Send your message */
// this.clientChannel.sendMessage(request);
}
......@@ -90,7 +90,7 @@ public class Client implements CoapClient {
public void onResponse(CoapClientChannel channel, CoapResponse response) {
// We just print out the response
if (response.getPayload() != null) {
/* TODO 15: Skip for now! In the 3rd step we replace this behavior.*/
/* TODO 5.2: Skip for now! In the 3rd step we replace this behavior.*/
System.out.println("Response: " + response.toString() + " Payload: " + new String(response.getPayload()));
} else {
System.out.println("Response: " + response.toString());
......
......@@ -15,30 +15,30 @@ public class Server {
if (this.resourceServer != null){
this.resourceServer.stop();
}
/* FIXME 0: Instantiate a new CoapResourceServer */
/* FIXME 1.1: Instantiate a new CoapResourceServer */
// this.resourceServer = new CoapResourceServer();
/* FIXME 1: Instantiate a TemperatureResource */
/* FIXME 1.2: Instantiate a TemperatureResource */
// TemperatureResource resource = new TemperatureResource();
/* TODO 10: Skip for now! In the 2nd step we will make this resource observable right here */
/* TODO 3.1: Skip for now! In the 2nd step we will make this resource observable right here */
// resource.set<CTRL><SPACE>;
/* FIXME 2: Add our resource to the server */
/* FIXME 1.3: Add our resource to the server */
// this.resourceServer.createResource(resource);
/* TODO 14: Skip for now! In the 3rd step we will add another resource here*/
/* TODO 5.1: Skip for now! In the 3rd step we will add another resource here*/
// this.resourceServer.createResource( new BasicCoapResource("/ACControl","off",CoapMediaType.text_plain));
/* this starts the server */
try {
/* FIXME 3: determine port to run */
/* FIXME 1.4: determine port to run */
// this.resourceServer.start(CoapConstants.COAP_DEFAULT_PORT);
} catch (Exception e) {
System.err.println(e.getLocalizedMessage());
}
/* TODO 11: Skip for now! In the 2nd step we will notify about a changed resource right here */
/* TODO 3.2: Skip for now! In the 2nd step we will notify about a changed resource right here */
// while(true){
// try {Thread.sleep(5000);}
// catch (InterruptedException e) {/*do nothing*/}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment