Changes for minimal-net and bug fix for buffer handling.
This commit is contained in:
parent
b19fb0ac9e
commit
91dd236c55
@ -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();
|
||||
|
||||
|
@ -19,6 +19,7 @@ delete_buffer(void)
|
||||
{
|
||||
if (data_buffer) {
|
||||
free(data_buffer);
|
||||
data_buffer = NULL;
|
||||
buffer_index = 0;
|
||||
buffer_size = 0;
|
||||
}
|
||||
|
@ -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 <stdio.h>
|
||||
@ -66,3 +68,4 @@ void configure_routing(void)
|
||||
}
|
||||
}
|
||||
#endif /*!UIP_CONF_IPV6_RPL*/
|
||||
#endif /*CONTIKI_TARGET_MINIMAL_NET*/
|
||||
|
@ -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_ */
|
||||
|
@ -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*/
|
||||
|
@ -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,", "</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*/
|
||||
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,", "</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");
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user