Made Erbium function parameters const where applicable.\nMinor clean-up.
This commit is contained in:
parent
0a4c77dbff
commit
4c3e858df5
10 changed files with 99 additions and 116 deletions
|
@ -14,7 +14,7 @@ WITH_UIP6=1
|
|||
UIP_CONF_IPV6=1
|
||||
|
||||
# variable for this Makefile
|
||||
# configure CoAP implementation (3|6|7)
|
||||
# configure CoAP implementation (3|7)
|
||||
WITH_COAP=7
|
||||
|
||||
# must be CFLAGS not variables
|
||||
|
@ -33,12 +33,6 @@ CFLAGS += -DWITH_COAP=7
|
|||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-07
|
||||
else ifeq ($(WITH_COAP), 6)
|
||||
${info INFO: compiling with CoAP-06}
|
||||
CFLAGS += -DWITH_COAP=6
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-06
|
||||
else ifeq ($(WITH_COAP), 3)
|
||||
${info INFO: compiling with CoAP-03}
|
||||
CFLAGS += -DWITH_COAP=3
|
||||
|
@ -50,7 +44,7 @@ ${info INFO: compiling with HTTP}
|
|||
CFLAGS += -DWITH_HTTP
|
||||
CFLAGS += -DREST=http_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=1
|
||||
APPS += rest-http-engine
|
||||
APPS += er-http-engine
|
||||
endif
|
||||
|
||||
APPS += erbium
|
||||
|
|
|
@ -8,12 +8,16 @@ coap-client-example.c: A CoAP client that polls the /toggle resource every 10 se
|
|||
|
||||
PRELIMINARIES
|
||||
-------------
|
||||
a) For convenience, define the Cooja addresses in /etc/hosts
|
||||
a) Make sure rpl-border-router has the same stack and fits into mote memory, e.g.:
|
||||
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
|
||||
...
|
||||
b) Get the Copper CoAP browser from https://addons.mozilla.org/en-US/firefox/addon/copper-270430/
|
||||
c) Optional: Save Tmotes as default target
|
||||
c) Get the Copper CoAP browser from https://addons.mozilla.org/en-US/firefox/addon/copper-270430/
|
||||
d) Optional: Save Tmotes as default target
|
||||
$ make TARGET=sky savetarget
|
||||
|
||||
COOJA HOWTO
|
||||
|
@ -26,8 +30,10 @@ Server only:
|
|||
|
||||
With client:
|
||||
1) $ make TARGET=cooja coap-client-server-example.csc
|
||||
2) Wait until red LED toggles on mote 2 (server)
|
||||
3) Choose "Click button on Sky 3" from the context menu of mote 3 (client) and watch serial output
|
||||
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
|
||||
------------
|
||||
|
@ -50,7 +56,7 @@ Add a client:
|
|||
|
||||
DETAILS
|
||||
-------
|
||||
The Erbium CoAP currently implements draft 07.
|
||||
The Erbium CoAP currently implements draft 08.
|
||||
Central features are commented in rest-server-example.c.
|
||||
In general, apps/er-coap-07 supports:
|
||||
* All CoAP-07 header options
|
||||
|
@ -60,6 +66,15 @@ In general, apps/er-coap-07 supports:
|
|||
* 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.
|
||||
* 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)
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
/* Must be <= open transaction number. */
|
||||
#ifndef COAP_MAX_OBSERVERS
|
||||
#define COAP_MAX_OBSERVERS COAP_MAX_OPEN_TRANSACTIONS
|
||||
#define COAP_MAX_OBSERVERS COAP_MAX_OPEN_TRANSACTIONS-1
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -84,8 +84,6 @@
|
|||
/* For CoAP-specific example: not required for normal RESTful Web service. */
|
||||
#if WITH_COAP == 3
|
||||
#include "er-coap-03.h"
|
||||
#elif WITH_COAP == 6
|
||||
#include "er-coap-06.h"
|
||||
#elif WITH_COAP == 7
|
||||
#include "er-coap-07.h"
|
||||
#else
|
||||
|
@ -227,7 +225,7 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
|||
{
|
||||
strpos += snprintf((char *)buffer+strpos, REST_MAX_CHUNK_SIZE-strpos+1, "Bl %lu%s (%u)\n", block_num, block_more ? "+" : "", block_size);
|
||||
}
|
||||
#elif WITH_COAP >= 5
|
||||
#else
|
||||
if (strpos<=REST_MAX_CHUNK_SIZE && (len = coap_get_header_location_path(request, &str)))
|
||||
{
|
||||
strpos += snprintf((char *)buffer+strpos, REST_MAX_CHUNK_SIZE-strpos+1, "LP %.*s\n", len, str);
|
||||
|
@ -240,15 +238,15 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
|||
{
|
||||
strpos += snprintf((char *)buffer+strpos, REST_MAX_CHUNK_SIZE-strpos+1, "B2 %lu%s (%u)\n", block_num, block_more ? "+" : "", block_size);
|
||||
}
|
||||
if (strpos<=REST_MAX_CHUNK_SIZE && coap_get_header_block1(request, &block_num, &block_more, &block_size, NULL)) /* This getter allows NULL pointers to get only a subset of the block parameters. */
|
||||
/*
|
||||
* Critical Block1 option is currently rejected by engine.
|
||||
*
|
||||
if (strpos<=REST_MAX_CHUNK_SIZE && coap_get_header_block1(request, &block_num, &block_more, &block_size, NULL))
|
||||
{
|
||||
strpos += snprintf((char *)buffer+strpos, REST_MAX_CHUNK_SIZE-strpos+1, "B1 %lu%s (%u)\n", block_num, block_more ? "+" : "", block_size);
|
||||
}
|
||||
#if WITH_COAP >= 7
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
*/
|
||||
#endif /* CoAP > 03 */
|
||||
#endif /* CoAP-specific example */
|
||||
|
||||
if (strpos<=REST_MAX_CHUNK_SIZE && (len = REST.get_query(request, &query)))
|
||||
|
@ -281,16 +279,13 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
|||
coap_set_header_observe(response, 10);
|
||||
#if WITH_COAP == 3
|
||||
coap_set_header_block(response, 42, 0, 64); /* The block option might be overwritten by the framework when blockwise transfer is requested. */
|
||||
#elif WITH_COAP >= 5
|
||||
#else
|
||||
coap_set_header_proxy_uri(response, "ftp://x");
|
||||
coap_set_header_block2(response, 42, 0, 64); /* The block option might be overwritten by the framework when blockwise transfer is requested. */
|
||||
coap_set_header_block1(response, 23, 0, 16);
|
||||
#if WITH_COAP >= 7
|
||||
coap_set_header_accept(response, TEXT_PLAIN);
|
||||
coap_set_header_if_none_match(response);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* CoAP > 03 */
|
||||
#endif /* CoAP-specific example */
|
||||
}
|
||||
#endif /* REST_RES_MIRROR */
|
||||
|
@ -497,7 +492,7 @@ light_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred
|
|||
uint16_t light_photosynthetic = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
|
||||
uint16_t light_solar = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
|
||||
|
||||
uint16_t *accept = NULL;
|
||||
const uint16_t *accept = NULL;
|
||||
int num = REST.get_header_accept(request, &accept);
|
||||
|
||||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
||||
|
@ -537,7 +532,7 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
|
|||
{
|
||||
int battery = battery_sensor.value(0);
|
||||
|
||||
uint16_t *accept = NULL;
|
||||
const uint16_t *accept = NULL;
|
||||
int num = REST.get_header_accept(request, &accept);
|
||||
|
||||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue