-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirstDemo.html
68 lines (54 loc) · 1.55 KB
/
firstDemo.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
<html>
<head>
<script src="bower_components/webduino-js/dist/webduino-all.js"></script>
<script>
var board, led;
//board = new webduino.WebArduino('device_id');
// board = new webduino.Arduino({
// 'transport': 'serial',
// 'path': '/dev/cu.usbmodem1421'
// });
// board = new webduino.Arduino({
// 'transport': 'bluetooth',
// 'address': '30:14:09:30:15:67'
// });
// board = new webduino.Arduino({
// 'transport': 'mqtt',
// 'device': '',
// 'server': 'wss://ws.webduino.io:443/',
// 'login': 'admin',
// 'password': 'password'
// });
board = new webduino.Arduino({
'transport': 'websocket',
'url': 'ws://192.168.0.114/'
});
board.on(webduino.BoardEvent.READY, function() {
console.log("Ready...");
var cmd = [0xF0, 0x04, 0x01, 0xF7];
board.send(cmd);
/*
led = new webduino.module.Led(board, board.getDigitalPin(12));
led.blink(500);
setTimeout(function() {
board.close();
}, 5000);
*/
});
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');
// test: should not emit 'disconnect' again
board.disconnect();
});
</script>
</head>
<body>
test
</body>
</html>