Add PAGETITLE option to webserver-nano, compress status page white space.

This commit is contained in:
David Kopf 2012-02-21 11:19:25 -05:00
parent deb75d3d97
commit ea3d427c33
4 changed files with 64 additions and 25 deletions

View file

@ -30,7 +30,6 @@
*
*
*/
/* Line endings in git repository are LF instead of CR-LF ? */
/*
* This file includes functions that are called by the web server
* scripts. The functions takes no argument, and the return value is
@ -185,19 +184,38 @@ static unsigned short
generate_header(void *arg)
{
unsigned short numprinted=0;
#if WEBSERVER_CONF_HEADER_W3C
#define _MSS1 100
static const char httpd_cgi_headerw[] HTTPD_STRING_ATTR = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_headerw);
#endif
#if WEBSERVER_CONF_HEADER_ICON
#define _MSS2 105
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>Contiki-nano</title><link rel=\"icon\" href=\"favicon.gif\" type=\"image/gif\"></head><body>";
#ifdef WEBSERVER_CONF_PAGETITLE
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>%s</title><link rel=\"icon\" href=\"favicon.gif\" type=\"image/gif\"></head><body>";
#else
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>Contiki-Nano</title><link rel=\"icon\" href=\"favicon.gif\" type=\"image/gif\"></head><body>";
#endif
#else
#define _MSS2 52
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>Contiki-nano</title></head><body>";
#ifdef WEBSERVER_CONF_PAGETITLE
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>%s</title></head><body>";
#else
static const char httpd_cgi_header1[] HTTPD_STRING_ATTR = "<html><head><title>Contiki-Nano</title></head><body>";
#endif
#endif
#ifdef WEBSERVER_CONF_PAGETITLE
#define WAD ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])->destipaddr.u8
{ char buf[40];
WEBSERVER_CONF_PAGETITLE;
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_header1,buf);
}
#else
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_header1);
#endif
#if WEBSERVER_CONF_HEADER_MENU
#define _MSS3 32
@ -538,7 +556,7 @@ generate_sensor_readings(void *arg)
static const char httpd_cgi_sensor2[] HTTPD_STRING_ATTR = "<em>Battery :</em> %s\n";
// static const char httpd_cgi_sensr12[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s <em>Battery:</em> %s<br>";
static const char httpd_cgi_sensor3[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %02d:%02d:%02d\n";
static const char httpd_cgi_sensor3d[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %u days %02u:%02u:%02u/n";
static const char httpd_cgi_sensor3d[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %u days %02u:%02u:%02u\n";
// static const char httpd_cgi_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
numprinted=0;
@ -624,7 +642,17 @@ uint8_t c;
numprinted =httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_sensor0,(unsigned int) (seconds-last_tempupdate));
}
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor1, sensor_temperature);
#if CONTIKI_TARGET_REDBEE_ECONOTAG
/* Econotag at 3v55 with 10 ohms to LiFePO4 battery: 3680mv usb 3106 battery (meter 3.08). Take 3500 as breakpoint for USB connected */
static const char httpd_cgi_sensor2u[] HTTPD_STRING_ATTR = "<em>Vcc (USB) :</em> %s\n";
if(adc_reading[8]<1404) {
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2u, sensor_extvoltage);
} else {
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
}
#else
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
#endif
// numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensr12, sensor_temperature,sensor_extvoltage);
#if RADIOSTATS

View file

@ -1,10 +1,10 @@
%! header
<h4>Addresses</h4>
<p>Addresses<br>
%! addresses
<h4>Neighbors</h4>
<p>Neighbors<br>
%! neighbors
<h4>Routes</h4>
<p>Routes<br>
%! routes
<h4>Sensors</h4>
<p>Sensors<br>
%! sensors
%! file-stats .

View file

