Changes for minimal-net and bug fix for buffer handling.

This commit is contained in:
dogan yazar 2011-04-12 00:09:15 +02:00
parent b19fb0ac9e
commit 91dd236c55
6 changed files with 35 additions and 22 deletions

View File

@ -12,7 +12,7 @@
#include "dev/leds.h" #include "dev/leds.h"
#if !UIP_CONF_IPV6_RPL #if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET)
#include "static-routing.h" #include "static-routing.h"
#endif #endif
@ -491,10 +491,10 @@ PROCESS_THREAD(coap_server, ev, data)
PRINTF("COAP SERVER\n"); PRINTF("COAP SERVER\n");
/* if static routes are used rather than RPL */ /* 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(); set_global_address();
configure_routing(); configure_routing();
#endif /*!UIP_CONF_IPV6_RPL*/ #endif
current_tid = random_rand(); current_tid = random_rand();

View File

@ -19,6 +19,7 @@ delete_buffer(void)
{ {
if (data_buffer) { if (data_buffer) {
free(data_buffer); free(data_buffer);
data_buffer = NULL;
buffer_index = 0; buffer_index = 0;
buffer_size = 0; buffer_size = 0;
} }

View File

@ -7,6 +7,8 @@
#include "static-routing.h" #include "static-routing.h"
#if !defined (CONTIKI_TARGET_MINIMAL_NET) /* Any other targets will be added here (&& ! defined (OTHER))*/
#define DEBUG 0 #define DEBUG 0
#if DEBUG #if DEBUG
#include <stdio.h> #include <stdio.h>
@ -66,3 +68,4 @@ void configure_routing(void)
} }
} }
#endif /*!UIP_CONF_IPV6_RPL*/ #endif /*!UIP_CONF_IPV6_RPL*/
#endif /*CONTIKI_TARGET_MINIMAL_NET*/

View File

@ -8,6 +8,7 @@
#ifndef STATICROUTING_H_ #ifndef STATICROUTING_H_
#define STATICROUTING_H_ #define STATICROUTING_H_
#if !defined (CONTIKI_TARGET_MINIMAL_NET)
#define NODE_IP(nodeid,type,ipaddr) NODE_##nodeid##_##type(ipaddr) #define NODE_IP(nodeid,type,ipaddr) NODE_##nodeid##_##type(ipaddr)
/*desktop machine*/ /*desktop machine*/
@ -56,4 +57,5 @@ do{\
void set_global_address(void); void set_global_address(void);
void configure_routing(void); void configure_routing(void);
#endif /*CONTIKI_TARGET_MINIMAL_NET*/
#endif /* STATICROUTING_H_ */ #endif /* STATICROUTING_H_ */

View File

@ -7,7 +7,7 @@
#include "buffer.h" #include "buffer.h"
#include "rest-util.h" #include "rest-util.h"
#if !UIP_CONF_IPV6_RPL #if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET)
#include "static-routing.h" #include "static-routing.h"
#endif #endif
@ -586,7 +586,7 @@ PROCESS_THREAD(http_server, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
/* if static routes are used rather than RPL */ /* 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(); set_global_address();
configure_routing(); configure_routing();
#endif /*!UIP_CONF_IPV6_RPL*/ #endif /*!UIP_CONF_IPV6_RPL*/

View File

@ -5,10 +5,12 @@
#include "contiki-net.h" #include "contiki-net.h"
#include "rest.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/light-sensor.h"
#include "dev/battery-sensor.h" #include "dev/battery-sensor.h"
#include "dev/sht11-sensor.h" #include "dev/sht11-sensor.h"
#include "dev/leds.h" #include "dev/leds.h"
#endif /*defined (CONTIKI_TARGET_SKY)*/
#define DEBUG 1 #define DEBUG 1
#if DEBUG #if DEBUG
@ -36,9 +38,24 @@ helloworld_handler(REQUEST* request, RESPONSE* response)
sprintf(temp,"Hello World!\n"); sprintf(temp,"Hello World!\n");
rest_set_header_content_type(response, TEXT_PLAIN); 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,", "</helloworld>;n=\"HelloWorld\"");
index += sprintf(temp + index, "%s,", "</led>;n=\"LedControl\"");
index += sprintf(temp + index, "%s", "</light>;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*/ /*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"); RESOURCE(led, METHOD_POST | METHOD_PUT , "led");
@ -120,20 +137,8 @@ toggle_handler(REQUEST* request, RESPONSE* response)
{ {
leds_toggle(LEDS_RED); 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,", "</helloworld>;n=\"HelloWorld\"");
index += sprintf(temp + index, "%s,", "</led>;n=\"LedControl\"");
index += sprintf(temp + index, "%s", "</light>;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"); PROCESS(rest_server_example, "Rest Server Example");
AUTOSTART_PROCESSES(&rest_server_example); AUTOSTART_PROCESSES(&rest_server_example);
@ -148,14 +153,16 @@ PROCESS_THREAD(rest_server_example, ev, data)
PRINTF("HTTP Server\n"); PRINTF("HTTP Server\n");
#endif #endif
SENSORS_ACTIVATE(light_sensor);
rest_init(); 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_led);
rest_activate_resource(&resource_light); rest_activate_resource(&resource_light);
rest_activate_resource(&resource_toggle); rest_activate_resource(&resource_toggle);
#endif /*defined (CONTIKI_TARGET_SKY)*/
rest_activate_resource(&resource_helloworld);
rest_activate_resource(&resource_discover); rest_activate_resource(&resource_discover);
PROCESS_END(); PROCESS_END();