On Oct 18, 4:40*pm, t...@testnospam.nl wrote:
Here's something to start playing with:
-Copy paste it and edit the line deviceURL= "http://0.0.0.0/headers?"
to point to the ip of your device.
-save it as utf8.
-name it whatever.html.
-open it in the browser (better not IE).
-click the bits buttons to toggle them between 0/1
-click send and an http GET request will be sent to your device:
something like :
http://0.0.0.0/headers?&rnd=6808913279445241&data=fe
-in the device, extract from the url the "&data=xx" part and ignore
the rest.
-the bits are sent in text as hex: the last 2 chars of the url.
-feel free to ask any questions.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Binary & buttons</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="jorge">
<!-- Date: 2008-10-19 -->
<style>
button { width: 50px; height: 35px; }
.sendBtn { width: 90px; height: 35px; }
</style>
<script>
window.onload= function (event) {
var i= 0, max= 7, d= document, bits= [], e,
sendBtn= d.createElement('button');
do {
e= bits[i]= d.createElement('button');
e.bit= 1;
e.weight= Math.pow(2, max-i);
(e.onclick= bitClick).apply(e);
d.body.appendChild(e);
d.body.appendChild(d.createTextNode(i<max ? "+" : "="));
} while (++i <= max)
d.body.appendChild(sendBtn);
sendBtn.className= "sendBtn";
sendBtn.onclick= function () {
var e, deviceURL= "http://0.0.0.0/headers?",
rnd= "&rnd="+ (""+Math.random()).substr(2);
e= d.createElement('img');
e.src= deviceURL+ rnd+ "&data="+ sendBtn.hex;
d.body.appendChild(d.createTextNode(e.src));
d.body.appendChild(e);
d.body.appendChild(d.createElement('br'));
};
d.body.appendChild(d.createElement('br'));
function bitClick (event) {
var i= bits.length, hex= 0;
this.bit= +(!this.bit);
this.innerHTML= this.bit*this.weight;
while (--i >= 0) {
hex+= +bits[i].innerHTML;
}
if ((sendBtn.hex= hex.toString(16)).length === 1) {
sendBtn.hex= "0"+ sendBtn.hex;
}
sendBtn.innerHTML= "send: 0x"+sendBtn.hex;
}
};
</script>
</head>
<body>
</body>
</html>
--
Jorge
"Silly things such as logic, common sense and rational thoughts are
not allowed in this forum."