-
Notifications
You must be signed in to change notification settings - Fork 0
/
rFlea.html
51 lines (43 loc) · 1.81 KB
/
rFlea.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>rFlea example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="rflea.js"></script>
</head>
<body>
<h1>rFlea bare example</h1>
<div id="rFlea">
Trying to connect…
</div>
<script type="text/javascript">
//rflea rFlea;
/**
* onrFleaMessage Function that is called whenever new rFlea data messages are received.
* You can use this function to send you date back to rFlea. rFeaSend().
* It accepts one parameters:
* @param {rFlea} rFleaData.message[] array of size 8 with the 8 data fields
* rFleaData.MAC[] array of size 2 with the unique ID of the connected rFlea
*/
function onrFleaMessage(rFleaData){
outputData(rFleaData);
//Now is time to send our DATA. Fill each of the fields with your data. Values form 0 to 255!
//in rFleaData.MAC you have the ID form the rFlea where this message was coming from.
if (rFleaData.MAC==rFleaMAC1)
rFleaSend(1,1,1,1,1,1,1,1,rFleaData.MAC); //returns true if format is correct
// else if (rFleaData.MAC==rFleaMAC2)//we add all the rFlea we have connected
// rFleaSend(2,2,2,2,2,2,2,2,rFleaData.MAC); //returns true if format is correct
};
//Functions that writes in the html plain text the data
function outputData(data) {
var output = "Data package #" + packagesReceived + " received from rFlea #" + data.MAC + ": <br/>";
for (var i = 0; i < data.message.length; i++) {
output += "data" + i + ": " + data.message[i] + "<br/>";
}
$("#rFlea").html(output);
}
</script>
</body>
</html>