@ -1,4 +1,4 @@
/*********Generated by contiki/tools/makefsdata on 2011-09-10*********/
/*********Generated by contiki/tools/makefsdata on 2012-02-21*********/
const char data_404_html[86] HTTPD_STRING_ATTR = {
@ -48,24 +48,23 @@ const char data_index_shtml[120] HTTPD_STRING_ATTR = {
0x21, 0x0a, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2e};
const char data_status_shtml[158] HTTPD_STRING_ATTR = {
const char data_status_shtml[150] HTTPD_STRING_ATTR = {
/* /status.shtml */
0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00,
0x25, 0x21, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a,
0x3c, 0x68, 0x34, 0x3e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73,
0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e, 0x0a, 0x25,
0x21, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65,
0x73, 0x0a, 0x3c, 0x68, 0x34, 0x3e, 0x4e, 0x65, 0x69, 0x67,
0x68, 0x62, 0x6f, 0x72, 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e,
0x0a, 0x25, 0x21, 0x20, 0x6e, 0x65, 0x69, 0x67, 0x68, 0x62,
0x6f, 0x72, 0x73, 0x0a, 0x3c, 0x68, 0x34, 0x3e, 0x52, 0x6f,
0x75, 0x74, 0x65, 0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e, 0x0a,
0x25, 0x21, 0x20, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x0a,
0x3c, 0x68, 0x34, 0x3e, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72,
0x73, 0x3c, 0x2f, 0x68, 0x34, 0x3e, 0x0a, 0x25, 0x21, 0x20,
0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0a, 0x25, 0x21,
0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74,
0x73, 0x20, 0x2e, 0x0a};
0x3c, 0x70, 0x3e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
0x65, 0x73, 0x3c, 0x62, 0x72, 0x3e, 0x0a, 0x25, 0x21, 0x20,
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x0a,
0x3c, 0x70, 0x3e, 0x4e, 0x65, 0x69, 0x67, 0x68, 0x62, 0x6f,
0x72, 0x73, 0x3c, 0x62, 0x72, 0x3e, 0x0a, 0x25, 0x21, 0x20,
0x6e, 0x65, 0x69, 0x67, 0x68, 0x62, 0x6f, 0x72, 0x73, 0x0a,
0x3c, 0x70, 0x3e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x3c,
0x62, 0x72, 0x3e, 0x0a, 0x25, 0x21, 0x20, 0x72, 0x6f, 0x75,
0x74, 0x65, 0x73, 0x0a, 0x3c, 0x70, 0x3e, 0x53, 0x65, 0x6e,
0x73, 0x6f, 0x72, 0x73, 0x3c, 0x62, 0x72, 0x3e, 0x0a, 0x25,
0x21, 0x20, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0a,
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
0x61, 0x74, 0x73, 0x20, 0x2e, 0x0a};
const char data_tcp_shtml[227] HTTPD_STRING_ATTR = {
/* /tcp.shtml */
@ -113,4 +112,4 @@ const struct httpd_fsdata_file file_tcp_shtml[] HTTPD_STRING_ATTR ={{ fi
#define HTTPD_FS_ROOT file_tcp_shtml
#define HTTPD_FS_NUMFILES 5
#define HTTPD_FS_SIZE 759
#define HTTPD_FS_SIZE 751

View file

@ -49,6 +49,18 @@
* The advertised MSS is easily seen in wireshark.
* Some example set a small MSS by default. rpl-border-router for example uses a receive window of 60.
*/
/* Titles of web pages served with the !header cgi can be configured to show characteristics of the node.
* For example "CD1A:3456" to show the node id and clock time of last access.
* Change this line and rebuild to make indentifiable instances.
* Undefine to reduce program size, giving "Contiki-Nano" title on all pages.
* WAD indexes into the uip destaddr field, which contains the address that we responded to.
*/
#define WEBSERVER_CONF_PAGETITLE sprintf(buf,"[%02x%02x]",WAD[14],WAD[15]);
//#define WEBSERVER_CONF_PAGETITLE sprintf(buf,"Nano[%02x%02x%02x]",WAD[13],WAD[14],WAD[15]);
//#define WEBSERVER_CONF_PAGETITLE sprintf(buf,"Nano[%02x%02x...%02x%02x]",WAD[0],WAD[1],WAD[14],WAD[15]);
//#define WEBSERVER_CONF_PAGETITLE sprintf(buf,"%2x%02x...%2x%02x [%lu]",WAD[0],WAD[1],WAD[14],WAD[15],clock_seconds());
#ifndef WEBSERVER_CONF_NANO
#if CONTIKI_TARGET_SKY || CONTIKI_TARGET_STK500
#define WEBSERVER_CONF_NANO 1