... | @@ -24,10 +24,10 @@ The following points will be covered by this tutorial: |
... | @@ -24,10 +24,10 @@ The following points will be covered by this tutorial: |
|
|
|
|
|
## 2. Introduction of jCoAP
|
|
## 2. Introduction of jCoAP
|
|
- WS4D-jCoAP: Java implementation of CoAP
|
|
- WS4D-jCoAP: Java implementation of CoAP
|
|
-- http://ws4d.org/
|
|
- http://ws4d.org/
|
|
-- https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap
|
|
- https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap
|
|
|
|
|
|
• Task 1 – Sequence Diagram
|
|
### Task 1 – Sequence Diagram
|
|
|
|
|
|
Server Side
|
|
Server Side
|
|
|
|
|
... | @@ -89,22 +89,22 @@ Client Side |
... | @@ -89,22 +89,22 @@ Client Side |
|
1. Create a new resource class TemperatureResource (TemperatureResource.java):
|
|
1. Create a new resource class TemperatureResource (TemperatureResource.java):
|
|
* We could have used the predefined BasicCoapResource
|
|
* We could have used the predefined BasicCoapResource
|
|
* BasicCoapResource is a resource that just keeps a static `byte[ ]` that is:
|
|
* BasicCoapResource is a resource that just keeps a static `byte[ ]` that is:
|
|
** returned on GET requests
|
|
* returned on GET requests
|
|
** replaced by the payload on PUT requests
|
|
* replaced by the payload on PUT requests
|
|
** appended with the payload on POST requests
|
|
* appended with the payload on POST requests
|
|
** deleted on DELETE requests
|
|
* deleted on DELETE requests
|
|
** We do not want a static `byte[ ]`
|
|
* We do not want a static `byte[ ]`
|
|
* Instead we want a random number to be returned on a GET
|
|
* Instead we want a random number to be returned on a GET
|
|
* PUT, POST and DELETE are not used
|
|
* PUT, POST and DELETE are not used
|
|
* ->So we implemented TemperatureResource wich extends BasicCoapResource with:
|
|
* ->So we implemented TemperatureResource wich extends BasicCoapResource with:
|
|
** A constructor
|
|
* A constructor
|
|
*** To initialize the resource
|
|
* To initialize the resource
|
|
*** Disallow POST, PUT and DELETE
|
|
* Disallow POST, PUT and DELETE
|
|
** 2 get() Methods
|
|
* 2 get() Methods
|
|
*** Get a list of accepted media types [& query parameters]
|
|
* Get a list of accepted media types [& query parameters]
|
|
*** Returns a `byte[ ]` together with its media type
|
|
* Returns a `byte[ ]` together with its media type
|
|
** And the `getResourceType()` method
|
|
* And the `getResourceType()` method
|
|
*** Wich returns a description string of the resource
|
|
* Wich returns a description string of the resource
|
|
2. Instantiate a new ResourceServer (Server.java, FIXME 1):
|
|
2. Instantiate a new ResourceServer (Server.java, FIXME 1):
|
|
* Need a CoapResourceServer to maintain resources
|
|
* Need a CoapResourceServer to maintain resources
|
|
`CoapResourceServer resourceServer = new CoapResourceServer();`
|
|
`CoapResourceServer resourceServer = new CoapResourceServer();`
|
... | | ... | |