... | ... | @@ -82,8 +82,8 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn |
|
|
5. Run the ResourceServer
|
|
|
|
|
|
#### 1. Create a new resource class TemperatureResource (TemperatureResource.java):
|
|
|
* We could have used the predefined BasicCoapResource
|
|
|
* BasicCoapResource is a resource that just keeps a static `byte[]` which is:
|
|
|
* We could have used the predefined `BasicCoapResource`
|
|
|
* `BasicCoapResource` is a resource that just keeps a static `byte[]` which is:
|
|
|
* returned on GET requests
|
|
|
* replaced by the payload on PUT requests
|
|
|
* appended with the payload on POST requests
|
... | ... | @@ -91,11 +91,11 @@ You can find the required files in our repository at [https://gitlab.amd.e-techn |
|
|
* We do not want a static `byte[]`
|
|
|
* Instead we want a random number to be returned on a GET
|
|
|
* PUT, POST and DELETE are not used
|
|
|
* ->So we implemented TemperatureResource which extends BasicCoapResource with:
|
|
|
* ->So we implemented `TemperatureResource` which extends `BasicCoapResource` with:
|
|
|
* A constructor to initialize the resource and disallow POST, PUT and DELETE requests
|
|
|
* Two get() Methods:
|
|
|
* Get a list of accepted media types [& query parameters] which returns a `byte[]` together with its media type
|
|
|
```java
|
|
|
```Java
|
|
|
CoapData get(List<CoapMediaType> mediaTypesAccepted)
|
|
|
CoapData get(List<String> query, List<CoapMediaType> mediaTypesAccepted)
|
|
|
```
|
... | ... | |