-
Notifications
You must be signed in to change notification settings - Fork 56
/
DeviceStatus.html
43 lines (37 loc) · 1.2 KB
/
DeviceStatus.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Device Status</title>
<script src="https://webduino.io/components/webduino-js/dist/webduino-base.min.js"></script>
</head>
<body>
<script>
var strUrl=location.search;
if (strUrl.indexOf("?")!=-1) {
var deviceID = strUrl.split("?")[1].split("&")[0];
var div= document.createElement("div");
div.id="demo-area-01-show";
div.innerHTML= "[ "+ deviceID + " ] connection failed." ;
document.body.appendChild(div);
var board = new webduino.WebArduino(deviceID);
var BoardEvent = webduino.BoardEvent;
var timeInterval = 5000;
board.on(BoardEvent.READY, function() {
setInterval(function(){
board.send([0xF0, 0x0E, 0x07, 0xF7]);
}, timeInterval);
});
board.on(BoardEvent.ERROR, function() {
document.getElementById("demo-area-01-show").innerHTML = "[ "+ deviceID + " ] connection failed." ;
setTimeout(function(){
window.location.reload();
}, timeInterval);
});
board.on(webduino.BoardEvent.STRING_MESSAGE, function(event) {
document.getElementById("demo-area-01-show").innerHTML = "[ "+ deviceID + " ] is connected." ;
});
}
</script>
</body>
</html>