Changes
Page history
bjoern.butzin created page: home
authored
Sep 08, 2016
by
Björn Butzin
Hide whitespace changes
Inline
Side-by-side
home.markdown
View page @
57aed26b
...
@@ -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
...
@@ -46,18 +46,18 @@ Client Side
...
@@ -46,18 +46,18 @@ Client Side
-CoapClient (interface):describes interfaces that must be supported by a client
-CoapClient (interface):describes interfaces that must be supported by a client
*
ToDo on server side:
*
ToDo on server side:
1.
Create a new resource class TemperatureResource
1.
Create a new resource class TemperatureResource
2.
Instantiate a new ResourceServer
2.
Instantiate a new ResourceServer
3.
Instantiate a new TemperatureResource
3.
Instantiate a new TemperatureResource
4.
Add the TemperatureResource to the ResourceServer
4.
Add the TemperatureResource to the ResourceServer
5.
Run the ResourceServer
5.
Run the ResourceServer
*
ToDo on client side:
*
ToDo on client side:
1.
Establish a connection to the Server using the ChannelManager
1.
Establish a connection to the Server using the ChannelManager
2.
Create a CoapRequest & add some Options
2.
Create a CoapRequest & add some Options
3.
Send the CoapRequest
3.
Send the CoapRequest
4.
Wait for CoapResponse
4.
Wait for CoapResponse
5.
Print the CoapResponse on the console
5.
Print the CoapResponse on the console
## 3. Import of prepared project into Eclipse
## 3. Import of prepared project into Eclipse
...
@@ -87,30 +87,30 @@ Client Side
...
@@ -87,30 +87,30 @@ Client Side
5.
Run the ResourceServer
5.
Run the ResourceServer
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();`
3.
Instantiate a new TemperatureResource (Server.java, FIXME 2):
3.
Instantiate a new TemperatureResource (Server.java, FIXME 2):
*
Resources are created like normal objects and added to the server
*
Resources are created like normal objects and added to the server
`CoapResource resource = new CoapResource();`
`CoapResource resource = new CoapResource();`
*
Use the „Tasks“ view of Eclipse to find the right places
*
Use the „Tasks“ view of Eclipse to find the right places
*
Solve only FIXME 1-3 as described by the following instructions - ignore other FIXMEs or TODOs
*
Solve only FIXME 1-3 as described by the following instructions - ignore other FIXMEs or TODOs
...
...
...
...