-
Notifications
You must be signed in to change notification settings - Fork 0
/
Discoverer.hx
51 lines (37 loc) · 1.19 KB
/
Discoverer.hx
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
package examples;
import js.Node.console;
/**
* @author Matthijs Kamstra aka [mck]
*/
class Discoverer {
public function new () {
// Found a microbit: id = f4795fe7854c449293d468a4b54273de, address = d0:3f:be:bd:3a:50
var id = "f4795fe7854c449293d468a4b54273de";
var address = "d0:3f:be:bd:3a:50";
// scan for all microbits
console.log('Scanning for microbits');
/*
// discover all microbits
BBCMicrobit.discoverAll(function(microbit) {
console.log('\tFound a microbit: id = %s, address = %s', microbit.id, microbit.address);
});
*/
/*
// to scan for a particular id use:
BBCMicrobit.discoverById(id, function(microbit) {
console.log('\tFound a microbit by id: id = %s, address = %s', microbit.id, microbit.address);
});
*/
/*
// to scan for a particular address use:
BBCMicrobit.discoverByAddress(address, function(microbit) {
console.log('\tFound a microbit by address id = %s, address = %s', microbit.id, microbit.address);
});
*/
function onDiscover(microbit) {
console.log('\tFound a microbit: id = %s, address = %s', microbit.id, microbit.address);
}
BBCMicrobit.discoverAll(onDiscover);
// BBCMicrobit.stopDiscoverAll(onDiscover);
}
}