osd-contiki/examples/er-rest-example
2012-03-17 15:32:51 +01:00
..
coap-client-example.c Also excluded platform native from static routing. 2012-03-17 11:47:09 +01:00
coap-client-server-example.csc Added Erbium REST engine with new CoAP implementation 2011-09-14 16:33:01 +02:00
Makefile Made Block1 support dependent on resource handlers.\nAdded flags and target for minimal-net. 2012-03-17 15:32:51 +01:00
project-conf.h Made Erbium function parameters const where applicable.\nMinor clean-up. 2012-01-20 18:30:12 +01:00
README Erbium README update. 2012-01-30 01:41:53 +01:00
rest-server-example.c Also excluded platform native from static routing. 2012-03-17 11:47:09 +01:00
rest-server-example.csc Fixed Erbium example simulation 2011-10-10 14:16:27 +02:00
static-routing.c Converted u8_t to uint8_t and u16_t to uint16_t in the examples directory. 2012-02-21 08:33:25 -05:00
static-routing.h Added Erbium REST engine with new CoAP implementation 2011-09-14 16:33:01 +02:00

This is the new example for the Erbium REST Engine
==================================================

EXAMPLE FILES
-------------
rest-server-example.c: A RESTful server example showing how to use the REST layer to develop server-side applications (at the moment only CoAP is implemented for the REST Engine).
coap-client-example.c: A CoAP client that polls the /toggle resource every 10 seconds and cycles through 4 resources on button press (target address is hard-coded).

PRELIMINARIES
-------------
a) Make sure rpl-border-router has the same stack and fits into mote memory:
   Disable RDC in border-router project-conf.h
   #undef NETSTACK_CONF_RDC
   #define NETSTACK_CONF_RDC     nullrdc_driver
b) For convenience, define the Cooja addresses in /etc/hosts
   aaaa::0212:7401:0001:0101	cooja1
   aaaa::0212:7402:0002:0202	cooja2
   ...
c) Get the Copper CoAP browser from https://addons.mozilla.org/en-US/firefox/addon/copper-270430/
d) Optional: Save your target as default target
   $ make TARGET=sky savetarget

COOJA HOWTO
-----------
Server only:
1) $ make TARGET=cooja rest-server-example.csc
2) Open new terminal
3) $ make connect-router-cooja
4) Start Copper and discover resources at coap://cooja2:5683/

With client:
1) $ make TARGET=cooja coap-client-server-example.csc
2) Open new terminal
3) $ make connect-router-cooja
4) Wait until red LED toggles on mote 2 (server)
5) Choose "Click button on Sky 3" from the context menu of mote 3 (client) and watch serial output

TMOTES HOWTO
------------
Server:
1) Connect two Tmote Skys (check with $ make TARGET=sky sky-motelist)
2) $ make TARGET=sky rest-server-example.upload MOTE=2
3) $ make TARGET=sky login MOTE=2
4) Press reset button, get address, abort with Ctrl+C:
   Line: "Tentative link-local IPv6 address fe80:0000:0000:0000:____:____:____:____"
5) $ cd ../ipv6/rpl-border-router/
6) $ make TARGET=sky border-router.upload MOTE=1
7) $ make connect-router
   For a BR tty other than USB0: $ make connect-router-port PORT=X
8) Start Copper and discover resources at coap://[aaaa::____:____:____:____]:5683/

Add a client:
1) Change the hard-coded server address in coap-client-example.c to aaaa::____:____:____:____
2) Connect a third Tmote Sky
3) $ make TARGET=sky coap-client-example.upload MOTE=3

DETAILS
-------
The Erbium CoAP currently implements draft 08 (name "er-coap-07" stems from last technical draft changes).
Central features are commented in rest-server-example.c.
In general, apps/er-coap-07 supports:
* All draft 08 header options
* CON Retransmissions (note COAP_MAX_OPEN_TRANSACTIONS)
* Blockwise Transfers (note REST_MAX_CHUNK_SIZE)
* Separate Responses (see rest_set_pre_handler() and coap_separate_handler())
* Resource discovery
* Observing Resources (see EVENT_ and PRERIODIC_RESOURCE, note COAP_MAX_OBSERVERS)

REST IMPLEMENTATIONS
--------------------
The Makefile uses WITH_COAP to configure different implementations for the Erbium REST Engine.
* WITH_COAP=7 uses Erbium CoAP 07 apps/er-coap-07/.
  The default port for coap-07 is 5683.
* WITH_COAP=3 uses Erbium CoAP 03 apps/er-coap-03/.
  The default port for coap-03 is 61616.
  er-coap-03 produces some warnings, as it not fully maintained anymore.
* WITH_COAP=0 is a stub to link an Erbium HTTP engine that uses the same resource abstraction (REST.x() functions and RESOURCE macros. 

TODOs
-----
* Blockwise uploads (for POST/PUT payload)
* Multiple If-Match ETags
* (Message deduplication)