Free internal webserver from dependency on /apps/webserver.
Allow choice of webservers with makefile switch.
This commit is contained in:
parent
577215deca
commit
e4257647cd
2 changed files with 41 additions and 22 deletions
|
@ -6,16 +6,23 @@ WITH_UIP6=1
|
||||||
UIP_CONF_IPV6=1
|
UIP_CONF_IPV6=1
|
||||||
CFLAGS+= -DUIP_CONF_IPV6_RPL
|
CFLAGS+= -DUIP_CONF_IPV6_RPL
|
||||||
|
|
||||||
#Override inclusion of internal webserver with make WITH_WEBSERVER=0
|
|
||||||
WITH_WEBSERVER=1
|
|
||||||
|
|
||||||
ifeq ($(WITH_WEBSERVER), 0)
|
|
||||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||||
PROJECT_SOURCEFILES += slip-bridge.c
|
PROJECT_SOURCEFILES += slip-bridge.c
|
||||||
else
|
|
||||||
APPS += webserver
|
#Simple built-in webserver is the default.
|
||||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -DWEBSERVER
|
#Override with make WITH_WEBSERVER=0 for no webserver.
|
||||||
PROJECT_SOURCEFILES += slip-bridge.c httpd-simple.c
|
#WITH_WEBSERVER=webserver-name will use /apps/webserver-name if it can be
|
||||||
|
#found in the /apps, /platform/$(TARGET)/apps/, or current directory (in that order).
|
||||||
|
# WITH_WEBSERVER=webserver for /apps/webserver
|
||||||
|
# WITH_WEBSERVER=raven-webserver for /platform/avr-raven/apps/raven-webserver/
|
||||||
|
#make clean before changing webservers!
|
||||||
|
WITH_WEBSERVER=1
|
||||||
|
ifeq ($(WITH_WEBSERVER),1)
|
||||||
|
CFLAGS += -DWEBSERVER=1
|
||||||
|
PROJECT_SOURCEFILES += httpd-simple.c
|
||||||
|
else ifneq ($(WITH_WEBSERVER), 0)
|
||||||
|
APPS += $(WITH_WEBSERVER)
|
||||||
|
CFLAGS += -DWEBSERVER=2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(CONTIKI)/Makefile.include
|
include $(CONTIKI)/Makefile.include
|
||||||
|
|
|
@ -46,12 +46,6 @@
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
#include "dev/slip.h"
|
#include "dev/slip.h"
|
||||||
|
|
||||||
/* For internal webserver Makefile must set APPS += webserver and PROJECT_SOURCEFILES += httpd-simple.c */
|
|
||||||
#if WEBSERVER
|
|
||||||
#include "webserver-nogui.h"
|
|
||||||
#include "httpd-simple.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -69,11 +63,33 @@ static uip_ipaddr_t prefix;
|
||||||
static uint8_t prefix_set;
|
static uint8_t prefix_set;
|
||||||
|
|
||||||
PROCESS(border_router_process, "Border router process");
|
PROCESS(border_router_process, "Border router process");
|
||||||
AUTOSTART_PROCESSES(&border_router_process);
|
|
||||||
|
|
||||||
#if WEBSERVER
|
#if WEBSERVER==0
|
||||||
/*---------------------------------------------------------------------------*/
|
/* No webserver */
|
||||||
/* Only one single web request at time */
|
AUTOSTART_PROCESSES(&border_router_process);
|
||||||
|
#elif WEBSERVER>1
|
||||||
|
/* Use an external webserver application */
|
||||||
|
#include "webserver-nogui.h"
|
||||||
|
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
|
||||||
|
#else
|
||||||
|
/* Use simple webserver with only one page */
|
||||||
|
#include "httpd-simple.h"
|
||||||
|
PROCESS(webserver_nogui_process, "Web server");
|
||||||
|
PROCESS_THREAD(webserver_nogui_process, ev, data)
|
||||||
|
{
|
||||||
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
httpd_init();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
|
||||||
|
httpd_appcall(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PROCESS_END();
|
||||||
|
}
|
||||||
|
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
|
||||||
|
|
||||||
static const char *TOP = "<html><head><title>ContikiRPL</title></head><body>\n";
|
static const char *TOP = "<html><head><title>ContikiRPL</title></head><body>\n";
|
||||||
static const char *BOTTOM = "</body></html>\n";
|
static const char *BOTTOM = "</body></html>\n";
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
@ -212,10 +228,6 @@ PROCESS_THREAD(border_router_process, ev, data)
|
||||||
|
|
||||||
PROCESS_PAUSE();
|
PROCESS_PAUSE();
|
||||||
|
|
||||||
#if WEBSERVER
|
|
||||||
process_start(&webserver_nogui_process, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SENSORS_ACTIVATE(button_sensor);
|
SENSORS_ACTIVATE(button_sensor);
|
||||||
|
|
||||||
PRINTF("RPL-Border router started\n");
|
PRINTF("RPL-Border router started\n");
|
||||||
|
|
Loading…
Reference in a new issue