mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-05 12:29:38 +00:00
Better formatting of webserver-nano status page
This commit is contained in:
parent
cf61e522a8
commit
ccd866cdd4
@ -527,11 +527,11 @@ generate_sensor_readings(void *arg)
|
||||
uint16_t days,h,m,s;
|
||||
unsigned long seconds=clock_seconds();
|
||||
static const char httpd_cgi_sensor0[] HTTPD_STRING_ATTR = "[Updated %d seconds ago]<br><br>";
|
||||
static const char httpd_cgi_sensor1[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s<br>";
|
||||
static const char httpd_cgi_sensor2[] HTTPD_STRING_ATTR = "<em>Battery:</em> %s<br>";
|
||||
static const char httpd_cgi_sensor1[] HTTPD_STRING_ATTR = "<pre><em>Temperature:</em> %s\n";
|
||||
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<br>";
|
||||
static const char httpd_cgi_sensor3d[] HTTPD_STRING_ATTR = "<em>Uptime :</em> %u days %02u:%02u:%02u<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_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
|
||||
|
||||
numprinted=0;
|
||||
@ -595,17 +595,20 @@ generate_sensor_readings(void *arg)
|
||||
#else
|
||||
energest_flush();
|
||||
#endif
|
||||
static const char httpd_cgi_sensor10[] HTTPD_STRING_ATTR = "<em>Radio (ENERGEST) :</em> Tx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor11[] HTTPD_STRING_ATTR = "Tx %02u:%02u:%02u (%u.%02u%%)<br>";
|
||||
s=energest_total_time[ENERGEST_TYPE_LISTEN].current/RTIMER_ARCH_SECOND;
|
||||
h=s*10000/seconds;p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
|
||||
static const char httpd_cgi_sensor10[] HTTPD_STRING_ATTR = "<em>Radio (ENERGEST):</em> Tx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor11[] HTTPD_STRING_ATTR = "Rx %02u:%02u:%02u (%u.%02u%%)\n";
|
||||
s=energest_total_time[ENERGEST_TYPE_TRANSMIT].current/RTIMER_ARCH_SECOND;
|
||||
h=((10000UL*energest_total_time[ENERGEST_TYPE_TRANSMIT].current)/RTIMER_ARCH_SECOND)/seconds;
|
||||
p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor10, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
s=energest_total_time[ENERGEST_TYPE_TRANSMIT].current/RTIMER_ARCH_SECOND;
|
||||
h=s*10000/seconds;p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
s=energest_total_time[ENERGEST_TYPE_LISTEN].current/RTIMER_ARCH_SECOND;
|
||||
h=((10000UL*energest_total_time[ENERGEST_TYPE_LISTEN].current)/RTIMER_ARCH_SECOND)/seconds;
|
||||
p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor11, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
@ -614,29 +617,24 @@ generate_sensor_readings(void *arg)
|
||||
}
|
||||
#endif /* ENERGEST_CONF_ON */
|
||||
|
||||
#if RIMESTATS_CONF_ON
|
||||
#include "net/rime/rimestats.h"
|
||||
static const char httpd_cgi_sensor21[] HTTPD_STRING_ATTR = "<em>Packets (RIMESTATS) :</em> Tx=%5lu Rx=%5lu TxL=%5lu RxL=%5lu<br>";
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor21,
|
||||
rimestats.tx,rimestats.rx,rimestats.lltx-rimestats.tx,rimestats.llrx-rimestats.rx);
|
||||
#endif
|
||||
|
||||
#if CONTIKIMAC_CONF_COMPOWER
|
||||
#include "sys/compower.h"
|
||||
{uint8_t p1,p2;
|
||||
extern struct compower_activity current_packet;
|
||||
static const char httpd_cgi_sensor31[] HTTPD_STRING_ATTR = "<em>ContikiMAC (COMPOWER):</em> Idle Rx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor32[] HTTPD_STRING_ATTR = "Tx %02u:%02u:%02u (%u.%0u%%)<br>";
|
||||
// extern struct compower_activity current_packet;
|
||||
static const char httpd_cgi_sensor31[] HTTPD_STRING_ATTR = "<em>ContikiMAC (COMPOWER):</em> Tx %02u:%02u:%02u (%u.%02u%%) ";
|
||||
static const char httpd_cgi_sensor32[] HTTPD_STRING_ATTR = "Rx %02u:%02u:%02u (%u.%02u%%)\n";
|
||||
|
||||
s=100UL*compower_idle_activity.listen/RTIMER_ARCH_SECOND;
|
||||
h=s*100/seconds;p1=h/100;p2=h-p1*100;s/=100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
s=compower_idle_activity.transmit/RTIMER_ARCH_SECOND;
|
||||
h=((10000UL*compower_idle_activity.transmit)/RTIMER_ARCH_SECOND)/seconds;
|
||||
p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor31, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||
s=100UL*compower_idle_activity.transmit/RTIMER_ARCH_SECOND;
|
||||
h=s*100/seconds;p1=h/100;p2=h-p1*100;s/=100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
s=compower_idle_activity.listen/RTIMER_ARCH_SECOND;
|
||||
h=((10000UL*compower_idle_activity.listen)/RTIMER_ARCH_SECOND)/seconds;
|
||||
p1=h/100;p2=h-p1*100;h=s/3600;s=s-h*3600;m=s/60;s=s-m*60;
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor32, h,m,s,p1,p2);
|
||||
if (*(char *)(uip_appdata + numprinted-4)==0) {numprinted-=4;}
|
||||
else if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
||||
@ -645,6 +643,15 @@ generate_sensor_readings(void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if RIMESTATS_CONF_ON
|
||||
#include "net/rime/rimestats.h"
|
||||
static const char httpd_cgi_sensor21[] HTTPD_STRING_ATTR = "<em>Packets (RIMESTATS):</em> Tx=%5lu Rx=%5lu TxL=%4lu RxL=%4lu\n";
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor21,
|
||||
rimestats.tx,rimestats.rx,rimestats.lltx-rimestats.tx,rimestats.llrx-rimestats.rx);
|
||||
#endif
|
||||
static const char httpd_cgi_sensor99[] HTTPD_STRING_ATTR = "</pre>";
|
||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor99);
|
||||
|
||||
return numprinted;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user