forked from CESARBR/knot-cloud-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
53 lines (44 loc) · 1.32 KB
/
demo.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
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://skynet.im/js/skynet.js"></script>
<script>
$( document ).ready(function() {
$('#uuid').append(location.pathname.split("/")[2]);
});
var conn = skynet.createConnection({
"uuid": "1917e841-afb7-11e3-912d-bd75677ad63b",
"token": "xufbkulx6pkqpvidvzmh3qyra6mvx6r",
// server: 'localhost',
// port: 3000
server: 'ws://skynet.im',
port: 80
});
conn.on('ready', function(device){
console.log('Ready');
// Subscribe to device/node i/o
conn.subscribe({
uuid: location.pathname.split("/")[2]
},
function(data){
console.log(data);
});
conn.on('message', function(message){
// console.log('message received', channel, message);
if(typeof message == "string"){
message = JSON.parse(message);
}
if(message && message.payload.x !== undefined){
$('#device').html("X Axis : " + message.payload.x + " Y Axis : " + message.payload.y);
}
});
});
</script>
</head>
<body>
<p>Connecting to Meshblu!</p>
<p>Subscribing to UUID: <span id="uuid"></span></p>
<p>Listening for sensor data...</p>
<div id="device"></div>
</body>
</html>