Add ENERGEST, RIMESTATS, COMPOWER to status page
This commit is contained in:
parent
a2073db715
commit
dd71927576
|
@ -524,14 +524,14 @@ static unsigned short
|
||||||
generate_sensor_readings(void *arg)
|
generate_sensor_readings(void *arg)
|
||||||
{
|
{
|
||||||
uint16_t numprinted;
|
uint16_t numprinted;
|
||||||
uint16_t h,m,s;
|
uint16_t days,h,m,s;
|
||||||
unsigned long seconds=clock_seconds();
|
unsigned long seconds=clock_seconds();
|
||||||
// uint8_t p1;
|
|
||||||
static const char httpd_cgi_sensor0[] HTTPD_STRING_ATTR = "[Updated %d seconds ago]<br><br>";
|
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_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_sensor2[] HTTPD_STRING_ATTR = "<em>Battery:</em> %s<br>";
|
||||||
// static const char httpd_cgi_sensr12[] HTTPD_STRING_ATTR = "<em>Temperature:</em> %s <em>Battery:</em> %s<br>";
|
// 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>Elapsed timer :</em> %02d:%02d:%02d<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_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
|
// static const char httpd_cgi_sensor4[] HTTPD_STRING_ATTR = "<em>Sleeping time :</em> %02d:%02d:%02d (%d%%)<br>";
|
||||||
|
|
||||||
numprinted=0;
|
numprinted=0;
|
||||||
|
@ -554,33 +554,97 @@ generate_sensor_readings(void *arg)
|
||||||
|
|
||||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
|
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor2, sensor_extvoltage);
|
||||||
// numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensr12, sensor_temperature,sensor_extvoltage);
|
// numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensr12, sensor_temperature,sensor_extvoltage);
|
||||||
|
|
||||||
#if RADIOSTATS
|
#if RADIOSTATS
|
||||||
/* Remember radioontime for display below - slow connection might make it report longer than cpu ontime! */
|
/* Remember radioontime for display below - slow connection might make it report longer than cpu ontime! */
|
||||||
savedradioontime = radioontime;
|
savedradioontime = radioontime;
|
||||||
#endif
|
#endif
|
||||||
h=seconds/3600;
|
h=seconds/3600;s=seconds-h*3600;m=s/60;s=s-m*60;
|
||||||
s=seconds-h*3600;
|
days=h/24;
|
||||||
m=s/60;
|
if (days == 0) {
|
||||||
s=s-m*60;
|
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3, h,m,s);
|
||||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3, h,m,s);
|
} else {
|
||||||
|
h=h-days*24;
|
||||||
/* TODO: some gcc's have a bug with %02d format that adds a zero byte and extra chars to the end of the string.
|
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor3d, days,h,m,s);
|
||||||
|
}
|
||||||
|
/* TODO: some gcc's have a bug with %02d format that adds an extra char after the string terminator.
|
||||||
* Seen with arm-none-eabi-gcc.exe (Sourcery G++ Lite 2008q3-66) 4.3.2
|
* Seen with arm-none-eabi-gcc.exe (Sourcery G++ Lite 2008q3-66) 4.3.2
|
||||||
* Quick cosmetic fix to strip that off: */
|
* Quick cosmetic fix to strip that off: */
|
||||||
if (*(char *)(uip_appdata + numprinted-3)==0) {numprinted-=3;}
|
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-2)==0) {numprinted-=2;}
|
||||||
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (sleepseconds) {
|
if (sleepseconds) {
|
||||||
p1=100UL*sleepseconds/seconds;
|
uint8_t p1;
|
||||||
h=sleepseconds/3600;
|
p1=100UL*sleepseconds/seconds;h=sleepseconds/3600;s=sleepseconds-h*3600;m=s/60;s=s-m*60;
|
||||||
s=sleepseconds-h*3600;
|
|
||||||
m=s/60;
|
|
||||||
s=s-m*60;
|
|
||||||
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor4, h,m,s,p1);
|
numprinted+=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_sensor4, h,m,s,p1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENERGEST_CONF_ON
|
||||||
|
{uint8_t p1,p2;
|
||||||
|
#if 0
|
||||||
|
/* Update all the timers to get current values */
|
||||||
|
for (p1=1;p1<ENERGEST_TYPE_MAX;p1++) {
|
||||||
|
if (energest_current_mode[p1]) {
|
||||||
|
ENERGEST_OFF(p1);
|
||||||
|
ENERGEST_ON(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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;
|
||||||
|
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;
|
||||||
|
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;}
|
||||||
|
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||||
|
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||||
|
}
|
||||||
|
#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>";
|
||||||
|
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;}
|
||||||
|
else if (*(char *)(uip_appdata + numprinted-2)==0) {numprinted-=2;}
|
||||||
|
else if (*(char *)(uip_appdata + numprinted-1)==0) {numprinted-=1;}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return numprinted;
|
return numprinted;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue