-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenDeviceID.html
72 lines (61 loc) · 1.77 KB
/
genDeviceID.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<html>
<head>
<script src="bower_components/webduino-js/dist/webduino-all.js"></script>
<style>
#light {
width: 300px;
height: 120px;
background-color: #af6666;
}
</style>
</head>
<body>
<div id='light'>
</div>
<script>
var board, led;
board = new webduino.Arduino({
'transport': 'websocket',
'url': 'ws://192.168.0.71'
});
board.on(webduino.BoardEvent.READY, function() {
console.log("board ready...");
led = new webduino.module.Led(board, board.getDigitalPin(12));
light.addEventListener('click', function() {
var cmd = [0xF0, 0x0E, 0x0B];
var url = "192.168.0.12";
for (i = 0; i < url.length; i++) {
cmd.push(url.charCodeAt(i));
}
cmd.push(0xF7);
board.send(cmd);
}, false);
});
board.on(webduino.BoardEvent.ERROR, function(err) {
console.log('board error', err.message);
});
board.on(webduino.BoardEvent.BEFOREDISCONNECT, function() {
console.log('board beforedisconnect');
});
board.on(webduino.BoardEvent.DISCONNECT, function() {
console.log('board disconnect');
board.disconnect();
});
board.on(webduino.BoardEvent.STRING_MESSAGE,
function(event) {
var m = event.message;
console.log('STRING:', m);
});
board.on(webduino.BoardEvent.SYSEX_MESSAGE,
function(event) {
var m = event.message;
var str = '';
console.log("SYSEX_MESSAGE (" + m[2] + ")");
for (var i = 3; i < m.length; i++) {
str += String.fromCharCode(m[i]);
}
console.log(str);
});
</script>
</body>
</html>