-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfindBrushId.js
29 lines (23 loc) · 895 Bytes
/
findBrushId.js
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
var async = require('async');
var noble = require('noble');
var OralB_manufacturerData = 'dc00010205030000000101';
process.env['NOBLE_HCI_DEVICE_ID'] = 0
noble.on('stateChange', function(state) {
console.log('changed state to:' + noble.state);
if (state === 'poweredOn') {
noble.startScanning();
} else {
console.log('changed state to off: ' + noble.state);
noble.stopScanning();
}
});
console.log('Searching for OralB Toothbrushes with manufacturerData: "' + OralB_manufacturerData +'"...');
noble.on('discover', function(peripheral) {
var advertisement = peripheral.advertisement;
if (advertisement.manufacturerData) {
if (advertisement.manufacturerData.toString('hex') === OralB_manufacturerData) {
console.log('Found OralB Tootbrush with ID: ' + peripheral.id);
noble.stopScanning();
}
}
});