Added more details to README and small printing modification in client example.
This commit is contained in:
parent
726f927c40
commit
d14e8996ab
2 changed files with 9 additions and 6 deletions
|
@ -4,6 +4,8 @@ MAIN EXAMPLE:
|
||||||
rest-server-example.c : A RESTful server example showing how to use the REST layer to develop server-side applications (possible to run it over either COAP or HTTP)
|
rest-server-example.c : A RESTful server example showing how to use the REST layer to develop server-side applications (possible to run it over either COAP or HTTP)
|
||||||
To use COAP as the underlying application protocol, one should define WITH_COAP = 1 in rest-example/Makefile. Otherwise, HTTP is used.
|
To use COAP as the underlying application protocol, one should define WITH_COAP = 1 in rest-example/Makefile. Otherwise, HTTP is used.
|
||||||
Look at the source code to see which resources are available. (check the RESOURCE macros in the code).
|
Look at the source code to see which resources are available. (check the RESOURCE macros in the code).
|
||||||
|
Each resource has a handler function which is called by the REST layer to serve the request.
|
||||||
|
(i.e. "helloworld" resource has a handler function named "helloworld_handler" which is called when a web service request is received for "helloworld" resource.)
|
||||||
|
|
||||||
|
|
||||||
To run REST examples in COOJA under Linux
|
To run REST examples in COOJA under Linux
|
||||||
|
@ -12,11 +14,11 @@ To run REST examples in COOJA under Linux
|
||||||
Accessing the server from outside:
|
Accessing the server from outside:
|
||||||
Start COOJA and load the simulation "rest-server-example.csc" by the following command.
|
Start COOJA and load the simulation "rest-server-example.csc" by the following command.
|
||||||
> make TARGET=cooja rest-server-example.csc
|
> make TARGET=cooja rest-server-example.csc
|
||||||
After loading the cooja file, in another terminal connect to the COOJA simulation using tunslip6:
|
After loading the cooja file, open another another terminal pointing to the same directory and connect to the COOJA simulation using tunslip6:
|
||||||
>make connect-router-cooja
|
>make connect-router-cooja
|
||||||
Now you need to use a COAP or HTTP client to interact with the COOJA nodes running REST code.
|
Now you need to use a COAP or HTTP client to interact with the COOJA nodes running REST code.
|
||||||
In this setting, two servers are available:
|
In this setting, two servers are available:
|
||||||
IP addresses are aaaa::0212:7402:0002:0202 and aaaa::0212:7403:0003:0303. COAP uses 61616, whereas HTTP uses 8080 port.
|
IP addresses are aaaa::0212:7402:0002:0202 and aaaa::0212:7403:0003:0303. COAP uses 61616, whereas HTTP uses 8080 port in default configuration.
|
||||||
|
|
||||||
HTTP Examples
|
HTTP Examples
|
||||||
You can use curl as an http client to interact with the COOJA motes running REST code.
|
You can use curl as an http client to interact with the COOJA motes running REST code.
|
||||||
|
@ -30,7 +32,8 @@ Accessing the server inside the sensor network:
|
||||||
(Note: Provided only for COAP implementation)
|
(Note: Provided only for COAP implementation)
|
||||||
Start COOJA and load the simulation "coap-client-server-example.csc" by the following command.
|
Start COOJA and load the simulation "coap-client-server-example.csc" by the following command.
|
||||||
> make TARGET=cooja coap-client-server-example.csc
|
> make TARGET=cooja coap-client-server-example.csc
|
||||||
coap-client-server-example.csc : Runs rest-server-example as the server (over COAP) (IP:aaaa::0212:7401:0001:0101) in one node and coap-client-example as the client (IP: aaaa::0212:7402:0002:0202) in another node.
|
coap-client-server-example.csc : Runs rest-server-example.c as the server (over COAP) (IP:aaaa::0212:7401:0001:0101)
|
||||||
|
in one node and coap-client-example.c as the client (IP: aaaa::0212:7402:0002:0202) in another node.
|
||||||
Client periodically accesses resources of server and prints the payload.
|
Client periodically accesses resources of server and prints the payload.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue