Add optional build without internal webserver

This commit is contained in:
dak664 2011-03-13 11:59:17 -04:00
parent a883c9bcbc
commit 14246ef811
2 changed files with 26 additions and 11 deletions

View File

@ -5,10 +5,17 @@ CONTIKI=../../..
WITH_UIP6=1
UIP_CONF_IPV6=1
APPS += webserver
#Override inclusion of internal webserver with make WITH_WEBSERVER=0
WITH_WEBSERVER=1
ifeq ($(WITH_WEBSERVER), 0)
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += slip-bridge.c
else
APPS += webserver
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -DWEBSERVER
PROJECT_SOURCEFILES += slip-bridge.c httpd-simple.c
endif
include $(CONTIKI)/Makefile.include

View File

@ -45,11 +45,13 @@
#include "net/netstack.h"
#include "dev/button-sensor.h"
#include "dev/slip.h"
#define INTERNAL_WEBSERVER 1
#if INTERNAL_WEBSERVER
/* 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 <stdlib.h>
#include <string.h>
@ -68,7 +70,8 @@ static uint8_t prefix_set;
PROCESS(border_router_process, "Border router process");
AUTOSTART_PROCESSES(&border_router_process);
#if INTERNAL_WEBSERVER
#if WEBSERVER
/*---------------------------------------------------------------------------*/
/* Only one single web request at time */
static const char *TOP = "<html><head><title>ContikiRPL</title></head><body>\n";
@ -155,6 +158,9 @@ httpd_simple_get_script(const char *name)
{
return generate_routes;
}
#endif /* WEBSERVER */
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
@ -162,18 +168,17 @@ print_local_addresses(void)
int i;
uint8_t state;
PRINTF("Server IPv6 addresses:\n");
PRINTA("Server IPv6 addresses:\n");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
blen = 0;
ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF(" %s\n", buf);
PRINTA(" ");
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
PRINTA("\n");
}
}
}
#endif /* INTERNAL_WEBSERVER */
/*---------------------------------------------------------------------------*/
void
request_prefix(void)
@ -206,9 +211,11 @@ PROCESS_THREAD(border_router_process, ev, data)
prefix_set = 0;
PROCESS_PAUSE();
#if INTERNAL_WEBSERVER
#if WEBSERVER
process_start(&webserver_nogui_process, NULL);
#endif
SENSORS_ACTIVATE(button_sensor);
PRINTF("RPL-Border router started\n");
@ -225,7 +232,8 @@ PROCESS_THREAD(border_router_process, ev, data)
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
#if INTERNAL_WEBSERVER
#if DEBUG || 1
print_local_addresses();
#endif