Added examples for MB851 platform.
This commit is contained in:
parent
9ecc0437f4
commit
a61a9459ea
31 changed files with 1668 additions and 0 deletions
8
examples/mb851/webserver-ajax/httpd-fs/404.html
Normal file
8
examples/mb851/webserver-ajax/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/mb851/webserver-ajax/httpd-fs/footer.html
Normal file
3
examples/mb851/webserver-ajax/httpd-fs/footer.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
</table>
|
||||
</body>
|
||||
</html>
|
12
examples/mb851/webserver-ajax/httpd-fs/header.html
Normal file
12
examples/mb851/webserver-ajax/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" onload="load()">
|
||||
<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/mb851/webserver-ajax/httpd-fs/index.html
Normal file
15
examples/mb851/webserver-ajax/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>
|
49
examples/mb851/webserver-ajax/httpd-fs/neighbors.shtml
Normal file
49
examples/mb851/webserver-ajax/httpd-fs/neighbors.shtml
Normal file
|
@ -0,0 +1,49 @@
|
|||
%!: /header.html
|
||||
<script type="text/javascript">
|
||||
function load() {
|
||||
a=document.anchors;
|
||||
for(i=0; i<a.length;i++){
|
||||
if(a[i].id=='node')
|
||||
a[i].href="http://"+addrgen(a[i].name)+"/"
|
||||
}
|
||||
}
|
||||
function addrgen(iid)
|
||||
{
|
||||
haddr=document.location.host;
|
||||
addr=haddr;
|
||||
ie7ll=0;sep=':';esc='%25';
|
||||
if(addr.search(/ipv6-literal.net/)!=-1){
|
||||
ie7ll=1;sep='-';esc='s';iid=iid.replace(/:/g,'-');
|
||||
}
|
||||
ncol=addr.replace(/ipv6-literal.net/,'').match(/[:-]/g).length;
|
||||
n=0;indtot=0;
|
||||
addr=haddr;
|
||||
while(n<4 && (ind=addr.indexOf(sep))!=-1){
|
||||
n++;
|
||||
if(addr.charAt(ind+1)==sep)
|
||||
n+=7-ncol;
|
||||
addr=addr.slice(ind+1);
|
||||
indtot+=ind+1;
|
||||
}
|
||||
if(ind==-1) return;
|
||||
newaddr = haddr.slice(0,indtot)+iid;
|
||||
oldiid = haddr.slice(indtot);
|
||||
end=oldiid.search(/[^0-9a-f:-]/i);
|
||||
if(end!=-1)
|
||||
newaddr = newaddr+oldiid.slice(end);
|
||||
if(!ie7ll&&newaddr.charAt(0)!='[')
|
||||
newaddr='['+newaddr+']';
|
||||
if(navigator.userAgent.search(/Firefox/i)==-1)
|
||||
newaddr=newaddr.replace('%',esc);
|
||||
return newaddr;
|
||||
}
|
||||
</script>
|
||||
<h1>Node
|
||||
%! nodeid
|
||||
</h1>
|
||||
<h2>Neighbors</h2>
|
||||
<ul>
|
||||
%! neighbors
|
||||
</ul>
|
||||
%!: /footer.html
|
||||
|
1
examples/mb851/webserver-ajax/httpd-fs/sensordata.shtml
Normal file
1
examples/mb851/webserver-ajax/httpd-fs/sensordata.shtml
Normal file
|
@ -0,0 +1 @@
|
|||
%! sensors
|
121
examples/mb851/webserver-ajax/httpd-fs/sensors.shtml
Normal file
121
examples/mb851/webserver-ajax/httpd-fs/sensors.shtml
Normal file
|
@ -0,0 +1,121 @@
|
|||
%!: /header.html
|
||||
<script type="text/javascript">
|
||||
var start;
|
||||
|
||||
i = new Image(50,60)
|
||||
i.src = "spin.gif"
|
||||
|
||||
function load() {
|
||||
var img = document.getElementById("spin");
|
||||
img.innerHTML = ' ';
|
||||
loadSensordata();
|
||||
}
|
||||
|
||||
function loadSensordata() {
|
||||
var r;
|
||||
try { r = new XMLHttpRequest(); }
|
||||
catch(e) {
|
||||
try { r = new ActiveXObject("Msxml2.XMLHTTP"); }
|
||||
catch(e) {
|
||||
try { r = new ActiveXObject("Microsoft.XMLHTTP"); }
|
||||
catch(e) {
|
||||
alert("Your browser does not support AJAX!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
start = new Date();
|
||||
r.open("GET", "/sensordata.shtml", true);
|
||||
r.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
|
||||
r.onreadystatechange = function() {
|
||||
if(r.readyState==1) {
|
||||
var img = document.getElementById("spin");
|
||||
img.innerHTML = '<img src="spin.gif">';
|
||||
}
|
||||
if(r.readyState==4) {
|
||||
var img = document.getElementById("spin");
|
||||
img.innerHTML = 'took ' +
|
||||
((new Date()).getTime()-start.getTime())/1000+
|
||||
' seconds';
|
||||
eval(r.responseText);
|
||||
}
|
||||
}
|
||||
r.send(null);
|
||||
}
|
||||
|
||||
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(m/10, 1);
|
||||
s('temp',n,40,'Temperature '+n+' °C');
|
||||
}
|
||||
function ax(m) {
|
||||
n = m;
|
||||
s('accx',n+2000,4000,'Acceleration (X-axis) '+n+'mg');
|
||||
}
|
||||
function ay(m) {
|
||||
n = m;
|
||||
s('accy',n+2000,4000,'Acceleration (Y-axis) '+n+'mg');
|
||||
}
|
||||
function az(m) {
|
||||
n = m;
|
||||
s('accz',n+2000,4000,'Acceleration (Z-axis) '+n+'mg');
|
||||
}
|
||||
function rs(m) {
|
||||
n = m + 45;
|
||||
s('rs',n,100,'RSSI '+n);
|
||||
}
|
||||
function p(c,l,t,r) {
|
||||
tm=c+l;
|
||||
cp=c*18/tm;
|
||||
lp=l*7.2/tm;
|
||||
lt=t*50.4/tm;
|
||||
lr=r*45.6/tm;
|
||||
n=cp+lp+lt+lr;
|
||||
s('p',n,100,'Power consumption '+dc(n,2)+' mW');
|
||||
s('pc',cp,100,'CPU power '+dc(cp,2)+' mW');
|
||||
s('pl',lp,100,'LPM power '+dc(lp,2)+' mW');
|
||||
s('pr',lr,100,'Radio RX power '+dc(lr,2)+' mW');
|
||||
s('pt',lt,100,'Radio TX power '+dc(lt,2)+' mW');
|
||||
}
|
||||
function v(n) {
|
||||
e('v').innerHTML = n;
|
||||
}
|
||||
</script>
|
||||
<h1>Node
|
||||
%! nodeid
|
||||
</h1>
|
||||
<a href="javascript:loadSensordata();">Reload</a>
|
||||
|
||||
<span id="spin"> </span>
|
||||
<h2>Environment</h2>
|
||||
<div id="temp"></div>
|
||||
<div id="accx"></div>
|
||||
<div id="accy"></div>
|
||||
<div id="accz"></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="v"></div>
|
||||
%!: /footer.html
|
BIN
examples/mb851/webserver-ajax/httpd-fs/spin.gif
Normal file
BIN
examples/mb851/webserver-ajax/httpd-fs/spin.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 496 B |
Loading…
Add table
Add a link
Reference in a new issue