From c46acc0a77301183d46f72f65638cdd4917b9fec Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Sep 2011 00:25:20 +0200 Subject: [PATCH] Updated for the latest version of httpd-simple in rpl-border-router --- examples/ipv6/sky-websense/Makefile | 2 +- examples/ipv6/sky-websense/project-conf.h | 6 +++- examples/ipv6/sky-websense/sky-websense.c | 17 +++++++++-- examples/ipv6/sky-websense/websense-remote.c | 17 +++++++++-- examples/ipv6/sky-websense/wget.c | 31 ++++++++++++++++++++ 5 files changed, 65 insertions(+), 8 deletions(-) diff --git a/examples/ipv6/sky-websense/Makefile b/examples/ipv6/sky-websense/Makefile index 6be80c822..09d80ce32 100644 --- a/examples/ipv6/sky-websense/Makefile +++ b/examples/ipv6/sky-websense/Makefile @@ -6,7 +6,7 @@ WITH_UIP6=1 UIP_CONF_IPV6=1 CFLAGS+= -DUIP_CONF_IPV6_RPL -APPS += webserver webbrowser +APPS += webbrowser CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" CONTIKI_SOURCEFILES += wget.c diff --git a/examples/ipv6/sky-websense/project-conf.h b/examples/ipv6/sky-websense/project-conf.h index ecfad3a69..4a9a8ee8d 100644 --- a/examples/ipv6/sky-websense/project-conf.h +++ b/examples/ipv6/sky-websense/project-conf.h @@ -33,7 +33,7 @@ #define __PROJECT_RPL_WEB_CONF_H__ #undef QUEUEBUF_CONF_NUM -#define QUEUEBUF_CONF_NUM 6 +#define QUEUEBUF_CONF_NUM 5 #undef UIP_CONF_BUFFER_SIZE #define UIP_CONF_BUFFER_SIZE 140 @@ -44,4 +44,8 @@ #undef WEBSERVER_CONF_CFS_CONNS #define WEBSERVER_CONF_CFS_CONNS 2 +/* Reserve space for a file name (default is to not use file name) */ +#undef WEBSERVER_CONF_CFS_PATHLEN +#define WEBSERVER_CONF_CFS_PATHLEN 80 + #endif /* __PROJECT_RPL_WEB_CONF_H__ */ diff --git a/examples/ipv6/sky-websense/sky-websense.c b/examples/ipv6/sky-websense/sky-websense.c index 33c06c129..30abba271 100644 --- a/examples/ipv6/sky-websense/sky-websense.c +++ b/examples/ipv6/sky-websense/sky-websense.c @@ -40,15 +40,27 @@ #include "contiki.h" #include "httpd-simple.h" -#include "webserver-nogui.h" #include "dev/sht11-sensor.h" #include "dev/light-sensor.h" #include "dev/leds.h" #include PROCESS(web_sense_process, "Sense Web Demo"); +PROCESS(webserver_nogui_process, "Web server"); +PROCESS_THREAD(webserver_nogui_process, ev, data) +{ + PROCESS_BEGIN(); -AUTOSTART_PROCESSES(&web_sense_process); + httpd_init(); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); + httpd_appcall(data); + } + + PROCESS_END(); +} +AUTOSTART_PROCESSES(&web_sense_process,&webserver_nogui_process); #define HISTORY 16 static int temperature[HISTORY]; @@ -148,7 +160,6 @@ PROCESS_THREAD(web_sense_process, ev, data) PROCESS_BEGIN(); sensors_pos = 0; - process_start(&webserver_nogui_process, NULL); etimer_set(&timer, CLOCK_SECOND * 2); SENSORS_ACTIVATE(light_sensor); diff --git a/examples/ipv6/sky-websense/websense-remote.c b/examples/ipv6/sky-websense/websense-remote.c index a30da909f..50ac8f7cf 100644 --- a/examples/ipv6/sky-websense/websense-remote.c +++ b/examples/ipv6/sky-websense/websense-remote.c @@ -41,7 +41,6 @@ #include "dev/button-sensor.h" #include "dev/leds.h" #include "wget.h" -#include "webserver-nogui.h" #include "httpd-simple.h" #include @@ -59,8 +58,21 @@ #define SET_LEDS_OFF "/0" PROCESS(websense_remote_process, "Websense Remote"); +PROCESS(webserver_nogui_process, "Web server"); +PROCESS_THREAD(webserver_nogui_process, ev, data) +{ + PROCESS_BEGIN(); -AUTOSTART_PROCESSES(&websense_remote_process); + httpd_init(); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); + httpd_appcall(data); + } + + PROCESS_END(); +} +AUTOSTART_PROCESSES(&websense_remote_process,&webserver_nogui_process); /*---------------------------------------------------------------------------*/ static const char *TOP = "Contiki Websense Remote\n"; @@ -141,7 +153,6 @@ PROCESS_THREAD(websense_remote_process, ev, data) mode = 0; wget_init(); - process_start(&webserver_nogui_process, NULL); SENSORS_ACTIVATE(button_sensor); diff --git a/examples/ipv6/sky-websense/wget.c b/examples/ipv6/sky-websense/wget.c index cf28758a1..c8668a897 100644 --- a/examples/ipv6/sky-websense/wget.c +++ b/examples/ipv6/sky-websense/wget.c @@ -68,6 +68,37 @@ static const char *file; static uint16_t port; static const struct wget_callbacks *callbacks; +const char http_10[9] = +/* "HTTP/1.0" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, }; +const char http_11[9] = +/* "HTTP/1.1" */ +{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, }; +const char http_200[5] = +/* "200 " */ +{0x32, 0x30, 0x30, 0x20, }; +const char http_301[5] = +/* "301 " */ +{0x33, 0x30, 0x31, 0x20, }; +const char http_302[5] = +/* "302 " */ +{0x33, 0x30, 0x32, 0x20, }; +const char http_crnl[3] = +/* "\r\n" */ +{0xd, 0xa, }; +const char http_host[7] = +/* "host: " */ +{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, }; +const char http_content_type[15] = +/* "content-type: " */ +{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, }; +const char http_location[11] = +/* "location: " */ +{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, }; +const char http_http[8] = +/* "http://" */ +{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, }; + PROCESS(wget_process, "wget"); /*---------------------------------------------------------------------------*/