Added an AJAX-style web server app that continously updates a web page with data from the Tmote Sky on-board sensors
This commit is contained in:
parent
e04e49999d
commit
10f3964be1
10 changed files with 818 additions and 2 deletions
8
examples/sky-ip/httpd-fs/404.html
Normal file
8
examples/sky-ip/httpd-fs/404.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body bgcolor="white">
|
||||
<center>
|
||||
<h1>404 - file not found</h1>
|
||||
<h3>Go <a href="/">here</a> instead.</h3>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
3
examples/sky-ip/httpd-fs/footer.html
Normal file
3
examples/sky-ip/httpd-fs/footer.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
</table>
|
||||
</body>
|
||||
</html>
|
12
examples/sky-ip/httpd-fs/header.html
Normal file
12
examples/sky-ip/httpd-fs/header.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Contiki</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<table border=0 cellpadding=4 cellspacing=4><tr><td valign="top" align="right">
|
||||
<h1>Contiki </h1>
|
||||
<a href="/">Front page</a><br>
|
||||
<a href="neighbors.shtml">Neighbors</a><br>
|
||||
<a href="sensors.shtml">Sensors</a><br>
|
||||
</td><td valign="top" align="left">
|
15
examples/sky-ip/httpd-fs/index.html
Normal file
15
examples/sky-ip/httpd-fs/index.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Contiki</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<table border=0 cellpadding=4 cellspacing=4><tr><td valign="top" align="right">
|
||||
<h1>Contiki </h1>
|
||||
<a href="/">Front page</a><br>
|
||||
<a href="neighbors.shtml">Neighbors</a><br>
|
||||
<a href="sensors.shtml">Sensors</a><br>
|
||||
</td><td valign="top" align="left">
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
10
examples/sky-ip/httpd-fs/neighbors.shtml
Normal file
10
examples/sky-ip/httpd-fs/neighbors.shtml
Normal file
|
@ -0,0 +1,10 @@
|
|||
%!: /header.html
|
||||
<h1>Node
|
||||
%! nodeid
|
||||
</h1>
|
||||
<h2>Neighbors</h2>
|
||||
<ul>
|
||||
%! neighbors
|
||||
</ul>
|
||||
%!: /footer.html
|
||||
|
78
examples/sky-ip/httpd-fs/sensors.shtml
Normal file
78
examples/sky-ip/httpd-fs/sensors.shtml
Normal file
|
@ -0,0 +1,78 @@
|
|||
%!: /header.html
|
||||
<script type="text/javascript">
|
||||
function e(el) {
|
||||
d = document;
|
||||
if(d.getElementById) {
|
||||
return d.getElementById(el);
|
||||
} else if (d.all) {
|
||||
return d.all[el];
|
||||
}
|
||||
}
|
||||
function s(el,n,max,text) {
|
||||
e(el).innerHTML = '<table width=504 border=0 cellpadding=1 cellspacing=0>'+
|
||||
'<tr><td width=200>' +
|
||||
text + '</td>' +
|
||||
'<td width=' + (300*n/max) + ' bgcolor="gray"> </td>' +
|
||||
'<td width=' + (300-300*n/max) + ' bgcolor="lightgray"> </td>' +
|
||||
'</table>';
|
||||
}
|
||||
function dc(n,d) {
|
||||
return n.toFixed(d);
|
||||
}
|
||||
function t(m) {
|
||||
n = dc(-39.6+0.01*m, 1);
|
||||
s('temp',n,40,'Temperature '+n+' °C');
|
||||
}
|
||||
function h(m) {
|
||||
n = dc(-4+0.0405*m - 2.8e-6*(m*m), 2);
|
||||
s('hum',n,100,'Humidity '+n+'%');
|
||||
}
|
||||
function l1(m) {
|
||||
n = dc(.7629394375*m, 0);
|
||||
s('l1',n,200,'Light 1 '+n);
|
||||
}
|
||||
function l2(m) {
|
||||
n = dc(.4693603*m, 0);
|
||||
s('l2',n,200,'Light 2 '+n);
|
||||
}
|
||||
function rs(m) {
|
||||
n = m + 45;
|
||||
s('rs',n,100,'RSSI '+n);
|
||||
}
|
||||
function p(c,l,t,r) {
|
||||
tm=c+l;
|
||||
cp=c*1.8/tm;
|
||||
lp=l*0.0545/tm;
|
||||
lt=t*17.7/tm;
|
||||
lr=r*20/tm;
|
||||
n=cp+lp+lt+lr;
|
||||
s('p',n,30,'Power consumption '+dc(n,2)+' mW');
|
||||
s('pc',cp,30,'CPU power '+dc(cp,2)+' mW');
|
||||
s('pl',lp,30,'LPM power '+dc(lp,2)+' mW');
|
||||
s('pr',lr,30,'Radio RX power '+dc(lr,2)+' mW');
|
||||
s('pt',lt,30,'Radio TX power '+dc(lt,2)+' mW');
|
||||
}
|
||||
function i(n) {
|
||||
e('i').innerHTML = n;
|
||||
}
|
||||
</script>
|
||||
<h1>Node
|
||||
%! nodeid
|
||||
</h1>
|
||||
<h2>Environment</h2>
|
||||
<div id="temp"></div>
|
||||
<div id="hum"></div>
|
||||
<h2>Light</h2>
|
||||
<div id="l1"></div>
|
||||
<div id="l2"></div>
|
||||
<h2>Power</h2>
|
||||
<div id="p"></div>
|
||||
<div id="pc"></div>
|
||||
<div id="pl"></div>
|
||||
<div id="pr"></div>
|
||||
<div id="pt"></div>
|
||||
<br><br>
|
||||
<div id="i">0</div>
|
||||
%!: /footer.html
|
||||
%! sensors
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue