diff --git a/apps/rest-coap/coap-server.c b/apps/rest-coap/coap-server.c index 4b462fbb7..62ff76870 100644 --- a/apps/rest-coap/coap-server.c +++ b/apps/rest-coap/coap-server.c @@ -12,7 +12,7 @@ #include "dev/leds.h" -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) #include "static-routing.h" #endif @@ -491,10 +491,10 @@ PROCESS_THREAD(coap_server, ev, data) PRINTF("COAP SERVER\n"); /* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) set_global_address(); configure_routing(); -#endif /*!UIP_CONF_IPV6_RPL*/ +#endif current_tid = random_rand(); diff --git a/apps/rest-common/buffer.c b/apps/rest-common/buffer.c index 3860027bd..630f21d3e 100644 --- a/apps/rest-common/buffer.c +++ b/apps/rest-common/buffer.c @@ -19,6 +19,7 @@ delete_buffer(void) { if (data_buffer) { free(data_buffer); + data_buffer = NULL; buffer_index = 0; buffer_size = 0; } diff --git a/apps/rest-common/static-routing.c b/apps/rest-common/static-routing.c index 32704dd14..91cff3719 100644 --- a/apps/rest-common/static-routing.c +++ b/apps/rest-common/static-routing.c @@ -7,6 +7,8 @@ #include "static-routing.h" +#if !defined (CONTIKI_TARGET_MINIMAL_NET) /* Any other targets will be added here (&& ! defined (OTHER))*/ + #define DEBUG 0 #if DEBUG #include @@ -66,3 +68,4 @@ void configure_routing(void) } } #endif /*!UIP_CONF_IPV6_RPL*/ +#endif /*CONTIKI_TARGET_MINIMAL_NET*/ diff --git a/apps/rest-common/static-routing.h b/apps/rest-common/static-routing.h index 591e06b81..fc255ba4f 100644 --- a/apps/rest-common/static-routing.h +++ b/apps/rest-common/static-routing.h @@ -8,6 +8,7 @@ #ifndef STATICROUTING_H_ #define STATICROUTING_H_ +#if !defined (CONTIKI_TARGET_MINIMAL_NET) #define NODE_IP(nodeid,type,ipaddr) NODE_##nodeid##_##type(ipaddr) /*desktop machine*/ @@ -56,4 +57,5 @@ do{\ void set_global_address(void); void configure_routing(void); +#endif /*CONTIKI_TARGET_MINIMAL_NET*/ #endif /* STATICROUTING_H_ */ diff --git a/apps/rest-http/http-server.c b/apps/rest-http/http-server.c index 6a361b182..4b84f8923 100644 --- a/apps/rest-http/http-server.c +++ b/apps/rest-http/http-server.c @@ -7,7 +7,7 @@ #include "buffer.h" #include "rest-util.h" -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) #include "static-routing.h" #endif @@ -586,7 +586,7 @@ PROCESS_THREAD(http_server, ev, data) PROCESS_BEGIN(); /* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) set_global_address(); configure_routing(); #endif /*!UIP_CONF_IPV6_RPL*/ diff --git a/examples/rest-example/rest-server-example.c b/examples/rest-example/rest-server-example.c index d4d1018a2..bfc489dfa 100644 --- a/examples/rest-example/rest-server-example.c +++ b/examples/rest-example/rest-server-example.c @@ -5,10 +5,12 @@ #include "contiki-net.h" #include "rest.h" +#if defined (CONTIKI_TARGET_SKY) /* Any other targets will be added here (&& defined (OTHER))*/ #include "dev/light-sensor.h" #include "dev/battery-sensor.h" #include "dev/sht11-sensor.h" #include "dev/leds.h" +#endif /*defined (CONTIKI_TARGET_SKY)*/ #define DEBUG 1 #if DEBUG @@ -36,9 +38,24 @@ helloworld_handler(REQUEST* request, RESPONSE* response) sprintf(temp,"Hello World!\n"); rest_set_header_content_type(response, TEXT_PLAIN); - rest_set_response_payload(response, temp, strlen(temp)); + rest_set_response_payload(response, (uint8_t*)temp, strlen(temp)); } +RESOURCE(discover, METHOD_GET, ".well-known/core"); +void +discover_handler(REQUEST* request, RESPONSE* response) +{ + char temp[100]; + int index = 0; + index += sprintf(temp + index, "%s,", ";n=\"HelloWorld\""); + index += sprintf(temp + index, "%s,", ";n=\"LedControl\""); + index += sprintf(temp + index, "%s", ";n=\"Light\""); + + rest_set_response_payload(response, (uint8_t*)temp, strlen(temp)); + rest_set_header_content_type(response, APPLICATION_LINK_FORMAT); +} + +#if defined (CONTIKI_TARGET_SKY) /*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/ RESOURCE(led, METHOD_POST | METHOD_PUT , "led"); @@ -120,20 +137,8 @@ toggle_handler(REQUEST* request, RESPONSE* response) { leds_toggle(LEDS_RED); } +#endif /*defined (CONTIKI_TARGET_SKY)*/ -RESOURCE(discover, METHOD_GET, ".well-known/core"); -void -discover_handler(REQUEST* request, RESPONSE* response) -{ - char temp[100]; - int index = 0; - index += sprintf(temp + index, "%s,", ";n=\"HelloWorld\""); - index += sprintf(temp + index, "%s,", ";n=\"LedControl\""); - index += sprintf(temp + index, "%s", ";n=\"Light\""); - - rest_set_response_payload(response, temp, strlen(temp)); - rest_set_header_content_type(response, APPLICATION_LINK_FORMAT); -} PROCESS(rest_server_example, "Rest Server Example"); AUTOSTART_PROCESSES(&rest_server_example); @@ -148,14 +153,16 @@ PROCESS_THREAD(rest_server_example, ev, data) PRINTF("HTTP Server\n"); #endif - SENSORS_ACTIVATE(light_sensor); - rest_init(); - rest_activate_resource(&resource_helloworld); +#if defined (CONTIKI_TARGET_SKY) + SENSORS_ACTIVATE(light_sensor); rest_activate_resource(&resource_led); rest_activate_resource(&resource_light); rest_activate_resource(&resource_toggle); +#endif /*defined (CONTIKI_TARGET_SKY)*/ + + rest_activate_resource(&resource_helloworld); rest_activate_resource(&resource_discover); PROCESS_END();