Clean-up and fix for rest-server-example.

This commit is contained in:
Matthias Kovatsch 2012-03-29 18:05:07 +02:00
parent 3b2fe65c66
commit ed92994784
6 changed files with 13 additions and 13 deletions

View file

@ -60,6 +60,9 @@ LIST(observers_list);
coap_observer_t *
coap_add_observer(uip_ipaddr_t *addr, uint16_t port, const uint8_t *token, size_t token_len, const char *url)
{
/* Remove existing observe relationship, if any. */
coap_remove_observer_by_url(addr, port, url);
coap_observer_t *o = memb_alloc(&observers_memb);
if (o)

View file

@ -54,7 +54,7 @@
#endif
/*----------------------------------------------------------------------------*/
int
void
coap_separate_reject()
{
coap_error_code = SERVICE_UNAVAILABLE_5_03;

View file

@ -59,7 +59,7 @@ typedef struct coap_separate {
} coap_separate_t;
int coap_separate_handler(resource_t *resource, void *request, void *response);
int coap_separate_reject();
void coap_separate_reject();
int coap_separate_accept(void *request, coap_separate_t *separate_store);
void coap_separate_resume(void *response, coap_separate_t *separate_store, uint8_t code);

View file

@ -269,8 +269,8 @@ resource_t resource_##name = {NULL, flags, url, attributes, parent##_handler, NU
*/
#define EVENT_RESOURCE(name, flags, url, attributes) \
void name##_handler(void *, void *, uint8_t *, uint16_t, int32_t *); \
resource_t resource_##name = {NULL, flags, url, attributes, name##_handler, NULL, NULL, NULL}; \
int name##_event_handler(resource_t*)
void name##_event_handler(resource_t*); \
resource_t resource_##name = {NULL, flags, url, attributes, name##_handler, NULL, NULL, NULL}
/*
* Macro to define a periodic resource

View file

@ -5,8 +5,10 @@ CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
# for static routing, if enabled
ifneq ($(TARGET), minimal-net)
ifneq ($(TARGET), native)
PROJECT_SOURCEFILES += static-routing.c
endif
endif
# variable for root Makefile.include
WITH_UIP6=1
@ -25,7 +27,7 @@ else
${info INFO: compiling without RPL}
UIP_CONF_RPL=0
CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0
CFLAGS += -DHARD_CODED_ADDRESS=\"2001:620:8:1010::10\"
CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\"
CFLAGS += -DUIP_CONF_BUFFER_SIZE=1280
endif
@ -37,13 +39,11 @@ ifeq ($(WITH_COAP), 7)
${info INFO: compiling with CoAP-07}
CFLAGS += -DWITH_COAP=7
CFLAGS += -DREST=coap_rest_implementation
CFLAGS += -DUIP_CONF_TCP=0
APPS += er-coap-07
else ifeq ($(WITH_COAP), 3)
${info INFO: compiling with CoAP-03}
CFLAGS += -DWITH_COAP=3
CFLAGS += -DREST=coap_rest_implementation
CFLAGS += -DUIP_CONF_TCP=0
APPS += er-coap-03
else
${info INFO: compiling with HTTP}

View file

@ -381,16 +381,14 @@ separate_handler(void* request, void* response, uint8_t *buffer, uint16_t prefer
*/
if (separate_active)
{
REST.set_response_status(response, REST.status.SERVICE_UNAVAILABLE);
const char *msg = "AlreadyInUse";
REST.set_response_payload(response, msg, strlen(msg));
coap_separate_reject();
}
else
{
separate_active = 1;
/* Take over and skip response by engine. */
coap_separate_yield(request, &separate_store->request_metadata);
coap_separate_accept(request, &separate_store->request_metadata);
/* Be aware to respect the Block2 option, which is also stored in the coap_separate_t. */
/*
@ -710,8 +708,7 @@ PROCESS_THREAD(rest_server_example, ev, data)
rest_activate_event_resource(&resource_event);
#endif
#if defined (PLATFORM_HAS_BUTTON) && REST_RES_SEPARATE && WITH_COAP > 3
/* Use this pre-handler for separate response resources. */
rest_set_pre_handler(&resource_separate, coap_separate_handler);
/* No pre-handler anymore, user coap_separate_accept() and coap_separate_reject(). */
rest_activate_resource(&resource_separate);
#endif
#if defined (PLATFORM_HAS_BUTTON) && (REST_RES_EVENT || (REST_RES_SEPARATE && WITH_COAP > 3))