... | ... | @@ -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 1):
|
|
|
#### 2. Instantiate a new ResourceServer (Server.java, FIXME 0):
|
|
|
* Need a CoapResourceServer to maintain resources
|
|
|
|
|
|
```java
|
|
|
CoapResourceServer resourceServer = new CoapResourceServer();
|
|
|
```
|
|
|
|
|
|
#### 3. Instantiate a new TemperatureResource (Server.java, FIXME 2):
|
|
|
#### 3. Instantiate a new TemperatureResource (Server.java, FIXME 1):
|
|
|
* Resources are created like normal objects
|
|
|
|
|
|
```java
|
|
|
CoapResource resource = new CoapResource();
|
|
|
```
|
|
|
|
|
|
#### 4. Add the TemperatureResource to the ResourceServer (Server.java, FIXME 3):
|
|
|
#### 4. Add the TemperatureResource to the ResourceServer (Server.java, FIXME 2):
|
|
|
|
|
|
```java
|
|
|
resourceServer.createResource(resource);
|
|
|
```
|
|
|
|
|
|
#### 5. Start the ResourceServer (Server.java FIXME 4):
|
|
|
#### 5. Start the ResourceServer (Server.java FIXME 3):
|
|
|
|
|
|
```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 5-6):
|
|
|
#### 1. Establish a connection to the Server using the ChannelManager (Client.java, FIXME 4-5):
|
|
|
* 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 7-9):
|
|
|
#### 2. Create a CoapRequest & add some Options (Client.java, FIXME 6-8):
|
|
|
* 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 7-9):
|
|
|
#### 3. Send the CoapRequest (Client.java, FIXME 9):
|
|
|
|
|
|
```java
|
|
|
clientChannel.sendMessage(request);
|
... | ... | @@ -220,7 +220,7 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn |
|
|
while (true) {
|
|
|
try {Thread.sleep(5000);}
|
|
|
catch (InterruptedException e) {/*do nothing*/}
|
|
|
resource.changed();
|
|
|
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):
|
... | ... | |